Dont filter get_vnf_data_by_globalid_and_service_type_response results
[vid.git] / vid-app-common / src / test / java / org / onap / vid / services / CategoryParameterServiceImplTest.java
index 04ee464..790427a 100644 (file)
@@ -2,15 +2,15 @@
  * ============LICENSE_START=======================================================
  * VID
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 - 2019 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.
  */
 package org.onap.vid.services;
 
-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;
@@ -50,6 +38,16 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.BeforeSuite;
 import org.testng.annotations.Test;
 
+import javax.ws.rs.ForbiddenException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.*;
+import static org.mockito.MockitoAnnotations.initMocks;
+
 public class CategoryParameterServiceImplTest {
 
     private static final String CATEGORY_NAME = "SAMPLE_CATEGORY_NAME";
@@ -89,7 +87,7 @@ public class CategoryParameterServiceImplTest {
 
         Assert.assertTrue(result.getErrors().isEmpty());;
         verify(dataAccessService, times(1))
-            .saveDomainObject(anyObject(), anyObject());
+            .saveDomainObject(any(), any());
     }
 
     @Test
@@ -97,7 +95,8 @@ public class CategoryParameterServiceImplTest {
         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));
+        CategoryParameter anotherCategoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.addOption(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, anotherCategoryParameter));
         List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
         String expectedError = String.format(CategoryParameterServiceImpl.OPTION_ALREADY_EXIST_FOR_CATEGORY
@@ -157,28 +156,30 @@ public class CategoryParameterServiceImplTest {
     @Test
     public void deleteCategoryOption_happyPath() {
         CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        CategoryParameter anotherCategoryParameter = createCategoryParameter(CATEGORY_NAME, true);
         CategoryParameterOption categoryParameterOption =
-            new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter);
-        categoryParameter.getOptions().add(categoryParameterOption);
+            new CategoryParameterOption(APP_ID_VID, OPTION_NAME, anotherCategoryParameter);
+        categoryParameter.addOption(categoryParameterOption);
         List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
-        doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject());
+        doReturn(aList).when(dataAccessService).getList(any(), anyString(), any(), any());
 
         testSubject.deleteCategoryOption(CATEGORY_NAME, categoryParameterOption);
 
         verify(dataAccessService, times(1))
-            .deleteDomainObject(anyObject(), anyObject());
+            .deleteDomainObject(any(), any());
     }
 
     @Test
     public void getCategoryParametersTest() {
         CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        CategoryParameter anotherCategoryParameter = createCategoryParameter(CATEGORY_NAME, true);
         CategoryParameterOption categoryParameterOption =
-            new CategoryParameterOption(APP_ID_VID, OPTION_NAME, categoryParameter);
-        categoryParameter.getOptions().add(categoryParameterOption);
+            new CategoryParameterOption(APP_ID_VID, OPTION_NAME, anotherCategoryParameter);
+        categoryParameter.addOption(categoryParameterOption);
         List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
-        doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject());
+        doReturn(aList).when(dataAccessService).getList(any(), anyString(), any(), any());
 
         CategoryParametersResponse response = testSubject.getCategoryParameters(Family.PARAMETER_STANDARDIZATION);
 
@@ -186,15 +187,16 @@ public class CategoryParameterServiceImplTest {
         Assert.assertTrue(response.getCategoryParameters().containsKey(CATEGORY_NAME));
 
         verify(dataAccessService, times(1))
-            .getList(anyObject(), anyString(), anyString(), anyObject());
+            .getList(any(), anyString(), any(), any());
     }
 
     @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));
+        CategoryParameter anotherCategoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.addOption(
+            new CategoryParameterOption(APP_ID_VID, UNIQUE_OPTION_NAME, anotherCategoryParameter));
         List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
         doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
@@ -202,14 +204,15 @@ public class CategoryParameterServiceImplTest {
         AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRepExisting);
 
         verify(dataAccessService, times(1))
-            .saveDomainObject(anyObject(), anyObject());
+            .saveDomainObject(any(), any());
     }
 
     @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));
+        CategoryParameter anotherCategoryParameter = createCategoryParameter(CATEGORY_NAME, false);
+        categoryParameter.addOption(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, anotherCategoryParameter));
         List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
         doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
@@ -224,7 +227,8 @@ public class CategoryParameterServiceImplTest {
         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));
+        CategoryParameter anotherCategoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.addOption(new CategoryParameterOption(APP_ID_VID, OPTION_NAME, anotherCategoryParameter));
         List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
         doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
@@ -239,10 +243,11 @@ public class CategoryParameterServiceImplTest {
         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));
+        CategoryParameter anotherCategoryParameter = createCategoryParameter(CATEGORY_NAME, true);
+        categoryParameter.addOption(
+            new CategoryParameterOption(APP_ID_VID, UNIQUE_OPTION_NAME, anotherCategoryParameter));
+        categoryParameter.addOption(
+            new CategoryParameterOption(APP_ID_SDC, OPTION_NAME, anotherCategoryParameter));
         List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
 
         doReturn(aList).when(dataAccessService).getList(CategoryParameter.class, QUERY_STRING_FOR_CATEGORY_NAME, null, null);
@@ -258,4 +263,4 @@ public class CategoryParameterServiceImplTest {
         categoryParameter.setIdSupported(idSupported);
         return categoryParameter;
     }
-}
\ No newline at end of file
+}