diff options
author | Ittay Stern <ittay.stern@att.com> | 2018-12-12 11:22:20 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-12-12 11:22:20 +0000 |
commit | 13022570337843e0112dcce93e2d7609992e20e9 (patch) | |
tree | 63d9191cd233f31b918977bb271ca3919b95dcbf /vid-app-common/src/test | |
parent | b146b8b737bf3ccaf981cf2b83e8eade53c01fcb (diff) | |
parent | 8d54fdee9b14e5e84b7840c0a7bb98334f22777b (diff) |
Merge "Make CategoryParameter.getOptions() unmodifiable"
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java | 28 |
1 files changed, 17 insertions, 11 deletions
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 7a4263c7e..3492a7547 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 @@ -95,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 @@ -155,9 +156,10 @@ 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(any(), anyString(), any(), any()); @@ -171,9 +173,10 @@ public class CategoryParameterServiceImplTest { @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(any(), anyString(), any(), any()); @@ -191,8 +194,9 @@ public class CategoryParameterServiceImplTest { 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); @@ -207,7 +211,8 @@ public class CategoryParameterServiceImplTest { 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); @@ -222,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); @@ -238,9 +244,9 @@ public class CategoryParameterServiceImplTest { CategoryParameter categoryParameter = createCategoryParameter(CATEGORY_NAME, true); CategoryParameter anotherCategoryParameter = createCategoryParameter(CATEGORY_NAME, true); - categoryParameter.getOptions().add( + categoryParameter.addOption( new CategoryParameterOption(APP_ID_VID, UNIQUE_OPTION_NAME, anotherCategoryParameter)); - categoryParameter.getOptions().add( + categoryParameter.addOption( new CategoryParameterOption(APP_ID_SDC, OPTION_NAME, anotherCategoryParameter)); List<CategoryParameter> aList = createCategoryParametersList(categoryParameter); |