templates button - rename from hasTemplates to isInstantiationTemplateExists on the... 50/100050/3
authorEinat Vinouze <einat.vinouze@intl.att.com>
Tue, 7 Jan 2020 09:57:32 +0000 (11:57 +0200)
committerEinat Vinouze <einat.vinouze@intl.att.com>
Tue, 7 Jan 2020 16:44:06 +0000 (18:44 +0200)
Issue-ID: VID-741
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Change-Id: I09e0579d96cf5265519eaa69646afef7b511593a
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java
vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java
vid-app-common/src/test/java/org/onap/vid/services/InstantiationTemplatesServiceTest.java
vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java
vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts
vid-webpack-master/cypress/integration/iFrames/service.popup.e2e.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts

index 092cfe4..f5dd5d8 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.onap.vid.asdc.beans;
 
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
 import java.util.Collection;
 import java.util.UUID;
 
@@ -77,6 +80,7 @@ public class Service {
 
     private String orchestrationType;
 
+    @JsonInclude(NON_NULL)
     private Boolean isInstantiationTemplateExists;
     
     
index c033fbd..17520ee 100644 (file)
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import javax.inject.Inject;
+import org.jetbrains.annotations.NotNull;
 import org.onap.vid.asdc.beans.Service;
 import org.onap.vid.dal.AsyncInstantiationRepository;
 import org.onap.vid.model.ModelUtil;
@@ -76,7 +77,8 @@ public class InstantiationTemplatesService {
 
     public Collection<Service> setOnEachServiceIsTemplateExists(Collection<Service> services){
         if (!featureManager.isActive(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE)){
-            return services;
+            return unsetTemplateExistsToAllServices(services);
+
         }
 
         Set<String> serviceModelIdsFromDB  = asyncInstantiationRepository.getAllTemplatesServiceModelIds();
@@ -84,8 +86,13 @@ public class InstantiationTemplatesService {
         return services.stream().map(it -> setTemplateExistForService(it, serviceModelIdsFromDB)).collect(toList());
     }
 
-    protected Service setTemplateExistForService(Service service, Set<String> serviceModelIdsFromDb) {
+    @NotNull
+    protected Collection<Service> unsetTemplateExistsToAllServices(Collection<Service> services) {
+        services.forEach(it -> it.setIsInstantiationTemplateExists(false));
+        return services;
+    }
 
+    protected Service setTemplateExistForService(Service service, Set<String> serviceModelIdsFromDb) {
         service.setIsInstantiationTemplateExists(serviceModelIdsFromDb.contains(service.getUuid()));
         return service;
     }
index 0c66f95..de9fc2b 100644 (file)
@@ -154,8 +154,8 @@ public class InstantiationTemplatesServiceTest {
         when(featureManager.isActive(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE)).thenReturn(false);
         Collection<Service> actualCollection = instantiationTemplatesService.setOnEachServiceIsTemplateExists(createGivenCollection());
         assertThat("was " + actualCollection, actualCollection, containsInAnyOrder(
-            allOf(hasProperty("uuid", is("1")), hasProperty("isInstantiationTemplateExists", nullValue())),
-            allOf(hasProperty("uuid", is("3")), hasProperty("isInstantiationTemplateExists", nullValue()))
+            allOf(hasProperty("uuid", is("1")), hasProperty("isInstantiationTemplateExists", is(false))),
+            allOf(hasProperty("uuid", is("3")), hasProperty("isInstantiationTemplateExists", is(false)))
         ));
     }
 
index 05d73a6..555c2ed 100644 (file)
@@ -101,6 +101,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
             "  }, {\n" +
@@ -115,6 +116,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_ERROR\",\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
             "  }, {\n" +
@@ -128,6 +130,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterUserId\": null,\n" +
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
@@ -143,6 +146,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
             "  }, {\n" +
@@ -157,6 +161,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
             "  }, {\n" +
@@ -170,6 +175,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterUserId\": null,\n" +
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
@@ -184,6 +190,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterUserId\": null,\n" +
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
@@ -198,6 +205,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterUserId\": null,\n" +
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
@@ -212,6 +220,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterUserId\": null,\n" +
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
@@ -226,6 +235,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterUserId\": null,\n" +
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
@@ -240,6 +250,7 @@ public class AaiApiTest extends BaseApiAaiTest {
             "    \"lastUpdaterUserId\": null,\n" +
             "    \"lastUpdaterFullName\": null,\n" +
             "    \"orchestrationType\": null,\n" +
+            "    \"isInstantiationTemplateExists\": false,\n" +
             "    \"distributionStatus\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
             "    \"artifacts\": null,\n" +
             "    \"resources\": null\n" +
index 0db1b09..168a936 100644 (file)
@@ -71,7 +71,7 @@ describe('Template', () => {
 
     cy.route(Cypress.config('baseUrl') + "/getuserID", 'us16807000');
 
-    cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true&hasTemplate=true');
+    cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true&isInstantiationTemplateExists=true');
 
   });
 
index 4b27ad0..de29313 100644 (file)
@@ -36,7 +36,7 @@ describe('Service popup', function () {
         res1.global.flags = {};
         res1.global.flags["FLAG_2004_INSTANTIATION_TEMPLATES_POPUP"] = true;
         cy.setReduxState(<any>res1);
-        cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true&hasTemplate=true');
+        cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true&isInstantiationTemplateExists=true');
         cy.getElementByDataTestsId('templateButton').should('be.visible')
       });
     });
index 9063e67..19ea9b9 100644 (file)
@@ -89,7 +89,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
       .subscribe(params => {
         this.serviceModelId = params['serviceModelId'];
         if (this.serviceModelId && params['isCreate'] == "true") {
-          this.onInitForCreateNewServicePopup(params['hasTemplate']);
+          this.onInitForCreateNewServicePopup(params['isInstantiationTemplateExists']);
         }
       });
 
@@ -107,7 +107,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
     }
   }
 
-  private onInitForCreateNewServicePopup(hasTemplate : boolean) {
+  private onInitForCreateNewServicePopup(isInstantiationTemplateExists : boolean) {
     this._genericFormPopupService.initReduxOnCreateNewService().then((serviceModelId: string) => {
       this.uuidData = <any>{
         bulkSize: 1,
@@ -117,7 +117,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
         popupService: this._servicePopupService,
       };
 
-      this.showTemplateBtn = this._genericFormPopupService.shouldShowTemplateBtn(hasTemplate);
+      this.showTemplateBtn = this._genericFormPopupService.shouldShowTemplateBtn(isInstantiationTemplateExists);
       this.isShowPreviousInstantiationBtn = !!this._store.getState().global.flags["FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER"];
 
       this.uuidData.popupService.closeDialogEvent.subscribe((that) => {
index 53f345a..9680c06 100644 (file)
@@ -1074,14 +1074,14 @@ describe('Generic Form popup Service', () => {
 
 
   const shouldShowTemplateBtnDataProvider = [
-    ['shouldShowTemplateBtn : should return true if flag is true and has template', true , true, true],
-    ['shouldShowTemplateBtn : should return false if flag is false and has template',false , true, false],
-    ['shouldShowTemplateBtn : should return false if flag is true and has no template',true , false, false],
-    ['shouldShowTemplateBtn : should return false if flag is false and has no template',false , false, false]];
-  each(shouldShowTemplateBtnDataProvider).test('%s', (desc : string, flag : boolean, hasTemplate : boolean, expected : boolean ) => {
+    ['shouldShowTemplateBtn : should return true if flag is true and has instantiation template', true , true, true],
+    ['shouldShowTemplateBtn : should return false if flag is false and has instantiation template',false , true, false],
+    ['shouldShowTemplateBtn : should return false if flag is true and has no instantiation template',true , false, false],
+    ['shouldShowTemplateBtn : should return false if flag is false and has no instantiation template',false , false, false]];
+  each(shouldShowTemplateBtnDataProvider).test('%s', (desc : string, flag : boolean, isInstantiationTemplateExists : boolean, expected : boolean ) => {
     spyOn(_featureFlagsService, 'getFlagState').and.returnValue(flag)
 
-    const result: boolean = service.shouldShowTemplateBtn(hasTemplate);
+    const result: boolean = service.shouldShowTemplateBtn(isInstantiationTemplateExists);
     expect(result).toEqual(expected);
   });
 });
index 2998ba9..e3cdaef 100644 (file)
@@ -95,10 +95,10 @@ export class GenericFormPopupService {
 
 
 
-  shouldShowTemplateBtn = (hasTemplate: boolean) : boolean => {
+  shouldShowTemplateBtn = (isInstantiationTemplateExists: boolean) : boolean => {
     const instantiationTemplateFlag =  this._featureFlagsService.getFlagState(Features.FLAG_2004_INSTANTIATION_TEMPLATES_POPUP);
     if(instantiationTemplateFlag){
-      return hasTemplate;
+      return isInstantiationTemplateExists;
     }
     return false;
   }
index 61f75e8..78614c0 100644 (file)
@@ -173,7 +173,7 @@ describe('instantiation templates modal service', () => {
 
     service.navigateToNewServiceModal(serviceModelId);
 
-    expect(_router.navigate).toBeCalledWith(["/servicePopup"], {"queryParams": {"isCreate": true, "serviceModelId": serviceModelId, hasTemplate : true}, "queryParamsHandling": "merge"});
+    expect(_router.navigate).toBeCalledWith(["/servicePopup"], {"queryParams": {"isCreate": true, "serviceModelId": serviceModelId, isInstantiationTemplateExists : true}, "queryParamsHandling": "merge"});
   })
 
 });
index c7c198f..5c092e9 100644 (file)
@@ -30,7 +30,7 @@ export class InstantiationTemplatesModalService {
 
 
   navigateToNewServiceModal(serviceModelId: string) {
-     this._router.navigate(['/servicePopup'], { queryParams: { serviceModelId: serviceModelId, isCreate:true, hasTemplate : true}, queryParamsHandling: 'merge' });
+     this._router.navigate(['/servicePopup'], { queryParams: { serviceModelId: serviceModelId, isCreate:true, isInstantiationTemplateExists : true}, queryParamsHandling: 'merge' });
   }
 
 }