VidNotion identify vlan tagging service 23/98223/3
authorEylon Malin <eylon.malin@intl.att.com>
Sun, 10 Nov 2019 10:24:11 +0000 (12:24 +0200)
committerEylon Malin <eylon.malin@intl.att.com>
Sun, 10 Nov 2019 11:28:36 +0000 (13:28 +0200)
Issue-ID: VID-701
Change-Id: Iffba5bca82e0511715e5ecb6b91cc9f4e077eaee
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt
vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java

index 0426758..5ed5f6a 100644 (file)
@@ -157,6 +157,9 @@ public class VidNotionsBuilder {
         if (isPortMirroringService(serviceModel)) {
             return ModelCategory.PORT_MIRRORING;
         }
+        if (isVlanTaggingService(serviceModel)) {
+            return ModelCategory.VLAN_TAGGING;
+        }
         if (isInfraStructureVpn(csarHelper)) {
             return VidNotions.ModelCategory.INFRASTRUCTURE_VPN;
         }
@@ -241,4 +244,15 @@ public class VidNotionsBuilder {
         return (serviceModel.getService()!=null &&
             StringUtils.equals(serviceModel.getService().getServiceType(), "portMirroring"));
     }
+
+    private boolean isVlanTaggingService(ServiceModel serviceModel) {
+        if (serviceModel==null || serviceModel.getVnfs()==null) {
+            return false;
+        }
+
+        return serviceModel.getVnfs().values().stream().anyMatch(
+            vnf-> MapUtils.isNotEmpty(vnf.getVfcInstanceGroups())
+        );
+
+    }
 }
index 66fe2dd..205a79b 100644 (file)
@@ -59,7 +59,8 @@ class VidNotions(@get:JsonInclude(JsonInclude.Include.NON_NULL)
         Transport,
         SERVICE_WITH_COLLECTION_RESOURCE,
         INFRASTRUCTURE_VPN,
-        PORT_MIRRORING,        
+        PORT_MIRRORING,
+        VLAN_TAGGING,
         @JsonProperty("other")
         OTHER
     }
index d6526d2..ec4bc22 100644 (file)
@@ -207,6 +207,16 @@ public class VidNotionsBuilderTest {
         assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel), is(ModelCategory.PORT_MIRRORING));
     }
 
+    @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));
+    }
+
+
     @Test
     public void uuidIsExactly1ffce89fEtc_UIHintIsPositive() {
         initServiceModelAndscarHelperWithMocks();