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;
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));
}
//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;
}
}
+ 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);
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;
}
}
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;
}
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;
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));
}
when(csarHelper.getServiceVlList()).thenReturn(ImmutableList.of(nodeTemplate));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(expectedInstantiationUI));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel, ModelCategory.OTHER), is(expectedInstantiationUI));
}
@Test
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));
}
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
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)
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));
}
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));
}
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() {
"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)
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
"serviceRole", serviceRole
)));
- assertThat(vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel), is(expectedViewEditUI));
+ assertThat(vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel, ModelCategory.OTHER), is(expectedViewEditUI));
}
@DataProvider
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);
}
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) {
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));
}
}