aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-11-10 16:17:58 +0200
committerEylon Malin <eylon.malin@intl.att.com>2019-11-11 13:06:50 +0200
commit81edb057a2658964c20330ed34fdf591e689b2d8 (patch)
tree688fc6e4cc5365f324f97947c35ae6b6cb24d322
parent15fd2ac8d6aef0f5bdefef6f5b18d15c710ee970 (diff)
a-la-carte services new instantiation ui
Issue-ID: VID-701 Change-Id: I1a58fd2221f0936d32a8289fa666c6ffcfc7e2fa Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java22
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt5
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java72
-rw-r--r--vid-app-common/src/test/resources/csars/service-Vocg1804Svc.zipbin0 -> 153401 bytes
4 files changed, 72 insertions, 27 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
index 786f74f25..76e911b4e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
@@ -34,6 +34,7 @@ import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.vid.model.ServiceModel;
import org.onap.vid.model.VidNotions;
+import org.onap.vid.model.VidNotions.InstantiationUI;
import org.onap.vid.model.VidNotions.ModelCategory;
import org.onap.vid.properties.Features;
import org.togglz.core.manager.FeatureManager;
@@ -56,9 +57,9 @@ public class VidNotionsBuilder {
VidNotions buildVidNotions(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
VidNotions.ModelCategory modelCategory = suggestModelCategory(csarHelper, serviceModel);
return new VidNotions(
- suggestInstantiationUI(csarHelper, serviceModel),
+ suggestInstantiationUI(csarHelper, serviceModel, modelCategory),
modelCategory,
- suggestViewEditUI(csarHelper, serviceModel),
+ suggestViewEditUI(csarHelper, serviceModel, modelCategory),
suggestInstantiationType(serviceModel, modelCategory));
}
@@ -89,10 +90,17 @@ public class VidNotionsBuilder {
//UI route a-la-carte services to old UI only if InstantiationUI is LEGACY
//So any other value for InstantiationUI other than LEGACY make UI to route
//a-la-carte services to new UI
- VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
+ VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel, ModelCategory modelCategory) {
if(featureManager.isActive(Features.FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI) && isALaCarte(csarHelper)) {
return VidNotions.InstantiationUI.ANY_ALACARTE_NEW_UI;
}
+
+ if (featureManager.isActive(Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI) &&
+ !isMacro(serviceModel) &&
+ !isAlacarteExcludedByCategory(modelCategory)) {
+ return InstantiationUI.ANY_ALACARTE_WHICH_NOT_EXCLUDED;
+ }
+
if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) {
return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING;
}
@@ -116,6 +124,10 @@ public class VidNotionsBuilder {
}
+ private boolean isAlacarteExcludedByCategory(ModelCategory modelCategory) {
+ return modelCategory==ModelCategory.PORT_MIRRORING || modelCategory==ModelCategory.VLAN_TAGGING ;
+ }
+
private boolean isVnfServiceRole(ISdcCsarHelper csarHelper) {
final String serviceRole = csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.SERVICE_ROLE );
return StringUtils.equalsIgnoreCase("VNF" , serviceRole);
@@ -172,7 +184,7 @@ public class VidNotionsBuilder {
return VidNotions.ModelCategory.OTHER;
}
- VidNotions.InstantiationUI suggestViewEditUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
+ VidNotions.InstantiationUI suggestViewEditUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel, ModelCategory modelCategory) {
if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) {
return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING;
}
@@ -186,7 +198,7 @@ public class VidNotionsBuilder {
}
if (featureManager.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)) {
- VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper, serviceModel);
+ VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper, serviceModel, modelCategory);
if (instantiationUISuggestion!=VidNotions.InstantiationUI.LEGACY) {
return instantiationUISuggestion;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt b/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt
index 205a79b50..c6de51c1a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt
@@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonValue
import com.google.common.base.CaseFormat
-class VidNotions(@get:JsonInclude(JsonInclude.Include.NON_NULL)
+data class VidNotions(@get:JsonInclude(JsonInclude.Include.NON_NULL)
val instantiationUI: InstantiationUI,
val modelCategory: ModelCategory,
val viewEditUI: InstantiationUI,
@@ -41,7 +41,8 @@ class VidNotions(@get:JsonInclude(JsonInclude.Include.NON_NULL)
TRANSPORT_SERVICE,
SERVICE_WITH_COLLECTION_RESOURCE,
A_LA_CARTE_VNF_SERVICE_ROLE,
- INFRASTRUCTURE_VPN
+ INFRASTRUCTURE_VPN,
+ ANY_ALACARTE_WHICH_NOT_EXCLUDED,
;
@JsonValue
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java
index ec4bc2215..c136f36e4 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java
@@ -23,6 +23,7 @@ package org.onap.vid.asdc.parser;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
@@ -97,7 +98,7 @@ public class VidNotionsBuilderTest {
public void VLNetworkWithPropertyNetworkTechnologyOVS_UIHintIsPositive() {
ISdcCsarHelper csarHelper = mockForNonLegacyInstantiationUI();
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS));
assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel) , is(ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL));
}
@@ -142,7 +143,7 @@ public class VidNotionsBuilderTest {
when(csarHelper.getServiceVlList()).thenReturn(ImmutableList.of(nodeTemplate));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(expectedInstantiationUI));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(expectedInstantiationUI));
}
@Test
@@ -158,7 +159,7 @@ public class VidNotionsBuilderTest {
when(csarHelper.getServiceVlList()).thenReturn(ImmutableList.of(nodeTemplate));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(InstantiationUI.LEGACY));
assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel) , is(ModelCategory.OTHER));
}
@@ -168,7 +169,7 @@ public class VidNotionsBuilderTest {
assertThat(vidNotionsBuilder.isALaCarte(csarHelper), is(false));
assertThat(vidNotionsBuilder.hasAnyNetworkWithPropertyEqualsToAnyOf(csarHelper, "unexpected_property_name"), is(false));
assertThat(vidNotionsBuilder.hasAnyNetworkWithPropertyEqualsToAnyOf(csarHelper, "network_technology","Standard-SR-IOV"), is(true));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(InstantiationUI.LEGACY));
}
@Test
@@ -176,7 +177,7 @@ public class VidNotionsBuilderTest {
initServiceModelAndscarHelperWithRealCsar("/csars/service-fabric-configuration.zip");
assertThat(vidNotionsBuilder.isALaCarte(csarHelper), is(false));
assertThat(vidNotionsBuilder.hasFabricConfiguration(csarHelper), is(true));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(InstantiationUI.LEGACY));
}
@Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
@@ -186,7 +187,7 @@ public class VidNotionsBuilderTest {
when(featureManagerMock.isActive(Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI)).thenReturn(flagValue);
assertThat(vidNotionsBuilder.isALaCarte(csarHelper), is(false));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(flagValue ? InstantiationUI.TRANSPORT_SERVICE : InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(flagValue ? InstantiationUI.TRANSPORT_SERVICE : InstantiationUI.LEGACY));
assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel), is(ModelCategory.Transport));
}
@@ -194,7 +195,7 @@ public class VidNotionsBuilderTest {
public void withoutMocks_givenZippedToscaFileOfInfraStructureVpn_InstantiationUIIsRight(boolean flagValue) throws SdcToscaParserException, IOException {
initServiceModelAndscarHelperWithRealCsar("/csars/service-Infravpn-csar.zip");
when(featureManagerMock.isActive(Features.FLAG_1908_INFRASTRUCTURE_VPN)).thenReturn(flagValue);
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(flagValue ? InstantiationUI.INFRASTRUCTURE_VPN : InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(flagValue ? InstantiationUI.INFRASTRUCTURE_VPN : InstantiationUI.LEGACY));
assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel), is(ModelCategory.INFRASTRUCTURE_VPN));
}
@@ -202,20 +203,51 @@ public class VidNotionsBuilderTest {
public void withoutMocks_givenToscaOfPortMirroring_InstantiationUIIsLegacyAndCategoryIsPortMirroring() throws SdcToscaParserException, IOException {
initServiceModelAndscarHelperWithRealCsar("/csars/portMirroringService.zip");
when(featureManagerMock.isActive(Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI)).thenReturn(true);
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
- assertThat(vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
- assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel), is(ModelCategory.PORT_MIRRORING));
+ assertThat(vidNotionsBuilder.buildVidNotions(csarHelper, serviceModel),
+ equalTo(new VidNotions(InstantiationUI.LEGACY, ModelCategory.PORT_MIRRORING, InstantiationUI.LEGACY, InstantiationType.ClientConfig)));
+
}
@Test()
public void withoutMocks_givenToscaOfVLanTagging_InstantiationUIIsLegacyAndCategoryIsVlanTagging() throws SdcToscaParserException, IOException {
initServiceModelAndscarHelperWithRealCsar("/csars/service-VdorotheaSrv-csar.zip");
when(featureManagerMock.isActive(Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI)).thenReturn(true);
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
- assertThat(vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
- assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel), is(ModelCategory.VLAN_TAGGING));
+ assertThat(vidNotionsBuilder.buildVidNotions(csarHelper, serviceModel),
+ equalTo(new VidNotions(InstantiationUI.LEGACY, ModelCategory.VLAN_TAGGING, InstantiationUI.LEGACY, InstantiationType.ALaCarte)));
+ }
+
+ @Test
+ public void withoutMocks_givenToscaWithoutTypeAndFlagOn_InstantiationUIisAlacarte()
+ throws SdcToscaParserException, IOException {
+ initServiceModelAndscarHelperWithRealCsar("/csars/service-Vocg1804Svc.zip");
+ when(featureManagerMock.isActive(Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI)).thenReturn(true);
+ assertThat(vidNotionsBuilder.buildVidNotions(csarHelper, serviceModel),
+ equalTo(new VidNotions(
+ InstantiationUI.ANY_ALACARTE_WHICH_NOT_EXCLUDED,
+ ModelCategory.OTHER,
+ InstantiationUI.LEGACY,
+ InstantiationType.ClientConfig)));
+ }
+
+ @DataProvider
+ public static Object[][] anyAlaCarteDataProvider() {
+ return new Object[][] {
+ {true, Constants.A_LA_CARTE, InstantiationUI.ANY_ALACARTE_WHICH_NOT_EXCLUDED},
+ {false, Constants.A_LA_CARTE, InstantiationUI.LEGACY},
+ {true, Constants.MACRO, InstantiationUI.LEGACY},
+ {true, Constants.CLIENT_CONFIG, InstantiationUI.ANY_ALACARTE_WHICH_NOT_EXCLUDED},
+ {true, null, InstantiationUI.ANY_ALACARTE_WHICH_NOT_EXCLUDED},
+ {true, "", InstantiationUI.ANY_ALACARTE_WHICH_NOT_EXCLUDED}
+ };
}
+ @Test(dataProvider = "anyAlaCarteDataProvider")
+ public void testAnyAlaCarteNewUI_byInstantiationTypeAndFeatureFlag(boolean flag, String instantiationType, InstantiationUI expected) {
+ initServiceModelAndscarHelperWithMocks();
+ mockInstantiationType(serviceModel, instantiationType);
+ when(featureManagerMock.isActive(Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI)).thenReturn(flag);
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(expected));
+ }
@Test
public void uuidIsExactly1ffce89fEtc_UIHintIsPositive() {
@@ -225,7 +257,7 @@ public class VidNotionsBuilderTest {
"UUID", "95eb2c44-bff2-4e8b-ad5d-8266870b7717"
)));
when(featureManagerMock.isActive(Features.FLAG_5G_IN_NEW_INSTANTIATION_UI)).thenReturn(true);
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de));
}
@Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
@@ -236,10 +268,10 @@ public class VidNotionsBuilderTest {
assertThat(vidNotionsBuilder.buildVidNotions(csarHelper, serviceModel), hasProperty("instantiationUI", is(InstantiationUI.LEGACY)));
}
- private void mockInstantiationType(ServiceModel serviceModel, String aLaCarte) {
+ private void mockInstantiationType(ServiceModel serviceModel, String instantiationType) {
Service mockService = mock(Service.class);
when(serviceModel.getService()).thenReturn(mockService);
- when(mockService.getInstantiationType()).thenReturn(aLaCarte);
+ when(mockService.getInstantiationType()).thenReturn(instantiationType);
}
@DataProvider
@@ -258,7 +290,7 @@ public class VidNotionsBuilderTest {
"serviceRole", serviceRole
)));
- assertThat(vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel), is(expectedViewEditUI));
+ assertThat(vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel, ModelCategory.OTHER), is(expectedViewEditUI));
}
@DataProvider
@@ -284,7 +316,7 @@ public class VidNotionsBuilderTest {
ServiceModel serviceModel = mock(ServiceModel.class);
mockInstantiationType(serviceModel, Constants.A_LA_CARTE);
- InstantiationUI result = vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel);
+ InstantiationUI result = vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel, ModelCategory.OTHER);
assertEquals(expectedViewEditUi, result);
}
@@ -438,7 +470,7 @@ public class VidNotionsBuilderTest {
emptyMap() : ImmutableMap.of(ToscaParserImpl2.Constants.SERVICE_ROLE, serviceRole)
));
- assertEquals(expectedViewEditUi, vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel));
+ assertEquals(expectedViewEditUi, vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER));
}
private static NodeTemplate mockNodeTemplateChild(boolean withFabricConfiguration) {
@@ -500,6 +532,6 @@ public class VidNotionsBuilderTest {
when(csarHelper.getServiceMetadata()).thenReturn(new Metadata(isTransport ? ImmutableMap.of(ToscaParserImpl2.Constants.SERVICE_TYPE, "TRANSPORT") : emptyMap()
));
- assertEquals(expectedViewEditUi, vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel));
+ assertEquals(expectedViewEditUi, vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel, ModelCategory.OTHER));
}
}
diff --git a/vid-app-common/src/test/resources/csars/service-Vocg1804Svc.zip b/vid-app-common/src/test/resources/csars/service-Vocg1804Svc.zip
new file mode 100644
index 000000000..8902c5149
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-Vocg1804Svc.zip
Binary files differ