Merge "Change ServiceInstance's top-level rollbackOnFailure serialization to String"
authorAmichai Hemli <amichai.hemli@intl.att.com>
Mon, 9 Dec 2019 13:17:24 +0000 (13:17 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 9 Dec 2019 13:17:24 +0000 (13:17 +0000)
14 files changed:
features.properties.md
vid-app-common/src/main/java/org/onap/vid/properties/Features.java
vid-automation/src/main/java/vid/automation/test/infra/Features.java
vid-automation/src/main/java/vid/automation/test/sections/InstantiationStatusPage.java
vid-automation/src/main/java/vid/automation/test/sections/deploy/DeployModernUIBase.java
vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java
vid-webpack-master/cypress/integration/iFrames/instantiationStatus.e2e.ts
vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json
vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json
vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.html
vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.ts
vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts

index a8fac83..8b80184 100644 (file)
   When flag is true the platform will appear as a multi select field, if false the platform will be dropdown list.
   
 * FLAG_2004_INSTANTIATION_STATUS_FILTER
-  when flag is true the user can filter rows in instantiation status by using text input 
+  When flag is true the user can filter rows in instantiation status by using text input
+  
+* FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE
+  When flag is true, the user see in instantiation status page, an option to recreate another instance.
+  This option is enabled only for instantiate jobs.
+  IF the user click on this option, the previous instantiation is opened in drawing board, 
+  and the user can create another one from this template.
index d1a0cf9..26bfec5 100644 (file)
@@ -80,6 +80,7 @@ public enum Features implements Feature {
     FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS,
     FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND,
     FLAG_2004_INSTANTIATION_STATUS_FILTER,
+    FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE,
     FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER,
     ;
 
index cdf30e2..289151b 100644 (file)
@@ -54,6 +54,7 @@ public enum Features implements Feature {
     FLAG_2002_VNF_PLATFORM_MULTI_SELECT,
     FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS,
     FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND,
+    FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER,
     ;
 
     public boolean isActive() {
index 1bb095f..e8b002c 100644 (file)
@@ -40,6 +40,13 @@ public abstract class InstantiationStatusPage extends VidBasePage {
         return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[table]//tbody/tr"))).size();
     }
 
+    public static void verifyUrlMatchInstantiationStatusWithFilterSearchParam(String serviceModelId) {
+
+        Map<String, String> paramsMap = extractQueryParamsFromCurrentURL("instantiationStatus?");
+        assertEquals(paramsMap.get("filterText"), serviceModelId);
+
+    }
+
     public static WebElement assertInstantiationStatusRow(String spanIdSelector, Map<String, String> fieldsIdsAndExpected) {
         try {
             WebElement newTrRow = getInstantiationStatusRow(spanIdSelector);
index 6b2c1ec..747f4eb 100644 (file)
@@ -51,4 +51,9 @@ public abstract class DeployModernUIBase extends DeployDialogBase {
     public void clickProjectSelect() {
         GeneralUIUtils.clickOnElementByTestId(Constants.OwningEntity.PROJECT_SELECT_TEST_ID);
     }
+
+    public void clickPreviousInstantiationButton() {
+        GeneralUIUtils.clickOnElementByTestIdWithoutWait("ShowPreviousInstancesButton");
+    }
+
 }
index 1bbf0e3..03006ad 100644 (file)
@@ -6,6 +6,7 @@ import static org.testng.Assert.assertFalse;
 import static vid.automation.test.infra.Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI;
 import static vid.automation.test.infra.Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI;
 import static vid.automation.test.infra.Features.FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND;
+import static vid.automation.test.infra.Features.FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER;
 import static vid.automation.test.infra.Features.FLAG_5G_IN_NEW_INSTANTIATION_UI;
 import static vid.automation.test.infra.Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION;
 import static vid.automation.test.infra.Features.FLAG_SHOW_ORCHESTRATION_TYPE;
@@ -45,6 +46,7 @@ import vid.automation.test.infra.SelectOption;
 import vid.automation.test.model.Service;
 import vid.automation.test.model.User;
 import vid.automation.test.sections.BrowseASDCPage;
+import vid.automation.test.sections.InstantiationStatusPage;
 import vid.automation.test.sections.SideMenu;
 import vid.automation.test.sections.ViewEditPage;
 import vid.automation.test.sections.deploy.DeployDialogBase;
@@ -314,14 +316,33 @@ public class BrowseASDCTest extends CreateInstanceDialogBaseTest {
 
     @Test
     private void testCategoryParamsDropdownsExistsInCreationDialog() throws Exception {
+        String serviceId = "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd";
+
+        DeployModernUIMacroDialog deployMacroDialog = getDeployModernUIMacroDialog(serviceId);
+        deployMacroDialog.assertDialog();
+        deployMacroDialog.clickProjectSelect();
+        deployMacroDialog.clickOwningEntitySelect();
+    }
+
+    private DeployModernUIMacroDialog getDeployModernUIMacroDialog(String serviceId) {
         BrowseASDCPage browseASDCPage = registerSimulatorAndGoToBrowseSDC();
-        Service service = servicesService.getService("2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd");
+        Service service = servicesService.getService(serviceId);
         browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
         DeployModernUIMacroDialog deployMacroDialog = new DeployModernUIMacroDialog();
         deployMacroDialog.waitForDialogToLoad();
-        deployMacroDialog.assertDialog();
-        deployMacroDialog.clickProjectSelect();
-        deployMacroDialog.clickOwningEntitySelect();
+        return deployMacroDialog;
+    }
+
+    @Test
+    @FeatureTogglingTest(FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER)
+    private void testClickPreviousInstantiationsInCreationDialog() throws Exception {
+
+        String serviceId = "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd";
+        DeployModernUIMacroDialog deployMacroDialog = getDeployModernUIMacroDialog(serviceId);
+        deployMacroDialog.clickPreviousInstantiationButton();
+
+        InstantiationStatusPage.verifyUrlMatchInstantiationStatusWithFilterSearchParam(serviceId);
+
     }
 
     private BrowseASDCPage registerSimulatorAndGoToBrowseSDC() {
index 9a0c1aa..c510391 100644 (file)
@@ -7,6 +7,7 @@ import {AsyncInstantiationModel} from '../../support/jsonBuilders/models/asyncIn
 describe('Instantiation status', function () {
   var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
   var asyncRes: Array<any>;
+  const contextMenuCreateAnotherOne = 'context-menu-recreate';
 
   beforeEach(() => {
       cy.clearSessionStorage();
@@ -60,17 +61,17 @@ describe('Instantiation status', function () {
 
   it('should filter rows by filter text', function () {
     cy.openIframe('app/ui/#/instantiationStatus');
-    cy.getElementByDataTestsId("instantiationStatusFilter").type("ComplexService");
-    cy.get('table#instantiation-status tbody tr').should('have.length', 3);
+    cy.getElementByDataTestsId("instantiation-status-filter").type("ComplexService");
+    cy.get('table#instantiation-status tbody tr').should('have.length', 2);
   });
 
   it('should filter rows by url filter text', function () {
     cy.openIframe('app/ui/#/instantiationStatus?filterText=ComplexService');
-    cy.getElementByDataTestsId("instantiationStatusFilter").should('have.value','ComplexService');
-    cy.get('table#instantiation-status tbody tr').should('have.length', 3);
+    cy.getElementByDataTestsId("instantiation-status-filter").should('have.value','ComplexService');
+    cy.get('table#instantiation-status tbody tr').should('have.length', 2);
   });
 
-  function getDropDownMenuByDataTestId(testId:String) {
+  function getDisabledDropDownItemByDataTestId(testId:String) {
     return cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='${testId}']`);
   }
 
@@ -79,37 +80,56 @@ describe('Instantiation status', function () {
     cy.get('#' + jobId).find('.menu-div').click();
   }
 
-  it('should enable correct menu items', function () {
+  it('should disabled correct menu items', function () {
 
     cy.openIframe('app/ui/#/instantiationStatus');
 
     // Instantiate action with Job status FAILED - isRetry = true
 
     clickOnTitleAndThenOnMenuWithJobId('5c2cd8e5-27d0-42e3-85a1-85db5eaba459');
-    getDropDownMenuByDataTestId('context-menu-retry').should('not.exist');
-    getDropDownMenuByDataTestId('context-menu-remove').should('exist');
-    getDropDownMenuByDataTestId('context-menu-open').should('exist');
-    getDropDownMenuByDataTestId('context-menu-hide').should('not.exist');
-    getDropDownMenuByDataTestId('context-menu-audit-info').should('not.exist');
+    getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.exist');
+    getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
+    getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
+    getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
+    getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
+    getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
 
     // Instantiate action with Job status FAILED - isRetry = false
     clickOnTitleAndThenOnMenuWithJobId('e1db03c3-6274-4ff7-84cf-7bd3a3946de7');
-    getDropDownMenuByDataTestId('context-menu-retry').should('not.be.visible');
-    getDropDownMenuByDataTestId('context-menu-open').should('exist');
+    getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.be.visible');
+    getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
+    getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
 
     //Delete action with Job status IN_PROGRESS
     clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c2');
-    getDropDownMenuByDataTestId('context-menu-remove').should('exist');
-    getDropDownMenuByDataTestId('context-menu-open').should('exist');
-    getDropDownMenuByDataTestId('context-menu-hide').should('exist');
-    getDropDownMenuByDataTestId('context-menu-audit-info').should('not.exist');
+    getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
+    getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
+    getDisabledDropDownItemByDataTestId('context-menu-hide').should('exist');
+    getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
+    getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
 
     //Update action with Job status COMPLETED
     clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c1');
-    getDropDownMenuByDataTestId('context-menu-remove').should('exist');
-    getDropDownMenuByDataTestId('context-menu-open').should('not.exist');
-    getDropDownMenuByDataTestId('context-menu-hide').should('not.exist');
-    getDropDownMenuByDataTestId('context-menu-audit-info').should('not.exist');
+    getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
+    getDisabledDropDownItemByDataTestId('context-menu-open').should('not.exist');
+    getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
+    getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
+    getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
+  });
+
+  it('clicking on create another one item, go to expected url', function () {
+    //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:8
+    const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
+    const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
+    const vidBaseUrl = `http://localhost:8080/vid/serviceModels.htm`;
+
+    cy.openIframe('app/ui/#/instantiationStatus');
+
+    clickOnTitleAndThenOnMenuWithJobId(jobId);
+    cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).click();
+    cy.location().should((loc) => {
+      expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);
+    });
   });
 
 });
index c6fc4eb..2a8c7e8 100644 (file)
     "isRetryEnabled": false
   },
   {
-    "id": 3,
-    "created": 1524991828000,
-    "modified": 1524991830000,
-    "action": "INSTANTIATE",
+    "id": 9,
+    "created": 1524663233000,
+    "modified": 1524663236000,
+    "action": "DELETE",
     "createdId": null,
     "modifiedId": null,
     "rowNum": null,
     "auditUserId": null,
     "auditTrail": null,
-    "jobId": "725ef127-4ee5-4665-bdf1-55ee342b362f",
-    "templateId": "6bd53c0d-8742-43f6-9ed2-efbb87062779",
+    "jobId": "850dc7d2-5240-437f-9bcd-b1ed7dc339c2",
+    "templateId": "262fccc5-cae9-4258-b522-540c4010e0a9",
     "userId": "16807000",
     "aLaCarte": true,
-    "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d96",
-    "jobStatus": "FAILED",
-    "statusModifiedDate": 1524991828000,
+    "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d45",
+    "jobStatus": "IN_PROGRESS",
+    "statusModifiedDate": 1524663233000,
     "hidden": false,
     "pause": false,
-    "owningEntityId": "aaa1",
-    "owningEntityName": "aaa1",
+    "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+    "owningEntityName": "WayneHolland",
     "project": "WATKINS",
     "aicZoneId": "NFT1",
     "aicZoneName": "NFTJSSSS-NFT1",
-    "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
-    "tenantName": "USP-SIP-IC-24335-T-01",
-    "regionId": "AAIAIC25",
+    "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
+    "tenantName": "AIN Web Tool-15-D-testalexandria",
+    "regionId": "hvf6",
     "regionName": null,
     "serviceType": "TYLER SILVIA",
     "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
     "serviceInstanceId": null,
-    "serviceInstanceName": null,
+    "serviceInstanceName": "sPenLiZXXpqzsVck instance name_01",
     "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
-    "serviceModelName": "ComplexService",
+    "serviceModelName": "action-data",
     "serviceModelVersion": "1.0",
-    "createdBulkDate": 1524991828000,
+    "createdBulkDate": 1524663233000,
     "isRetryEnabled": false
   },
   {
-  "id": 9,
-  "created": 1524663233000,
-  "modified": 1524663236000,
-  "action": "DELETE",
-  "createdId": null,
-  "modifiedId": null,
-  "rowNum": null,
-  "auditUserId": null,
-  "auditTrail": null,
-  "jobId": "850dc7d2-5240-437f-9bcd-b1ed7dc339c2",
-  "templateId": "262fccc5-cae9-4258-b522-540c4010e0a9",
-  "userId": "16807000",
-  "aLaCarte": true,
-  "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d45",
-  "jobStatus": "IN_PROGRESS",
-  "statusModifiedDate": 1524663233000,
-  "hidden": false,
-  "pause": false,
-  "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
-  "owningEntityName": "WayneHolland",
-  "project": "WATKINS",
-  "aicZoneId": "NFT1",
-  "aicZoneName": "NFTJSSSS-NFT1",
-  "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
-  "tenantName": "AIN Web Tool-15-D-testalexandria",
-  "regionId": "hvf6",
-  "regionName": null,
-  "serviceType": "TYLER SILVIA",
-  "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
-  "serviceInstanceId": null,
-  "serviceInstanceName": "sPenLiZXXpqzsVck instance name_01",
-  "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
-  "serviceModelName": "action-data",
-  "serviceModelVersion": "1.0",
-  "createdBulkDate": 1524663233000,
-  "isRetryEnabled": false
-},
-  {
-  "id": 10,
-  "created": 1524663233000,
-  "modified": 1524663236000,
-  "action": "UPDATE",
-  "createdId": null,
-  "modifiedId": null,
-  "rowNum": null,
-  "auditUserId": null,
-  "auditTrail": null,
-  "jobId": "850dc7d2-5240-437f-9bcd-b1ed7dc339c1",
-  "templateId": "262fccc5-cae9-4258-b522-540c4010e0a9",
-  "userId": "16807000",
-  "aLaCarte": true,
-  "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d45",
-  "jobStatus": "COMPLETED",
-  "statusModifiedDate": 1524663233000,
-  "hidden": false,
-  "pause": false,
-  "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
-  "owningEntityName": "WayneHolland",
-  "project": "WATKINS",
-  "aicZoneId": "NFT1",
-  "aicZoneName": "NFTJSSSS-NFT1",
-  "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
-  "tenantName": "AIN Web Tool-15-D-testalexandria",
-  "regionId": "hvf6",
-  "regionName": null,
-  "serviceType": "TYLER SILVIA",
-  "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
-  "serviceInstanceId": null,
-  "serviceInstanceName": "sPenLiZXXpqzsVck instance name_01",
-  "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
-  "serviceModelName": "action-data",
-  "serviceModelVersion": "1.0",
-  "createdBulkDate": 1524663233000
-}
+    "id": 10,
+    "created": 1524663233000,
+    "modified": 1524663236000,
+    "action": "UPDATE",
+    "createdId": null,
+    "modifiedId": null,
+    "rowNum": null,
+    "auditUserId": null,
+    "auditTrail": null,
+    "jobId": "850dc7d2-5240-437f-9bcd-b1ed7dc339c1",
+    "templateId": "262fccc5-cae9-4258-b522-540c4010e0a9",
+    "userId": "16807000",
+    "aLaCarte": true,
+    "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d45",
+    "jobStatus": "COMPLETED",
+    "statusModifiedDate": 1524663233000,
+    "hidden": false,
+    "pause": false,
+    "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+    "owningEntityName": "WayneHolland",
+    "project": "WATKINS",
+    "aicZoneId": "NFT1",
+    "aicZoneName": "NFTJSSSS-NFT1",
+    "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
+    "tenantName": "AIN Web Tool-15-D-testalexandria",
+    "regionId": "hvf6",
+    "regionName": null,
+    "serviceType": "TYLER SILVIA",
+    "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
+    "serviceInstanceId": null,
+    "serviceInstanceName": "sPenLiZXXpqzsVck instance name_01",
+    "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+    "serviceModelName": "action-data",
+    "serviceModelVersion": "1.0",
+    "createdBulkDate": 1524663233000
+  }
 ]
index c7412ed..5e92e4f 100644 (file)
@@ -21,5 +21,6 @@
   "FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS": true,
   "FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER": true,
   "FLAG_2004_INSTANTIATION_STATUS_FILTER": true,
-  "FLAG_2004_INSTANTIATION_TEMPLATES_POPUP" : false
+  "FLAG_2004_INSTANTIATION_TEMPLATES_POPUP" : false,
+  "FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE": true
 }
index 9ef98e5..16b8c01 100644 (file)
@@ -18,7 +18,7 @@
         </div>
         <div class="instantiationStatusFilter" *ngIf=isInstantiationStatusFilterFlagOn()>
           <input
-            [attr.data-tests-id]="'instantiationStatusFilter'"
+            [attr.data-tests-id]="'instantiation-status-filter'"
             class="form-control input-text"
             [placeholder]="'filter'"
             [(ngModel)]="filterText">
@@ -74,7 +74,7 @@
             </svg-icon>
 
           </custom-popover>
-          <div class="menu-div" (click)="onContextMenu($event, data)">
+          <div class="menu-div" (click)="onContextMenu($event, data)" [attr.data-tests-id]="'menu-'+data.jobId">
             <span class="icon-menu"></span>
             <context-menu>
               <ng-template *ngFor="let action of contextMenuActions" contextMenuItem let-item
index 29adfa9..eedd46d 100644 (file)
@@ -5,36 +5,25 @@ import {AaiService} from "../shared/services/aaiService/aai.service";
 import {MsoService} from "../shared/services/msoService/mso.service";
 import {NgRedux} from "@angular-redux/store";
 import {HttpClientTestingModule} from "@angular/common/http/testing";
-import {FeatureFlagsService} from "../shared/services/featureFlag/feature-flags.service";
+import {FeatureFlagsService, Features} from "../shared/services/featureFlag/feature-flags.service";
 import {DrawingBoardModes} from "../drawingBoard/service-planning/drawing-board.modes";
 import {RouterTestingModule} from "@angular/router/testing";
 import {of} from "rxjs";
 import {UrlTree} from "@angular/router";
 import each from "jest-each";
 import {ServiceAction} from "../shared/models/serviceInstanceActions";
+import {instance, mock, when} from "ts-mockito";
 
 class MockAppStore<T> {
-
-  getState() {
-    return {
-      global: {
-        flags: {
-          'FLAG_1902_NEW_VIEW_EDIT': true,
-
-        }
-      }
-    }
-  }
-
-  dispatch() {
-
-  }
+  dispatch() {}
 }
+
 describe('Instantiation Status Service', () => {
   let injector;
   let aaiService: AaiService;
   let msoService: MsoService;
   let service: InstantiationStatusComponentService;
+  let mockFeatureFlagsService: FeatureFlagsService = mock(FeatureFlagsService);
 
 
   beforeAll(done => (async () => {
@@ -48,7 +37,9 @@ describe('Instantiation Status Service', () => {
         AaiService,
         MsoService,
         FeatureFlagsService,
-        {provide: NgRedux, useClass: MockAppStore}]
+        {provide: NgRedux, useClass: MockAppStore},
+        {provide: FeatureFlagsService, useValue: instance(mockFeatureFlagsService)}
+      ]
     });
     await TestBed.compileComponents();
 
@@ -172,6 +163,15 @@ describe('Instantiation Status Service', () => {
     expect(service.isRecreateEnabled(serviceInfoModel)).toBe(expected);
   });
 
+  each([
+    [true, true],
+    [false, false],
+  ]).
+  test('isRecreateVisible: should be %s if flag is %s', (expected:boolean, flag:boolean) => {
+    when(mockFeatureFlagsService.getFlagState(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE)).thenReturn(flag);
+    expect(service.isRecreateVisible()).toEqual(expected);
+  });
+
   test('getStatusTooltip should return correct icon per job status', () => {
     let result : ServiceStatus  = service.getStatus('pending');
     expect(result.iconClassName).toEqual(PENDING);
index 227fff1..4bfedd9 100644 (file)
@@ -29,7 +29,8 @@ export class InstantiationStatusComponentService {
   constructor( private _aaiService: AaiService,
                private _msoService: MsoService,
                private _router : Router,
-               private _store: NgRedux<AppState>) {
+               private _store: NgRedux<AppState>,
+               private _featureFlagsService:FeatureFlagsService) {
   }
 
   generateServiceInfoDataMapping(arr: ServiceInfoModel[]) : { [serviceInstanceId: string]: ServiceInfoModel[]}{
@@ -70,7 +71,7 @@ export class InstantiationStatusComponentService {
   }
 
   open(item: ServiceInfoModel): void {
-    if (FeatureFlagsService.getFlagState(Features.FLAG_1902_VNF_GROUPING, this._store)) {
+    if (this._featureFlagsService.getFlagState(Features.FLAG_1902_VNF_GROUPING)) {
       this._aaiService.getServiceModelById(item['serviceModelId']).subscribe((result)=>{
         const serviceModel =  new ServiceModel(result);
 
@@ -92,7 +93,7 @@ export class InstantiationStatusComponentService {
   }
 
   navigateToNewViewOnlyOrOldEditView(item: ServiceInfoModel) {
-    if (FeatureFlagsService.getFlagState(Features.FLAG_1902_NEW_VIEW_EDIT, this._store)) {
+    if (this._featureFlagsService.getFlagState(Features.FLAG_1902_NEW_VIEW_EDIT)) {
       this.navigateToNewViewEdit(item, DrawingBoardModes.VIEW);
     }
     else {
@@ -184,6 +185,9 @@ export class InstantiationStatusComponentService {
     return item.action === ServiceAction.INSTANTIATE;
   }
 
+  isRecreateVisible(): boolean {
+    return this._featureFlagsService.getFlagState(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE);
+  }
 }
 
 
index ba26716..58227c9 100644 (file)
@@ -58,6 +58,14 @@ export class InstantiationStatusComponent implements OnInit {
       enabled: (item: ServiceInfoModel) =>  this.isOpenEnabled(item),
       visible: () =>  true,
     },
+    {
+      name: "Recreate",
+      dataTestId: "context-menu-recreate",
+      className: "fa-clone",
+      click: (item: ServiceInfoModel) => this.instantiationStatusComponentService.recreate(item),
+      enabled: (item: ServiceInfoModel) =>  this.instantiationStatusComponentService.isRecreateEnabled(item),
+      visible: () =>  this.instantiationStatusComponentService.isRecreateVisible(),
+    },
     {
       name: "Audit info",
       dataTestId: "context-menu-audit-info",
index 8570b08..7e0575b 100644 (file)
@@ -14,6 +14,7 @@ export enum Features {
   FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT ='FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT',
   FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS ='FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS',
   FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER',
+  FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE = 'FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE',
   FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER ='FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER',
 }