aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/test/java/org')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java24
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java28
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/IntersectionTest.java155
3 files changed, 121 insertions, 86 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
index 1282a6f78..e1c5e923b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
@@ -15,8 +15,8 @@ import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.local.LocalAsdcClient;
-import org.onap.vid.model.*;
import org.onap.vid.controllers.ToscaParserMockHelper;
+import org.onap.vid.model.*;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -196,6 +196,28 @@ public class ToscaParserImpl2Test {
JsonAssert.assertJsonEquals(expectedConfigurations, actualConfigurations);
}
+ @Test
+ public void modelWithAnnotatedInputWithTwoProperties_vfModuleGetsTheInput() throws Exception {
+ final ToscaParserMockHelper mockHelper = new ToscaParserMockHelper("90fe6842-aa76-4b68-8329-5c86ff564407", "empty.json");
+ final ServiceModel serviceModel = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid()));
+
+ assertJsonStringEqualsIgnoreNulls("{ vfModules: { 201712488_adiodvpe10..201712488AdiodVpe1..ADIOD_vRE_BV..module-1: { inputs: { 201712488_adiodvpe10_availability_zone_0: { } } } } }", om.writeValueAsString(serviceModel));
+ }
+
+ @Test
+ public void modelWithNfNamingWithToValues_ecompGeneratedNamingIsExtracted() throws Exception {
+ final ToscaParserMockHelper mockHelper = new ToscaParserMockHelper("90fe6842-aa76-4b68-8329-5c86ff564407", "empty.json");
+ final ServiceModel serviceModel = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid()));
+
+ assertJsonStringEqualsIgnoreNulls("" +
+ "{ vnfs: " +
+ " { \"201712-488_ADIOD-vPE-1 0\": " +
+ " { properties: { " +
+ " ecomp_generated_naming: \"true\", " +
+ " nf_naming: \"{naming_policy=SDNC_Policy.Config_MS_1806SRIOV_VPE_ADIoDJson, ecomp_generated_naming=true}\" " +
+ "} } } }", om.writeValueAsString(serviceModel));
+ }
+
private void setPprobeServiceProxy(Map<String, PortMirroringConfig> expectedConfigurations){
//Port Mirroring Configuration By Policy 0 doesn't contains pProbe.
// But due to sdc design if pProbe not exists parser expects to get it from other source.
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);
diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/IntersectionTest.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/IntersectionTest.java
index c766d26f3..dcccab008 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/IntersectionTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/IntersectionTest.java
@@ -1,101 +1,108 @@
+/*-
+ * ============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.testUtils;
-import org.junit.Assert;
import org.junit.Test;
import org.onap.vid.utils.Intersection;
-import java.util.ArrayList;
import java.util.List;
-/**
- * Created by moriya1 on 10/10/2017.
- */
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.util.Lists.emptyList;
+import static org.assertj.core.util.Lists.list;
+
public class IntersectionTest {
@Test
- public void testFourArrays(){
- List<String> l1 = new ArrayList<String>();
- l1.add("1");
- l1.add("2");
-
- List<String> l2 = new ArrayList<String>();
- l2.add("2");
- l2.add("3");
-
- List<String> l3 = new ArrayList<String>();
- l3.add("2");
- l3.add("4");
-
- List<String> l4 = new ArrayList<String>();
- l4.add("2");
- l4.add("5");
-
- List<List<String>> all = new ArrayList<>();
- all.add(l1);
- all.add(l2);
- all.add(l3);
- all.add(l4);
- Intersection<String> m = new Intersection<>();
- List<String> ans = m.intersectMultipileArray(all);
- Assert.assertEquals(1,ans.size());
- Assert.assertEquals(ans.get(0),"2");
+ public void testFourArrays() {
+ // given
+ List<List<String>> input = list(
+ list("1", "2"),
+ list("2", "3"),
+ list("2", "4"),
+ list("2", "5")
+ );
+ // when
+ List<String> output = Intersection.of(input);
+ // then
+ assertThat(output).containsExactlyInAnyOrder("2");
}
-
-
@Test
- public void testTwoArrays(){
- List<String> l1 = new ArrayList<String>();
- l1.add("1");
- l1.add("2");
-
- List<String> l2 = new ArrayList<String>();
- l2.add("2");
- l2.add("3");
-
- List<List<String>> all = new ArrayList<>();
- all.add(l1);
- all.add(l2);
- Intersection<String> m = new Intersection<>();
- List<String> l3 = m.intersectMultipileArray(all);
- Assert.assertEquals(l3.size(),1);
- Assert.assertEquals(l3.get(0),"2");
+ public void testTwoArrays() {
+ // given
+ List<List<String>> input = list(
+ list("1", "2"),
+ list("2", "3")
+ );
+ // when
+ List<String> output = Intersection.of(input);
+ // then
+ assertThat(output).containsExactlyInAnyOrder("2");
}
@Test
- public void testNoIntersection(){
- List<String> l1 = new ArrayList<String>();
- l1.add("1");
- l1.add("2");
-
- List<String> l2 = new ArrayList<String>();
- l2.add("3");
- l2.add("4");
+ public void testNoIntersection() {
+ // given
+ List<List<String>> input = list(
+ list("1", "2"),
+ list("3", "4")
+ );
+ // when
+ List<String> output = Intersection.of(input);
+ // then
+ assertThat(output).isEmpty();
- List<List<String>> all = new ArrayList<>();
- all.add(l1);
- all.add(l2);
- Intersection<String> m = new Intersection<>();
- List<String> l3 = m.intersectMultipileArray(all);
- Assert.assertEquals(l3.size(),0);
+ }
+ @Test
+ public void testOneArray() {
+ // given
+ List<List<String>> input = list(list("1", "2"));
+ // when
+ List<String> output = Intersection.of(input);
+ // then
+ assertThat(output).containsExactlyInAnyOrder("1", "2");
}
@Test
- public void testOneArrays(){
- List<String> l1 = new ArrayList<String>();
- l1.add("1");
- l1.add("2");
- List<List<String>> all = new ArrayList<>();
- all.add(l1);
- Intersection<String> m = new Intersection<>();
- List<String> l3 = m.intersectMultipileArray(all);
- Assert.assertEquals(l3.size(),2);
- Assert.assertEquals(l3.get(0),"1");
- Assert.assertEquals(l3.get(1),"2");
+ public void testEmptyInput() {
+ // when
+ List<String> output = Intersection.of(emptyList());
+ // then
+ assertThat(output).isEmpty();
+ }
+ @Test
+ public void shouldIgnoreRepetitions() {
+ // when
+ List<String> output = Intersection.of(list(
+ list("1", "1"),
+ list("1", "1")
+ ));
+ // then
+ assertThat(output).containsExactly("1");
}
}