aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-11-10 09:58:54 +0200
committerEylon Malin <eylon.malin@intl.att.com>2019-11-10 13:22:11 +0200
commitf02305ae720426a2fc06d76c9fb1bf0c88dbd1da (patch)
tree3adfaed51aad0e690eb09160c1b2cdbbcc14438c /vid-app-common/src/test/java/org
parent28389331a544dcf8d74584c215467b149b959ecf (diff)
VidNotion identify port mirroring service
Issue-ID: VID-701 Change-Id: I805acab9380c779d2609107c1c65ef25bb0dad47 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java32
1 files changed, 20 insertions, 12 deletions
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 edf7d0862..d6526d2f7 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
@@ -56,6 +56,7 @@ import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Property;
import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.vid.asdc.parser.ToscaParserImpl2.Constants;
import org.onap.vid.model.CR;
import org.onap.vid.model.Network;
import org.onap.vid.model.Node;
@@ -197,6 +198,15 @@ public class VidNotionsBuilderTest {
assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel), is(ModelCategory.INFRASTRUCTURE_VPN));
}
+ @Test()
+ 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));
+ }
+
@Test
public void uuidIsExactly1ffce89fEtc_UIHintIsPositive() {
initServiceModelAndscarHelperWithMocks();
@@ -216,6 +226,12 @@ public class VidNotionsBuilderTest {
assertThat(vidNotionsBuilder.buildVidNotions(csarHelper, serviceModel), hasProperty("instantiationUI", is(InstantiationUI.LEGACY)));
}
+ private void mockInstantiationType(ServiceModel serviceModel, String aLaCarte) {
+ Service mockService = mock(Service.class);
+ when(serviceModel.getService()).thenReturn(mockService);
+ when(mockService.getInstantiationType()).thenReturn(aLaCarte);
+ }
+
@DataProvider
public static Object[][] ServiceRoleTypesDataProvider() {
return new Object[][] {
@@ -256,9 +272,7 @@ public class VidNotionsBuilderTest {
when(featureManagerMock.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)).thenReturn(isFlag1902NewViewEdit);
ServiceModel serviceModel = mock(ServiceModel.class);
- Service service = mock(Service.class);
- when(serviceModel.getService()).thenReturn(service);
- when(service.getInstantiationType()).thenReturn(ToscaParserImpl2.Constants.A_LA_CARTE);
+ mockInstantiationType(serviceModel, Constants.A_LA_CARTE);
InstantiationUI result = vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel);
assertEquals(expectedViewEditUi, result);
@@ -302,9 +316,7 @@ public class VidNotionsBuilderTest {
@Test(dataProvider="toscaParserInstantiationTypeToVidNotion")
public void testSuggestInstantiationTypeWhenInstantiationUiLegacy(String toscaParserInstantiationType, InstantiationType expectedInstantiationType) {
ServiceModel serviceModel = mock(ServiceModel.class);
- Service service = mock(Service.class);
- when(serviceModel.getService()).thenReturn(service);
- when(service.getInstantiationType()).thenReturn(toscaParserInstantiationType);
+ mockInstantiationType(serviceModel, toscaParserInstantiationType);
assertEquals(expectedInstantiationType, vidNotionsBuilder.suggestInstantiationType(serviceModel, ModelCategory.OTHER));
}
@@ -326,9 +338,7 @@ public class VidNotionsBuilderTest {
boolean isFeatureOn,
InstantiationType expectedInstantiationType) {
ServiceModel serviceModel = mock(ServiceModel.class);
- Service service = mock(Service.class);
- when(serviceModel.getService()).thenReturn(service);
- when(service.getInstantiationType()).thenReturn(ToscaParserImpl2.Constants.A_LA_CARTE);
+ mockInstantiationType(serviceModel, Constants.A_LA_CARTE);
when(featureManagerMock.isActive(featureFlag)).thenReturn(isFeatureOn);
assertEquals(expectedInstantiationType, vidNotionsBuilder.suggestInstantiationType(serviceModel, instantiationUI));
}
@@ -378,9 +388,7 @@ public class VidNotionsBuilderTest {
@Test
public void whenInstantiationTypeInServiceModelIsNull_thenInstantiationTypeIsClientConfig() {
initServiceModelAndscarHelperWithMocks();
- Service service = mock(Service.class);
- when(serviceModel.getService()).thenReturn(service);
- when(service.getInstantiationType()).thenReturn(null);
+ mockInstantiationType(serviceModel, null);
assertEquals( InstantiationType.ClientConfig, vidNotionsBuilder.suggestInstantiationType(serviceModel, ModelCategory.OTHER));
}