diff --git a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java
index 89d3963..b19ea57 100644
--- a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java
@@ -1,5 +1,27 @@
 package org.onap.vid.category;
 
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
 import org.onap.vid.model.ListOfErrorsResponse;
 
 import java.util.List;
@@ -9,6 +31,10 @@
     public AddCategoryOptionResponse() {
     }
 
+    public AddCategoryOptionResponse(String error) {
+        errors.add(error);
+    }
+
     public AddCategoryOptionResponse(List<String> errors) {
         super(errors);
     }
diff --git a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java
index 5db4746..8e9b144 100644
--- a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java
+++ b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java
@@ -1,7 +1,30 @@
 package org.onap.vid.category;
 
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 public class AddCategoryOptionsRequest {
 
@@ -10,4 +33,17 @@
 	public AddCategoryOptionsRequest() {
 		options = new ArrayList<>();
 	}
+
+	@Override
+	public boolean equals(Object o) {
+		if (this == o) return true;
+		if (o == null || this.getClass() != o.getClass()) return false;
+		AddCategoryOptionsRequest that = (AddCategoryOptionsRequest) o;
+		return Objects.equals(this.options, that.options);
+	}
+
+	@Override
+	public int hashCode() {
+		return Objects.hash(this.options);
+	}
 }
diff --git a/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java b/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java
index 355e548..dc0ecba 100644
--- a/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java
+++ b/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java
@@ -1,5 +1,29 @@
 package org.onap.vid.category;
 
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+import java.util.Objects;
+
 public class CategoryParameterOptionRep {
 
     private String id;
@@ -28,4 +52,18 @@
     public void setName(String name) {
         this.name = name;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || this.getClass() != o.getClass()) return false;
+        CategoryParameterOptionRep that = (CategoryParameterOptionRep) o;
+        return Objects.equals(this.id, that.id) &&
+                Objects.equals(this.name, that.name);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(this.id, this.name);
+    }
 }
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java b/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java
index 0976f40..1a3eb42 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java
@@ -1,6 +1,30 @@
 package org.onap.vid.controllers;
 
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 
+import static org.onap.vid.utils.Logging.getMethodCallerName;
+
+import javax.ws.rs.ForbiddenException;
 import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.vid.category.AddCategoryOptionResponse;
@@ -14,124 +38,114 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.ForbiddenException;
-import java.util.Arrays;
-import java.util.Collections;
-
-import static org.onap.vid.utils.Logging.getMethodCallerName;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * Controler for APIs that are used only by vid operators
  */
 
 @RestController
-@RequestMapping(MaintenanceController.MAINTENANCE)
+@RequestMapping("maintenance")
 public class MaintenanceController extends UnRestrictedBaseController {
 
-    public static final String MAINTENANCE = "maintenance";
+    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MaintenanceController.class);
+    private CategoryParameterService categoryParameterService;
 
     @Autowired
-    protected CategoryParameterService categoryParameterService;
-    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MaintenanceController.class);
+    public MaintenanceController(CategoryParameterService categoryParameterService) {
+        this.categoryParameterService = categoryParameterService;
+    }
 
     /**
      * Add list of options to one category parameter
-     * @param request the request
-     * @return the new option
-     * @throws Exception the exception
      */
     @RequestMapping(value = "/category_parameter/{categoryName}", method = RequestMethod.POST)
-    public ResponseEntity addCategoryOptions (
-            HttpServletRequest request, @PathVariable String categoryName, @RequestBody AddCategoryOptionsRequest option) {
+    public ResponseEntity addCategoryOptions(@PathVariable String categoryName,
+        @RequestBody AddCategoryOptionsRequest option) {
         debugStartLog();
         try {
-            AddCategoryOptionResponse response = categoryParameterService.createCategoryParameterOptions(categoryName, option);
-            HttpStatus httpStatus = response.getErrors().size()>0 ? HttpStatus.MULTI_STATUS : HttpStatus.OK;
+            AddCategoryOptionResponse response = categoryParameterService
+                .createCategoryParameterOptions(categoryName, option);
+            HttpStatus httpStatus = response.getErrors().isEmpty() ? HttpStatus.OK : HttpStatus.MULTI_STATUS;
             debugEndLog(response);
-            return new ResponseEntity<>(response, httpStatus);
-        }
-        catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) {
-            return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.NOT_FOUND);
-        }
-        catch (Exception exception) {
+            return createResponseWithBody(httpStatus, response);
+        } catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) {
+            return createResponseWithBody(HttpStatus.NOT_FOUND, new AddCategoryOptionResponse(exception.getMessage()));
+        } catch (RuntimeException exception) {
             LOGGER.error("failed to add option to parameter category " + categoryName, exception);
-            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
         }
     }
 
     @RequestMapping(value = "/category_parameter/{categoryName}", method = RequestMethod.PUT)
-    public ResponseEntity updateNameForOption (
-            HttpServletRequest request, @PathVariable String categoryName, @RequestBody CategoryParameterOptionRep option) {
+    public ResponseEntity updateNameForOption(@PathVariable String categoryName,
+        @RequestBody CategoryParameterOptionRep option) {
         debugStartLog();
         try {
-            AddCategoryOptionResponse response = categoryParameterService.updateCategoryParameterOption(categoryName, option);
-            HttpStatus httpStatus = response.getErrors().size()>0 ? HttpStatus.MULTI_STATUS : HttpStatus.OK;
+            AddCategoryOptionResponse response = categoryParameterService
+                .updateCategoryParameterOption(categoryName, option);
+            HttpStatus httpStatus = response.getErrors().isEmpty() ? HttpStatus.OK : HttpStatus.MULTI_STATUS;
             debugEndLog(response);
-            return new ResponseEntity<>(response, httpStatus);
-        }
-        catch (ForbiddenException exception) {
-            return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.FORBIDDEN);
-        }
-        catch (CategoryParameterServiceImpl.UnfoundedCategoryException|CategoryParameterServiceImpl.UnfoundedCategoryOptionException exception) {
-            return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.NOT_FOUND);
-        }
-        catch (CategoryParameterServiceImpl.AlreadyExistOptionNameException exception) {
-            return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.CONFLICT);
-        }
-        catch (Exception exception) {
+            return createResponseWithBody(httpStatus, response);
+        } catch (ForbiddenException exception) {
+            return createResponseWithBody(HttpStatus.FORBIDDEN, new AddCategoryOptionResponse(exception.getMessage()));
+        } catch (CategoryParameterServiceImpl.UnfoundedCategoryException | CategoryParameterServiceImpl.UnfoundedCategoryOptionException exception) {
+            return createResponseWithBody(HttpStatus.NOT_FOUND, new AddCategoryOptionResponse(exception.getMessage()));
+
+        } catch (CategoryParameterServiceImpl.AlreadyExistOptionNameException exception) {
+            return createResponseWithBody(HttpStatus.CONFLICT, new AddCategoryOptionResponse(exception.getMessage()));
+
+        } catch (RuntimeException exception) {
             LOGGER.error("failed to update option to parameter category " + categoryName, exception);
-            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
         }
     }
 
     /**
      * Gets the owning entity properties.
-     * @param request the request
-     * @return the property
-     * @throws Exception the exception
      */
     @RequestMapping(value = "/category_parameter", method = RequestMethod.GET)
-    public ResponseEntity getCategoryParameter(HttpServletRequest request, @RequestParam(value="familyName", required = true) Family familyName) {
+    public ResponseEntity getCategoryParameter(@RequestParam(value = "familyName", required = true) Family familyName) {
         debugStartLog();
         try {
             CategoryParametersResponse response = categoryParameterService.getCategoryParameters(familyName);
             debugEndLog(response);
-            return new ResponseEntity<>(response, HttpStatus.OK);
-        }
-        catch (Exception exception) {
+            return ResponseEntity.ok().body(response);
+        } catch (RuntimeException exception) {
             LOGGER.error("failed to retrieve category parameter list from DB.", exception);
-            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
         }
     }
 
-
     /**
      * Delete option of the category.
-     * @param request the request
-     * @throws Exception the exception
      */
-    @RequestMapping(value = "/delete_category_parameter/{categoryName}", method = RequestMethod.POST)
-    public ResponseEntity deleteCategoryOption (
-            HttpServletRequest request, @PathVariable String categoryName, @RequestBody CategoryParameterOption option) {
+    @RequestMapping(value = "/delete_category_parameter/{categoryName}", method = RequestMethod.DELETE)
+    public ResponseEntity deleteCategoryOption(@PathVariable String categoryName,
+        @RequestBody CategoryParameterOption option) {
         debugStartLog();
 
         try {
             categoryParameterService.deleteCategoryOption(categoryName, option);
             debugEndLog(HttpStatus.OK);
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) {
-            return new ResponseEntity<>(new AddCategoryOptionResponse(Arrays.asList(exception.getMessage())), HttpStatus.NOT_FOUND);
-        }
-        catch (Exception exception) {
+            return ResponseEntity.status(HttpStatus.OK).build();
+        } catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) {
+            return createResponseWithBody(HttpStatus.NOT_FOUND, new AddCategoryOptionResponse(exception.getMessage()));
+        } catch (RuntimeException exception) {
             LOGGER.error("failed to add/update owning entity option", exception);
-            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
         }
     }
 
+    private ResponseEntity createResponseWithBody(HttpStatus status, AddCategoryOptionResponse response) {
+        return ResponseEntity.status(status).body(response);
+    }
+
     private void debugStartLog() {
         LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodCallerName());
     }
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java
index 99824e7..91617ff 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java
@@ -1,12 +1,41 @@
 package org.onap.vid.model;
 
-//import org.hibernate.annotations.Table;
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 
-import javax.persistence.*;
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.Set;
-
-//import javax.persistence.*;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
 
 @Entity
 @Table(name = "vid_category_parameter", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
@@ -72,4 +101,20 @@
     public void setIdSupported(boolean idSupported) {
         this.idSupported = idSupported;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || this.getClass() != o.getClass()) return false;
+        CategoryParameter that = (CategoryParameter) o;
+        return this.idSupported == that.idSupported &&
+                Objects.equals(this.name, that.name) &&
+                Objects.equals(this.family, that.family) &&
+                Objects.equals(this.options, that.options);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(this.name, this.idSupported, this.family, this.options);
+    }
 }
diff --git a/vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java
index 80c6593..7bdd6b8 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java
@@ -1,66 +1,340 @@
 package org.onap.vid.controllers;
 
-import javax.servlet.http.HttpServletRequest;
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
 
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.then;
+import static org.mockito.BDDMockito.willThrow;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.times;
+import static org.onap.vid.model.CategoryParameter.Family.PARAMETER_STANDARDIZATION;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
+import java.util.function.BiFunction;
+import javax.ws.rs.ForbiddenException;
+import org.apache.log4j.BasicConfigurator;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatcher;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.vid.category.AddCategoryOptionResponse;
 import org.onap.vid.category.AddCategoryOptionsRequest;
 import org.onap.vid.category.CategoryParameterOptionRep;
+import org.onap.vid.category.CategoryParametersResponse;
+import org.onap.vid.model.CategoryParameter;
 import org.onap.vid.model.CategoryParameterOption;
-import org.springframework.http.ResponseEntity;
+import org.onap.vid.services.CategoryParameterService;
+import org.onap.vid.services.CategoryParameterServiceImpl;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.ResultActions;
+import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 
+@RunWith(MockitoJUnitRunner.class)
 public class MaintenanceControllerTest {
 
-    private MaintenanceController createTestSubject() {
-        return new MaintenanceController();
+    final private String MAINTENANCE_CATEGORY_PATH = "/maintenance/category_parameter";
+    final private String CATEGORY_PARAMETER_PATH = MAINTENANCE_CATEGORY_PATH + "/{name}";
+    final private String DELETE_CATEGORY_PATH = "/maintenance/delete_category_parameter/{name}";
+
+    @Mock
+    private CategoryParameterService service;
+    private MaintenanceController maintenanceController;
+    private MockMvc mockMvc;
+    private ObjectMapper objectMapper;
+
+    @Before
+    public void setUp() {
+        maintenanceController = new MaintenanceController(service);
+        BasicConfigurator.configure();
+        mockMvc = MockMvcBuilders.standaloneSetup(maintenanceController).build();
+        objectMapper = new ObjectMapper();
     }
 
     @Test
-    public void testAddCategoryOptions() throws Exception {
-        MaintenanceController testSubject;
-        HttpServletRequest request = null;
-        String categoryName = "";
-        AddCategoryOptionsRequest option = null;
-        ResponseEntity result;
+    public void addCategoryOptions_shouldReturnMultiStatus_whenErrorsExist() throws Exception {
+        String categoryName = "catName1";
+        AddCategoryOptionsRequest req = new AddCategoryOptionsRequest();
+        req.options = ImmutableList.of("first option", "second option");
+        AddCategoryOptionResponse addCategoryOptionResponse = new AddCategoryOptionResponse(
+            ImmutableList.of("error one", "error two"));
 
-        // default test
-        testSubject = createTestSubject();
-        result = testSubject.addCategoryOptions(request, categoryName, option);
+        given(service.createCategoryParameterOptions(eq(categoryName), argThat(requestMatcher(req))))
+            .willReturn(addCategoryOptionResponse);
+
+        prepareRequestExpectations(MockMvcRequestBuilders::post, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(req))
+            .andExpect(status().isMultiStatus())
+            .andExpect(
+                content().json(objectMapper
+                    .writeValueAsString(addCategoryOptionResponse)));
     }
 
     @Test
-    public void testUpdateNameForOption() throws Exception {
-        MaintenanceController testSubject;
-        HttpServletRequest request = null;
-        String categoryName = "";
-        CategoryParameterOptionRep option = null;
-        ResponseEntity result;
+    public void addCategoryOptions_shouldReturnOk_whenNoErrorsExist() throws Exception {
+        String categoryName = "catName2";
+        AddCategoryOptionsRequest req = new AddCategoryOptionsRequest();
+        req.options = ImmutableList.of("first option", "second option", "third option");
+        AddCategoryOptionResponse addCategoryOptionResponse = new AddCategoryOptionResponse(Collections.emptyList());
 
-        // default test
-        testSubject = createTestSubject();
-        result = testSubject.updateNameForOption(request, categoryName, option);
+        given(service.createCategoryParameterOptions(eq(categoryName), argThat(requestMatcher(req))))
+            .willReturn(addCategoryOptionResponse);
+        prepareRequestExpectations(MockMvcRequestBuilders::post, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(req))
+            .andExpect(status().isOk())
+            .andExpect(content().json(
+                objectMapper.writeValueAsString(addCategoryOptionResponse)));
     }
 
     @Test
-    public void testGetCategoryParameter() throws Exception {
-        MaintenanceController testSubject;
-        HttpServletRequest request = null;
-        ResponseEntity result;
+    public void addCategoryOptions_shouldReturnNotFound_whenUnfoundedCategoryExceptionIsThrown() throws Exception {
+        String unfoundedMsg = "unfounded category exception message";
+        String categoryName = "catName3";
+        AddCategoryOptionsRequest req = new AddCategoryOptionsRequest();
+        req.options = ImmutableList.of("first option");
 
-        // default test
-        testSubject = createTestSubject();
-        result = testSubject.getCategoryParameter(request, null);
+        given(service.createCategoryParameterOptions(eq(categoryName), argThat(requestMatcher(req))))
+            .willThrow(new CategoryParameterServiceImpl.UnfoundedCategoryException(unfoundedMsg));
+
+        prepareRequestExpectations(MockMvcRequestBuilders::post, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(req))
+            .andExpect(status().isNotFound())
+            .andExpect(content().json(
+                objectMapper.writeValueAsString(new AddCategoryOptionResponse(ImmutableList.of(unfoundedMsg)))));
     }
 
     @Test
-    public void testDeleteCategoryOption() throws Exception {
-        MaintenanceController testSubject;
-        HttpServletRequest request = null;
-        String categoryName = "";
-        CategoryParameterOption option = null;
-        ResponseEntity result;
+    public void addCategoryOptions_shouldReturnInternalServerError_whenExceptionIsThrown() throws Exception {
+        String categoryName = "catName13";
+        AddCategoryOptionsRequest req = new AddCategoryOptionsRequest();
+        req.options = ImmutableList.of("option second", "first option");
 
-        // default test
-        testSubject = createTestSubject();
-        result = testSubject.deleteCategoryOption(request, categoryName, option);
+        given(service.createCategoryParameterOptions(eq(categoryName), argThat(requestMatcher(req))))
+            .willThrow(new RuntimeException());
+
+        prepareRequestExpectations(MockMvcRequestBuilders::post, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(req))
+            .andExpect(status().isInternalServerError());
+    }
+
+    @Test
+    public void updateNameForOption_shouldReturnMultiStatus_whenErrorsExist() throws Exception {
+        String categoryName = "catName4";
+        CategoryParameterOptionRep categoryParameterOptionRep = new CategoryParameterOptionRep("id1", "name1");
+        AddCategoryOptionResponse addCategoryOptionResponse = new AddCategoryOptionResponse(
+            ImmutableList.of("error one", "error two"));
+
+        given(service
+            .updateCategoryParameterOption(eq(categoryName), argThat(requestMatcher(categoryParameterOptionRep))))
+            .willReturn(addCategoryOptionResponse);
+
+        prepareRequestExpectations(MockMvcRequestBuilders::put, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOptionRep))
+            .andExpect(status().isMultiStatus())
+            .andExpect(
+                content().json(objectMapper
+                    .writeValueAsString(addCategoryOptionResponse)));
+    }
+
+    @Test
+    public void updateNameForOption_shouldReturnOk_whenNoErrorsExist() throws Exception {
+        String categoryName = "catName5";
+        CategoryParameterOptionRep categoryParameterOptionRep = new CategoryParameterOptionRep("id2", "name2");
+        AddCategoryOptionResponse addCategoryOptionResponse = new AddCategoryOptionResponse(Collections.emptyList());
+
+        given(service
+            .updateCategoryParameterOption(eq(categoryName), argThat(requestMatcher(categoryParameterOptionRep))))
+            .willReturn(addCategoryOptionResponse);
+        prepareRequestExpectations(MockMvcRequestBuilders::put, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOptionRep))
+            .andExpect(status().isOk())
+            .andExpect(content().json(
+                objectMapper.writeValueAsString(addCategoryOptionResponse)));
+    }
+
+    @Test
+    public void updateNameForOption_shouldReturnForbidden_whenForbiddenExceptionIsThrown() throws Exception {
+        String categoryName = "catName6";
+        CategoryParameterOptionRep categoryParameterOptionRep = new CategoryParameterOptionRep("id3", "name3");
+
+        given(service
+            .updateCategoryParameterOption(eq(categoryName), argThat(requestMatcher(categoryParameterOptionRep))))
+            .willThrow(new ForbiddenException());
+        prepareRequestExpectations(MockMvcRequestBuilders::put, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOptionRep))
+            .andExpect(status().isForbidden())
+            .andExpect(content().json(
+                objectMapper
+                    .writeValueAsString(new AddCategoryOptionResponse(ImmutableList.of("HTTP 403 Forbidden")))));
+    }
+
+    @Test
+    public void updateNameForOption_shouldReturnNotFound_whenUnfoundedIsThrown() throws Exception {
+        String unfoundedOptionMsg = "unfounded category option exception message";
+        String categoryName = "catName7";
+        CategoryParameterOptionRep categoryParameterOptionRep = new CategoryParameterOptionRep("id4", "name4");
+
+        given(service
+            .updateCategoryParameterOption(eq(categoryName), argThat(requestMatcher(categoryParameterOptionRep))))
+            .willThrow(new CategoryParameterServiceImpl.UnfoundedCategoryOptionException(unfoundedOptionMsg));
+
+        prepareRequestExpectations(MockMvcRequestBuilders::put, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOptionRep))
+            .andExpect(status().isNotFound())
+            .andExpect(content().json(
+                objectMapper.writeValueAsString(new AddCategoryOptionResponse(ImmutableList.of(unfoundedOptionMsg)))));
+    }
+
+    @Test
+    public void updateNameForOption_shouldReturnConflict_whenAlreadyExistOptionNameIsThrown() throws Exception {
+        String conflictMsg = "already exists option name exception message";
+        String categoryName = "catName8";
+        CategoryParameterOptionRep categoryParameterOptionRep = new CategoryParameterOptionRep("id5", "name5");
+
+        given(service
+            .updateCategoryParameterOption(eq(categoryName), argThat(requestMatcher(categoryParameterOptionRep))))
+            .willThrow(new CategoryParameterServiceImpl.AlreadyExistOptionNameException(conflictMsg));
+
+        prepareRequestExpectations(MockMvcRequestBuilders::put, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOptionRep))
+            .andExpect(status().isConflict())
+            .andExpect(content().json(
+                objectMapper.writeValueAsString(new AddCategoryOptionResponse(ImmutableList.of(conflictMsg)))));
+    }
+
+    @Test
+    public void updateNameForOption_shouldReturnInternalServerError_whenExceptionIsThrown() throws Exception {
+        String categoryName = "catName18";
+        CategoryParameterOptionRep categoryParameterOptionRep = new CategoryParameterOptionRep("id6", "name6");
+
+        given(service
+            .updateCategoryParameterOption(eq(categoryName), argThat(requestMatcher(categoryParameterOptionRep))))
+            .willThrow(new RuntimeException());
+
+        prepareRequestExpectations(MockMvcRequestBuilders::put, CATEGORY_PARAMETER_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOptionRep))
+            .andExpect(status().isInternalServerError());
+    }
+
+    @Test
+    public void getCategoryParameter_shouldReturnExistingMap() throws Exception {
+        CategoryParametersResponse categoryParametersResponse =
+            new CategoryParametersResponse(
+                ImmutableMap.of(
+                    "key1", ImmutableList.of(
+                        new CategoryParameterOptionRep("testId", "testName"))));
+
+        given(service.getCategoryParameters(PARAMETER_STANDARDIZATION))
+            .willReturn(categoryParametersResponse);
+
+        mockMvc.perform(get(MAINTENANCE_CATEGORY_PATH)
+            .param("familyName", "PARAMETER_STANDARDIZATION")
+            .accept(MediaType.APPLICATION_JSON))
+            .andExpect(status().isOk())
+            .andExpect(content().json(objectMapper.writeValueAsString(categoryParametersResponse)));
+    }
+
+    @Test
+    public void getCategoryParameter_shouldReturnInternalServerError_whenExceptionIsThrown() throws Exception {
+        given(service.getCategoryParameters(PARAMETER_STANDARDIZATION))
+            .willThrow(new RuntimeException());
+
+        mockMvc.perform(get(MAINTENANCE_CATEGORY_PATH)
+            .param("familyName", "PARAMETER_STANDARDIZATION")
+            .accept(MediaType.APPLICATION_JSON))
+            .andExpect(status().isInternalServerError());
+    }
+
+    @Test
+    public void deleteCategoryOption_shouldReturnOk_whenNoExceptionIsThrown() throws Exception {
+        String categoryName = "catName9";
+        CategoryParameterOption categoryParameterOption = new CategoryParameterOption("id1", "name1",
+            new CategoryParameter());
+
+        prepareRequestExpectations(MockMvcRequestBuilders::delete, DELETE_CATEGORY_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOption))
+            .andExpect(status().isOk());
+
+        then(service).should(times(1))
+            .deleteCategoryOption(eq(categoryName), argThat(requestMatcher(categoryParameterOption)));
+    }
+
+    @Test
+    public void deleteCategoryOption_shouldReturnNotFound_whenUnfoundedExceptionIsThrown() throws Exception {
+        String unfoundedMsg = "unfounded category exception message";
+        String categoryName = "catName10";
+        CategoryParameterOption categoryParameterOption = new CategoryParameterOption("id2", "name2",
+            new CategoryParameter());
+
+        willThrow(new CategoryParameterServiceImpl.UnfoundedCategoryException(unfoundedMsg))
+            .given(service).deleteCategoryOption(eq(categoryName), argThat(requestMatcher(categoryParameterOption)));
+
+        prepareRequestExpectations(MockMvcRequestBuilders::delete, DELETE_CATEGORY_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOption))
+            .andExpect(status().isNotFound())
+            .andExpect(content().json(
+                objectMapper.writeValueAsString(new AddCategoryOptionResponse(ImmutableList.of(unfoundedMsg)))));
+    }
+
+    @Test
+    public void deleteCategoryOption_shouldReturnInternalServerError_whenExceptionIsThrown() throws Exception {
+        String categoryName = "catName19";
+        CategoryParameterOption categoryParameterOption = new CategoryParameterOption("id3", "name3",
+            new CategoryParameter());
+
+        willThrow(new RuntimeException()).given(service)
+            .deleteCategoryOption(eq(categoryName), argThat(requestMatcher(categoryParameterOption)));
+
+        prepareRequestExpectations(MockMvcRequestBuilders::delete, DELETE_CATEGORY_PATH, categoryName,
+            objectMapper.writeValueAsString(categoryParameterOption))
+            .andExpect(status().isInternalServerError());
+    }
+
+    private <T> ArgumentMatcher<T> requestMatcher(T t) {
+        return new ArgumentMatcher<T>() {
+            @Override
+            public boolean matches(Object o) {
+                return t.equals(o);
+            }
+        };
+    }
+
+    private ResultActions prepareRequestExpectations(
+        BiFunction<String, String, MockHttpServletRequestBuilder> httpMethod,
+        String path, String name, String jsonContent) throws Exception {
+        return mockMvc.perform(httpMethod.apply(path, name)
+            .contentType(MediaType.APPLICATION_JSON)
+            .content(jsonContent));
     }
 }
\ No newline at end of file
