diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java
index 13db1ae..b4806f1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
 package org.onap.vid.services;
 
 import com.fasterxml.jackson.core.JsonParseException;
@@ -16,12 +36,12 @@
 
     @Inject
     private AsyncInstantiationBusinessLogic asyncInstantiationBL;
+    public static final String FAILED_MSO_REQUEST_STATUS = "FAILED";
 
     @Override
     public void setFailedAuditStatusFromMso(UUID jobUuid, String requestId, int statusCode, String msoResponse){
-        final String failedMsoRequestStatus = "FAILED";
         String additionalInfo = formatExceptionAdditionalInfo(statusCode, msoResponse);
-        asyncInstantiationBL.auditMsoStatus(jobUuid, failedMsoRequestStatus, requestId, additionalInfo);
+        asyncInstantiationBL.auditMsoStatus(jobUuid, FAILED_MSO_REQUEST_STATUS, requestId, additionalInfo);
     }
 
     private String formatExceptionAdditionalInfo(int statusCode, String msoResponse) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java
index fa531ff..b3d20a6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
 package org.onap.vid.services;
 
 import org.onap.vid.category.AddCategoryOptionResponse;
@@ -20,6 +40,7 @@
 @Service
 public class CategoryParameterServiceImpl implements CategoryParameterService {
 
+    public static final String OPTION_ALREADY_EXIST_FOR_CATEGORY = "Option %s already exist for category %s";
     @Autowired
     private DataAccessService dataAccessService;
 
@@ -68,7 +89,7 @@
         Set<String> categoryOptions = categoryParameter.getOptions().stream().map(CategoryParameterOption::getName).collect(Collectors.toSet());
         for (String optionName : optionsRequest.options) {
             if (categoryOptions.contains(optionName)) {
-                response.getErrors().add(String.format("Option %s already exist for category %s", optionName, categoryName));
+                response.getErrors().add(String.format(OPTION_ALREADY_EXIST_FOR_CATEGORY, optionName, categoryName));
                 continue;
             }
             String appId = categoryParameter.isIdSupported() ? UUID.randomUUID().toString() : optionName;
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java
index 21b1ec1..231b352 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/PombaServiceImpl.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
 package org.onap.vid.services;
 
 import org.onap.vid.aai.PombaClientInterface;
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
index dc2541b..1890a5b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
 package org.onap.vid.services;
 
 import com.google.common.cache.CacheBuilder;
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java
new file mode 100644
index 0000000..3d2a20b
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+package org.onap.vid.services;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.UUID;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class AuditServiceImplTest {
+  @Mock
+  private AsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+  @InjectMocks
+  private AuditServiceImpl auditService;
+
+  @BeforeClass
+  public void init() {
+    initMocks(this);
+  }
+
+  @Test
+  public void setFailedAuditStatusFromMsoTest() {
+
+    UUID jobUuid = UUID.randomUUID();
+    String requestId = "1";
+    int statusCode = HttpStatus.OK_200.getStatusCode();
+    String msoResponse = "{}";
+
+    auditService.setFailedAuditStatusFromMso(jobUuid, requestId, statusCode, msoResponse);
+
+    verify(asyncInstantiationBL, times(1))
+        .auditMsoStatus(
+            Mockito.any(UUID.class),
+            Mockito.anyString(),
+            Mockito.anyString(),
+            Mockito.anyString());
+  }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/BulkInstantiationServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/BulkInstantiationServiceImplTest.java
new file mode 100644
index 0000000..6677da3
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/services/BulkInstantiationServiceImplTest.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+package org.onap.vid.services;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.ws.rs.NotFoundException;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobsBrokerService;
+import org.onap.vid.job.impl.JobDaoImpl;
+import org.onap.vid.model.JobBulk;
+import org.onap.vid.model.JobModel;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+public class BulkInstantiationServiceImplTest {
+
+  @Mock
+  private JobsBrokerService jobsBrokerService;
+
+  @Mock
+  private JobAdapter jobAdapter;
+
+  @InjectMocks
+  private BulkInstantiationServiceImpl testSubject;
+
+  @BeforeSuite
+  public void before() {
+    initMocks(this);
+  }
+
+  @BeforeMethod
+  public void resetMocks() {
+    reset(jobsBrokerService);
+    reset(jobAdapter);
+  }
+
+  @Test
+  public void saveBulkTest() {
+    UUID uuid = UUID.randomUUID();
+    Map<String, Object> bulkRequest = new HashMap<>();
+    List<Job> jobList = new ArrayList<>();
+    jobList.add(createJob(uuid));
+    when(jobAdapter.createBulkOfJobs(bulkRequest)).thenReturn(jobList);
+
+    JobBulk jobBulk = createJobBulk(jobList);
+    when(jobAdapter.toModelBulk(jobList)).thenReturn(jobBulk);
+
+    JobBulk result = testSubject.saveBulk(bulkRequest);
+
+    Assert.assertEquals(result.getJobs().size(), jobList.size());
+    Assert.assertEquals(result.getJobs().get(0).getUuid(), uuid);
+  }
+
+  @Test
+  public void getJobTest() {
+    UUID uuid = UUID.randomUUID();
+    Job job = createJob(uuid);
+    doReturn(job).when(jobsBrokerService).peek(uuid);
+    JobModel jobModel = createJobModel(uuid);
+    when(jobAdapter.toModel(job)).thenReturn(jobModel);
+
+    JobModel response = testSubject.getJob(uuid);
+    Assert.assertEquals(response.getUuid(), uuid);
+  }
+
+  @Test(expectedExceptions = {NotFoundException.class})
+  public void getJobTest_throwsExceptionOnEmptyUUID() {
+    UUID uuid = null;
+    Job job = createJob(uuid);
+    doReturn(job).when(jobsBrokerService).peek(uuid);
+    JobModel response = testSubject.getJob(uuid);
+    Assert.fail();
+  }
+
+  @Test(expectedExceptions = {NotFoundException.class})
+  public void getJobTest_throwsExceptionCauseJobDoesNotExists() {
+    UUID uuid = UUID.randomUUID();
+    doReturn(null).when(jobsBrokerService).peek(uuid);
+    JobModel response = testSubject.getJob(uuid);
+    Assert.fail();
+  }
+
+  private Job createJob(UUID uuid) {
+    Job job = new JobDaoImpl();
+    job.setUuid(uuid);
+    return job;
+  }
+
+  private JobModel createJobModel(UUID uuid) {
+    JobModel jobModel = new JobModel();
+    jobModel.setUuid(uuid);
+    return jobModel;
+  }
+
+  private JobBulk createJobBulk(List<Job> jobList) {
+    List<JobModel> jobBulkList = new ArrayList<>();
+    jobList.stream().forEach(job -> {
+      JobModel jm = new JobModel();
+      jm.setUuid(job.getUuid());
+      jobBulkList.add(jm);
+    });
+    return new JobBulk(jobBulkList);
+  }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java
index 440a2a7..04ee464 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java
@@ -1,80 +1,261 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
 package org.onap.vid.services;
 
-import org.junit.Test;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.ws.rs.ForbiddenException;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.portalsdk.core.service.DataAccessService;
 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.CategoryParameter.Family;
 import org.onap.vid.model.CategoryParameterOption;
+import org.onap.vid.services.CategoryParameterServiceImpl.AlreadyExistOptionNameException;
+import org.onap.vid.services.CategoryParameterServiceImpl.UnfoundedCategoryException;
+import org.onap.vid.services.CategoryParameterServiceImpl.UnfoundedCategoryOptionException;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
 
 public class CategoryParameterServiceImplTest {
 
-    private CategoryParameterServiceImpl createTestSubject() {
-        return new CategoryParameterServiceImpl();
+    private static final String CATEGORY_NAME = "SAMPLE_CATEGORY_NAME";
+    private static final String OPTION_NAME = "SAMPLE_OPTION_NAME";
+    private static final String UNIQUE_OPTION_NAME = "UNIQUE_OPTION_NAME";
+    private static final String APP_ID_VID = "VID";
+    private static final String APP_ID_SDC = "SDC";
+    private static final String QUERY_STRING_FOR_CATEGORY_NAME = String.format(" where name = '%s' ", CATEGORY_NAME);
+
+
+    @Mock
+    private DataAccessService dataAccessService;
+
+    @InjectMocks
+    private CategoryParameterServiceImpl testSubject;
+
+    @BeforeSuite
+    public void before() {
+        initMocks(this);
+    }
+
+    @BeforeMethod
+    public void resetMocks() {
+        reset(dataAccessService);
     }
 
     @Test
-    public void testCreateCategoryParameterOptions() throws Exception {
-        CategoryParameterServiceImpl testSubject;
-        String categoryName = "";
-        AddCategoryOptionsRequest optionsRequest = null;
-        AddCategoryOptionResponse result;
+    public void createCategoryParameterOptions_happyPath()  {
+        AddCategoryOptionsRequest optionsRequest = new AddCategoryOptionsRequest();
+        optionsRequest.options.add(UNIQUE_OPTION_NAME);
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
-        // default test
-        try {
-            testSubject = createTestSubject();
-            result = testSubject.createCategoryParameterOptions(categoryName, optionsRequest);
-        } catch (
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
 
-        Exception e) {
-        }
+        AddCategoryOptionResponse result = testSubject.createCategoryParameterOptions(CATEGORY_NAME, optionsRequest);
+
+        Assert.assertTrue(result.getErrors().isEmpty());;
+        verify(dataAccessService, times(1))
+            .saveDomainObject(anyObject(), anyObject());
     }
 
     @Test
-    public void testDeleteCategoryOption() throws Exception {
-        CategoryParameterServiceImpl testSubject;
-        String categoryName = "";
+    public void createCategoryParameterOptions_existingOptionsForCategory()  {
+        AddCategoryOptionsRequest optionsRequest = new AddCategoryOptionsRequest();
+        optionsRequest.options.add(OPTION_NAME);
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.getOptions().add(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        String expectedError = String.format(CategoryParameterServiceImpl.OPTION_ALREADY_EXIST_FOR_CATEGORY
+            , OPTION_NAME, CATEGORY_NAME);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.createCategoryParameterOptions(CATEGORY_NAME, optionsRequest);
+
+        Assert.assertFalse(result.getErrors().isEmpty());
+        Assert.assertEquals(result.getErrors().size(), 1);
+        Assert.assertTrue(result.getErrors().stream().allMatch(expectedError::equals));
+    }
+
+    private List<CategoryParameter> createCategoryParametersList(CategoryParameter categoryParameter) {
+        List<CategoryParameter> aList = new ArrayList<>();
+        aList.add(categoryParameter);
+        return aList;
+    }
+
+    @Test
+    public void createCategoryParameterOptions_nonExistingOptionsForCategory()  {
+        AddCategoryOptionsRequest optionsRequest = new AddCategoryOptionsRequest();
+
+        List<CategoryParameter> aList = createCategoryParametersList(new CategoryParameter());
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.createCategoryParameterOptions(CATEGORY_NAME, optionsRequest);
+
+        Assert.assertTrue(result.getErrors().isEmpty());
+    }
+
+    @Test(expectedExceptions = { UnfoundedCategoryException.class })
+    public void createCategoryParameterOptions_wrongNumberOfCategoryParameters()  {
+        AddCategoryOptionsRequest optionsRequest = new AddCategoryOptionsRequest();
+        List<CategoryParameter> aList = Collections.emptyList();
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.createCategoryParameterOptions(CATEGORY_NAME, optionsRequest);
+
+        Assert.fail();
+    }
+
+    @Test(expectedExceptions = { UnfoundedCategoryException.class })
+    public void deleteCategoryOption_wrongNumberOfParameters() {
         CategoryParameterOption option = null;
+        List<CategoryParameter> aList = Collections.emptyList();
 
-        // default test
-        try {
-            testSubject = createTestSubject();
-            testSubject.deleteCategoryOption(categoryName, option);
-        } catch (
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
 
-        Exception e) {
-        }
+        testSubject.deleteCategoryOption(CATEGORY_NAME, option);
+
+        Assert.fail();
     }
 
     @Test
-    public void testGetCategoryParameters() throws Exception {
-        CategoryParameterServiceImpl testSubject;
-        CategoryParametersResponse result;
+    public void deleteCategoryOption_happyPath() {
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        CategoryParameterOption categoryParameterOption =
+            new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter);
+        categoryParameter.getOptions().add(categoryParameterOption);
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
-        // default test
-        try {
-            testSubject = createTestSubject();
-            testSubject.getCategoryParameters(null);
-        } catch (
+        doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject());
 
-        Exception e) {
-        }
+        testSubject.deleteCategoryOption(CATEGORY_NAME, categoryParameterOption);
+
+        verify(dataAccessService, times(1))
+            .deleteDomainObject(anyObject(), anyObject());
     }
 
     @Test
-    public void testUpdateCategoryParameterOption() throws Exception {
-        CategoryParameterServiceImpl testSubject;
-        String categoryName = "";
-        CategoryParameterOptionRep option = null;
-        AddCategoryOptionResponse result;
+    public void getCategoryParametersTest() {
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        CategoryParameterOption categoryParameterOption =
+            new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter);
+        categoryParameter.getOptions().add(categoryParameterOption);
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
-        // default test
-        try {
-            testSubject = createTestSubject();
-            result = testSubject.updateCategoryParameterOption(categoryName, option);
-        } catch (
+        doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject());
 
-        Exception e) {
-        }
+        CategoryParametersResponse response = testSubject.getCategoryParameters(Family.PARAMETER_STANDARDIZATION);
+
+        Assert.assertFalse(response.getCategoryParameters().isEmpty());
+        Assert.assertTrue(response.getCategoryParameters().containsKey(CATEGORY_NAME));
+
+        verify(dataAccessService, times(1))
+            .getList(anyObject(), anyString(), anyString(), anyObject());
+    }
+
+    @Test
+    public void updateCategoryParameterOption_domainObjectGetsSavedSuccessfully() {
+        CategoryParameterOptionRep optionRepExisting = new CategoryParameterOptionRep(APP_ID_VID, OPTION_NAME);
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.getOptions().add(
+            new CategoryParameterOption(APP_ID_VID, UNIQUE_OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRepExisting);
+
+        verify(dataAccessService, times(1))
+            .saveDomainObject(anyObject(), anyObject());
+    }
+
+    @Test(expectedExceptions = { ForbiddenException.class })
+    public void updateCategoryParameterOption_shouldFailUpdateForbidden() {
+        CategoryParameterOptionRep optionRep = new CategoryParameterOptionRep("1", CATEGORY_NAME);
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, false);
+        categoryParameter.getOptions().add(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRep);
+
+        Assert.fail();
+    }
+
+    @Test(expectedExceptions = { UnfoundedCategoryOptionException.class })
+    public void updateCategoryParameterOption_CategoryNotFound() {
+        CategoryParameterOptionRep optionRep = new CategoryParameterOptionRep("SOME_UNRELATED_ID", CATEGORY_NAME);
+
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.getOptions().add(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRep);
+
+        Assert.fail();
+    }
+
+    @Test(expectedExceptions = { AlreadyExistOptionNameException.class })
+    public void updateCategoryParameterOption_OptionNameExists() {
+        CategoryParameterOptionRep optionRepExisting = new CategoryParameterOptionRep(APP_ID_VID, OPTION_NAME);
+
+        CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.getOptions().add(
+            new CategoryParameterOption(APP_ID_VID, UNIQUE_OPTION_NAME, categoryParameter));
+        categoryParameter.getOptions().add(
+            new CategoryParameterOption(APP_ID_SDC, OPTION_NAME, categoryParameter));
+        List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
+
+        doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
+
+        AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRepExisting);
+
+        Assert.fail();
+    }
+
+    private CategoryParameter createCategoryParameter(String categoryName, boolean idSupported) {
+        CategoryParameter categoryParameter = new CategoryParameter();
+        categoryParameter.setName(categoryName);
+        categoryParameter.setIdSupported(idSupported);
+        return categoryParameter;
     }
 }
\ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/PombaServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/PombaServiceImplTest.java
new file mode 100644
index 0000000..d0eec26
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/services/PombaServiceImplTest.java
@@ -0,0 +1,40 @@
+package org.onap.vid.services;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.vid.aai.PombaClientInterface;
+import org.onap.vid.model.PombaInstance.PombaRequest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class PombaServiceImplTest {
+
+  @Mock
+  private PombaClientInterface pombaClientInterface;
+
+  @InjectMocks
+  private PombaServiceImpl testSubject;
+
+  @BeforeClass
+  public void beforeClass() {
+    initMocks(this);
+  }
+
+  @BeforeMethod
+  public void resetMocks() {
+    Mockito.reset(pombaClientInterface);
+  }
+
+  @Test
+  public void testVerify() {
+    PombaRequest pombaRequest = new PombaRequest();
+    testSubject.verify(pombaRequest);
+    verify(pombaClientInterface, times(1))
+        .verify(pombaRequest);
+  }
+}
\ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java
index 544a799..d7db495 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java
@@ -1,25 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
 package org.onap.vid.services;
 
-import static org.junit.Assert.*;
-import java.util.*;
-import org.junit.Assert;
-import org.junit.Test;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.ArrayList;
+import org.apache.commons.lang.StringUtils;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.AaiResponse;
+import org.onap.vid.aai.ServiceSubscription;
+import org.onap.vid.aai.ServiceSubscriptions;
+import org.onap.vid.aai.Services;
+import org.onap.vid.model.Subscriber;
+import org.onap.vid.model.SubscriberList;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
 public class RoleGenaratorServiceImplTest {
 
-    private RoleGenaratorServiceImpl createTestSubject() {
-        return new RoleGenaratorServiceImpl();
+    private static final String GLOBAL_CUSTOMER_ID = "997";
+    private static final String SUBSCRIBER_NAME = "name";
+    private static final String SUBSCRIBER_TYPE = "subscriber_type";
+    private static final String RESOURCE_VERSION = "1";
+    private static final String SERVICE_TYPE = "service_type";
+
+    @Mock
+    private AaiClientInterface aaiClientInterface;
+
+    @InjectMocks
+    private RoleGenaratorServiceImpl testSubject;
+
+    @BeforeClass
+    public void beforeClass() {
+        initMocks(this);
+    }
+
+    @BeforeMethod
+    public void resetMocks() {
+        Mockito.reset(aaiClientInterface);
     }
 
     @Test
-    public void testGenerateRoleScript() throws Exception {
-        RoleGenaratorServiceImpl testSubject;
-        Boolean firstRun = null;
-        String result;
+    public void tenerateRoleScript_firstRun() {
+        boolean firstRun = true;
 
-        // default test
-        testSubject = createTestSubject();
-        result = testSubject.generateRoleScript(firstRun);
+        Subscriber subscriber = createSubscriber();
+        AaiResponse<SubscriberList> subscribers = createSubscriberListAaiResponse(subscriber);
+        doReturn(subscribers).when(aaiClientInterface).getAllSubscribers();
+
+        ServiceSubscription serviceSubscription = createServiceSubscription();
+        AaiResponse<Services> subscriberResponse = createServicesAaiResponse(serviceSubscription);
+        doReturn(subscriberResponse).when(aaiClientInterface).getSubscriberData(subscriber.globalCustomerId);
+
+        String result = testSubject.generateRoleScript(firstRun);
+        Assert.assertTrue(StringUtils.isNotBlank(result));
+    }
+
+    @Test
+    public void tenerateRoleScript_notAFirstRun() {
+        boolean firstRun = false;
+
+        Subscriber subscriber = createSubscriber();
+        AaiResponse<SubscriberList> subscribers = createSubscriberListAaiResponse(subscriber);
+        doReturn(subscribers).when(aaiClientInterface).getAllSubscribers();
+
+        ServiceSubscription serviceSubscription = createServiceSubscription();
+        AaiResponse<Services> subscriberResponse = createServicesAaiResponse(serviceSubscription);
+        doReturn(subscriberResponse).when(aaiClientInterface).getSubscriberData(subscriber.globalCustomerId);
+
+        String result = testSubject.generateRoleScript(firstRun);
+        Assert.assertTrue(StringUtils.isNotBlank(result));
+    }
+
+    @Test(expectedExceptions = { Exception.class })
+    public void tenerateRoleScript_errorGettingDataFromAAIClient() {
+        boolean firstRun = false;
+
+        doThrow(new Exception("This is expected.")).when(aaiClientInterface).getAllSubscribers();
+
+        String result = testSubject.generateRoleScript(firstRun);
+        Assert.fail();
+    }
+
+    private ServiceSubscription createServiceSubscription() {
+        ServiceSubscription serviceSubscription = new ServiceSubscription();
+        serviceSubscription.serviceType = SERVICE_TYPE;
+        return serviceSubscription;
+    }
+
+    private AaiResponse<SubscriberList> createSubscriberListAaiResponse(Subscriber subscriber) {
+        AaiResponse<SubscriberList> subscribers = new AaiResponse<>(new SubscriberList(new ArrayList<>()), "", 200);
+        subscribers.getT().customer.add(subscriber);
+        return subscribers;
+    }
+
+    private AaiResponse<Services> createServicesAaiResponse(ServiceSubscription serviceSubscription) {
+        AaiResponse<Services> subscriberResponse = new AaiResponse<>(new Services(), "", 200);
+        subscriberResponse.getT().serviceSubscriptions = new ServiceSubscriptions();
+        subscriberResponse.getT().serviceSubscriptions.serviceSubscription = new ArrayList<>();
+        subscriberResponse.getT().serviceSubscriptions.serviceSubscription.add(serviceSubscription);
+        return subscriberResponse;
+    }
+
+    private Subscriber createSubscriber() {
+        Subscriber subscriber = new Subscriber();
+        subscriber.globalCustomerId = GLOBAL_CUSTOMER_ID;
+        subscriber.subscriberName = SUBSCRIBER_NAME;
+        subscriber.subscriberType = SUBSCRIBER_TYPE;
+        subscriber.resourceVersion = RESOURCE_VERSION;
+        return subscriber;
     }
 
 
