diff options
19 files changed, 326 insertions, 57 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java index 96e777a13..c73a01877 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java @@ -92,7 +92,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController { if (serviceModelId == null) { return asyncInstantiationBL.getAllServicesInfo(); } else { - return asyncInstantiationRepository.listServicesByServiceModelId(serviceModelId); + return asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(serviceModelId); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt index c26b88a5e..e26247281 100644 --- a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt +++ b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt @@ -90,9 +90,10 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService: " and created >= '" + filterDate + "' " } - private fun filterByServiceModelId(serviceModelUuid: UUID): String { + private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String { return filterServicesByNotHiddenAndNotDeleted() + - " and SERVICE_MODEL_ID = '$serviceModelUuid'" + " and SERVICE_MODEL_ID = '$serviceModelUuid'" + + " and ACTION = 'INSTANTIATE'" } private fun filterServicesByNotHiddenAndNotDeleted(): String { @@ -154,6 +155,6 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService: return dataAccessService.getList(className, " WHERE $condition", orderBy, null) as List<T> } - fun listServicesByServiceModelId(serviceModelId: UUID): List<ServiceInfo> = - dataAccessService.getList(ServiceInfo::class.java, filterByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>; + fun listInstantiatedServicesByServiceModelId(serviceModelId: UUID): List<ServiceInfo> = + dataAccessService.getList(ServiceInfo::class.java, filterInstantiatedServiceByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>; } diff --git a/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java b/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java index 012c37f4d..27be3fb50 100644 --- a/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java @@ -45,6 +45,7 @@ import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig; import org.onap.vid.job.Job; import org.onap.vid.model.ResourceInfo; import org.onap.vid.model.ServiceInfo; +import org.onap.vid.model.ServiceInfo.ServiceAction; import org.onap.vid.model.serviceInstantiation.ServiceInstantiation; import org.onap.vid.mso.rest.AsyncRequestStatus; import org.onap.vid.mso.rest.RequestStatus; @@ -73,14 +74,16 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest LocalDateTime NOW = LocalDateTime.now(); - addNewServiceInfo(UUID.randomUUID(), "abc", "1", NOW.minusYears(1L), NOW, COMPLETED, false, false, - MODEL_UUID); - addNewServiceInfo(UUID.randomUUID(), "abc", "2", NOW, NOW, COMPLETED, false, false, - MODEL_UUID_2); - addNewServiceInfo(UUID.randomUUID(), "abc", "3", NOW, NOW, COMPLETED, false, false, - MODEL_UUID); - addNewServiceInfo(UUID.randomUUID(), "abc", "hidden", NOW, NOW, COMPLETED, true, false, - MODEL_UUID); + addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "0", NOW.minusYears(1L), NOW, COMPLETED, false, false, + MODEL_UUID, ServiceAction.RESUME); + addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "1", NOW.minusYears(1L), NOW, COMPLETED, false, false, + MODEL_UUID, ServiceAction.INSTANTIATE); + addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "2", NOW, NOW, COMPLETED, false, false, + MODEL_UUID_2, ServiceAction.INSTANTIATE); + addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "3", NOW, NOW, COMPLETED, false, false, + MODEL_UUID, ServiceAction.INSTANTIATE); + addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "hidden", NOW, NOW, COMPLETED, true, false, + MODEL_UUID, ServiceAction.INSTANTIATE); } @DataProvider @@ -93,14 +96,15 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest @Test(dataProvider = "listServicesByServiceModelIdDataProvider") public void testListServicesByServiceModelId(String desc, String modelUUID, String... expectedResult) { - List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listServicesByServiceModelId(UUID.fromString(modelUUID)); + List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository. + listInstantiatedServicesByServiceModelId(UUID.fromString(modelUUID)); assertThat(desc, serviceInfoListResult.stream().map(ServiceInfo::getServiceInstanceName).collect(toList()), contains(expectedResult)); } @Test public void whenFilterServiceByNotExistUUID_emptyListIsReturned() { - List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listServicesByServiceModelId(UUID.randomUUID()); + List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(UUID.randomUUID()); assertThat(serviceInfoListResult, is(empty())); } diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java index d41ce87bf..7c0abbe6e 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java @@ -23,7 +23,6 @@ package org.onap.vid.services; import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsEqual.equalTo; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -49,6 +48,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import javax.inject.Inject; import org.hibernate.SessionFactory; +import org.jetbrains.annotations.NotNull; import org.onap.portalsdk.core.domain.FusionObject; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.vid.aai.AaiClientInterface; @@ -56,6 +56,7 @@ import org.onap.vid.aai.ExceptionWithRequestInfo; import org.onap.vid.job.Job.JobStatus; import org.onap.vid.model.Action; import org.onap.vid.model.ServiceInfo; +import org.onap.vid.model.ServiceInfo.ServiceAction; import org.onap.vid.model.VidNotions; import org.onap.vid.model.serviceInstantiation.InstanceGroup; import org.onap.vid.model.serviceInstantiation.Network; @@ -67,7 +68,6 @@ import org.onap.vid.mso.model.ModelInfo; import org.onap.vid.mso.rest.AsyncRequestStatus; import org.onap.vid.mso.rest.RequestStatus; import org.onap.vid.properties.Features; -import org.onap.vid.services.AsyncInstantiationBusinessLogicTest.ServiceInfoComparator; import org.onap.vid.utils.DaoUtils; import org.onap.vid.utils.TimeUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -149,9 +149,19 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests }); } + protected void addNewServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate, LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled, String modelUUID) { + ServiceInfo serviceInfo = createServiceInfo(uuid, userId, serviceName, createDate, statusModifiedDate, status, + isHidden, retryEnabled, modelUUID); + dataAccessService.saveDomainObject(serviceInfo, getPropsMap()); + setCreateDateToServiceInfo(uuid, createDate); + serviceCount++; + } + @NotNull + private ServiceInfo createServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate, + LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled, String modelUUID) { ServiceInfo serviceInfo = new ServiceInfo(); serviceInfo.setJobId(uuid); serviceInfo.setUserId(userId); @@ -164,10 +174,18 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests serviceInfo.setRetryEnabled(retryEnabled); serviceInfo.setServiceModelId(modelUUID); serviceInfo.setHidden(isHidden); + return serviceInfo; + } + + protected void addNewServiceInfoWithAction(UUID uuid, String userId, String serviceName, LocalDateTime createDate, + LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled, + String modelUUID, ServiceAction action) { + ServiceInfo serviceInfo = createServiceInfo(uuid, userId, serviceName, createDate, statusModifiedDate, status, + isHidden, retryEnabled, modelUUID); + serviceInfo.setAction(action); dataAccessService.saveDomainObject(serviceInfo, getPropsMap()); setCreateDateToServiceInfo(uuid, createDate); serviceCount++; - } diff --git a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java index cb59129c3..efd9e2b27 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java @@ -22,6 +22,7 @@ package org.onap.vid.services; import static com.google.common.collect.Maps.newHashMap; import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals; +import static net.javacrumbs.jsonunit.JsonMatchers.jsonNodeAbsent; import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals; import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER; import static org.hamcrest.MatcherAssert.assertThat; @@ -47,7 +48,9 @@ import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; import javax.inject.Inject; +import net.javacrumbs.jsonunit.ConfigurableJsonMatcher; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.BooleanUtils; import org.hibernate.SessionFactory; import org.mockito.Mock; import org.mockito.Mockito; @@ -611,19 +614,23 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest { assertThat(result, jsonEquals(expected).when(IGNORING_ARRAY_ORDER)); } - @Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class) - public void generateReplaceVfModuleRequest_whenRetainAssignmentsProvidedFromFrontend_retainAssignmentsToMsoIsTheSame(boolean retainAssignments) { - + @Test(dataProvider = "trueAndFalseAndNull", dataProviderClass = TestUtils.class) + public void generateReplaceVfModuleRequest_whenRetainAssignmentsProvidedFromFrontend_retainAssignmentsToMsoIsTheSame(Boolean retainAssignments) { assertThat(generatedVfModuleReplaceRequest(retainAssignments, null, null), - jsonPartEquals("requestDetails.requestParameters.retainAssignments", retainAssignments)); + jsonPartEqualsOrUndefined( + "requestDetails.requestParameters.retainAssignments", retainAssignments)); } - @Test - public void generateReplaceVfModuleRequest_whenRetainVolumeGroupIsTrue_rebuildVolumeGroupIsFalse() { - boolean retainVolumeGroups = true; - + @Test(dataProvider = "trueAndFalseAndNull", dataProviderClass = TestUtils.class) + public void generateReplaceVfModuleRequest_whenRetainVolumeGroupIsGiven_rebuildVolumeGroupIsNegated(Boolean retainVolumeGroups) { assertThat(generatedVfModuleReplaceRequest(null, retainVolumeGroups, null), - jsonPartEquals("requestDetails.requestParameters.rebuildVolumeGroups", false)); + jsonPartEqualsOrUndefined("requestDetails.requestParameters.rebuildVolumeGroups", BooleanUtils.negate(retainVolumeGroups))); + } + + private <T> ConfigurableJsonMatcher<T> jsonPartEqualsOrUndefined(String path, Boolean expected) { + return (expected != null) + ? jsonPartEquals(path, expected) + : jsonNodeAbsent(path); } @Test diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java index 857221a2a..862b8db8f 100644 --- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java +++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java @@ -389,4 +389,9 @@ public class TestUtils { return new Object[][]{{true}, {false}}; } + @DataProvider + public static Object[][] trueAndFalseAndNull() { + return new Boolean[][]{{Boolean.TRUE}, {Boolean.FALSE}, {null}}; + } + } diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json index b1c9d9b9a..d215a4331 100644 --- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json +++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json @@ -59,7 +59,7 @@ "platformName": null, "trackById": "b0732bed-3ddf-43cc-b193-7f18db84e476", "isBase": true, - "volumeGroupName": "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0_vol", + "volumeGroupName": null, "supplementaryFile": null, "supplementaryFile_hidden": null, "supplementaryFile_hidden_content" : null diff --git a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts index 3c53d262f..0075dc240 100644 --- a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts @@ -1,3 +1,6 @@ +import * as _ from "lodash"; +import {PropertyPath} from "lodash"; + describe('Drawing Board: Instantiation Templates', function () { describe('Instantiation templates ', () => { @@ -78,30 +81,66 @@ describe('Drawing Board: Instantiation Templates', function () { }); + [ + {desc: "with changes", modifySomeValues: true}, + {desc: "without changes", modifySomeValues: false}, + ].forEach((testCase) => { + + it(`Given a stored template - edit service vnf and vfmodule ${testCase.desc} - deploy request should be ${testCase.desc}`, function () { + + loadDrawingBoardWithRecreateMode(); + + //edit service + cy.openServiceContextMenu(); + cy.getElementByDataTestsId("context-menu-header-edit-item").click(); + if (testCase.modifySomeValues) { + cy.clearInput("instanceName"); + cy.typeToInput("instanceName", "different.instance.name"); + } + cy.getElementByDataTestsId('form-set').click(); + + // edit vnf + editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0"); + if (testCase.modifySomeValues) { + cy.selectPlatformValue('platform'); + cy.selectDropdownOptionByText("tenant", "CESAR-100-D-spjg61909"); + } + cy.getElementByDataTestsId('form-set').click(); + + //edit vf module + editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0"); + if (testCase.modifySomeValues) { + cy.getElementByDataTestsId('sdncPreLoad').click(); + } + cy.getElementByDataTestsId('form-set').click(); + + // Then... + let vnfPath = [ + "vnfs", "vProbe_NC_VNF 0" + ]; + let vfModule_0Path = [ + ...vnfPath, "vfModules", + "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0", + "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg", + ]; + + assertThatBodyFromDeployRequestEqualsToFile(testCase.modifySomeValues ? [ + {path: ["instanceName"], value: "different.instance.name"}, + {path: ["existingNames", "vprobe_nc_service_dg_new_si"], value: undefined}, + {path: ["existingNames", "different.instance.name"], value: ""}, + + {path: [...vnfPath, "platformName"], value: "xxx1,platform"}, + {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"}, + + {path: [...vfModule_0Path, "sdncPreLoad"], value: true}, + ] : []); + }) - it('Given a stored template - edit service vnf and vfmodule without changes - deploy request should be without changes', function () { - - loadDrawingBoardWithRecreateMode(); - - //open - set edit service - cy.openServiceContextMenu() - .getElementByDataTestsId("context-menu-header-edit-item").click() - .getElementByDataTestsId('form-set').click(); - - //open - set edit vnf - editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0") - .getElementByDataTestsId('form-set').click(); - - //open - set edit vf - editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0") - .getElementByDataTestsId('form-set').click(); - - assertThatBodyFromDeployRequestEqualsToFile(); }); - }); }); }); +}); function loadDrawingBoardWithRecreateMode() { const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38'; @@ -145,17 +184,24 @@ function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() { } -function assertThatBodyFromDeployRequestEqualsToFile() { +function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { cy.getDrawingBoardDeployBtn().click(); cy.wait('@expectedPostAsyncInstantiation').then(xhr => { cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json').then((expectedResult) => { + setDeviationInExpected(expectedResult, deviationFromExpected); cy.deepCompare(xhr.request.body, expectedResult); }); }); } +function setDeviationInExpected(expectedResult: any, deviation: { path: PropertyPath; value: any }[]) { + for (const caveat of deviation) { + _.set(expectedResult, caveat.path, caveat.value); + } +} + //We use this function because the deployService() on drawing-board-header.component class // changes rollbackOnFailure value from string type to boolean. function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) { diff --git a/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts index 3caa4e81d..b2d3eb578 100644 --- a/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts @@ -39,6 +39,44 @@ describe('Template', () => { "serviceModelVersion": "1.0", "createdBulkDate": 1525075968000, "isRetryEnabled": true + }, + { + "id": 7, + "created": 1525075968000, + "modified": 1525075971000, + "action": "INSTANTIATE", + "createdId": null, + "modifiedId": null, + "rowNum": null, + "auditUserId": null, + "auditTrail": null, + "jobId": "13063a83-924e-4500-a3a1-e53d1b58450b", + "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e", + "userId": "17807000", + "aLaCarte": false, + "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9d", + "jobStatus": "IN_PROGRESS", + "statusModifiedDate": 1525075968000, + "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": "nWUfl instance name_001", + "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "serviceModelName": "action-data", + "serviceModelVersion": "1.0", + "createdBulkDate": 1525075968000, + "isRetryEnabled": false } ]; @@ -65,6 +103,7 @@ describe('Template', () => { }); cy.route(Cypress.config('baseUrl') + "/asyncInstantiation**", asyncInstantiation); + cy.route(Cypress.config('baseUrl') + "/getuserID", '16807000'); cy.openIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true'); @@ -106,9 +145,14 @@ describe('Template', () => { //check load button is disabled - cy.getElementByDataTestsId('LoadTemplateButton').should('be.disabled') + cy.getElementByDataTestsId('LoadTemplateButton').should('be.disabled'); cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click(); - cy.getElementByDataTestsId('LoadTemplateButton').should('not.be.disabled') + cy.getElementByDataTestsId('LoadTemplateButton').should('not.be.disabled'); + + //filter by userId + cy.get('.member-table-row').should('have.length', 2); + cy.getElementByDataTestsId('filterByUserIdTestId').click(); + cy.get('.member-table-row').should('have.length', 1); }); diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json index 42ac805e9..5ac833dca 100644 --- a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json +++ b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json @@ -80,7 +80,7 @@ "platformName": null, "trackById": "b0732bed-3ddf-43cc-b193-7f18db84e476", "isBase": true, - "volumeGroupName": "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0_vol" + "volumeGroupName": null } } }, diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss new file mode 100644 index 000000000..005e28cc6 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss @@ -0,0 +1,41 @@ +.details-item input { + cursor: pointer; + opacity: 0; + position: absolute; + z-index: 100; + width: 24px; + height: 22px; + margin: 0; +} + +.details-item label { + position: relative; + cursor: pointer; +} + +.details-item label:before { + content:''; + -webkit-appearance: none; + background-color: transparent; + border: 2px solid #0079bf; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05); + padding: 10px; + display: inline-block; + position: relative; + vertical-align: middle; + cursor: pointer; + margin-right: 5px; +} + +.details-item input:checked + label:after { + content: ''; + display: block; + position: absolute; + top: 2px; + left: 9px; + width: 6px; + height: 14px; + border: solid #0079bf; + border-width: 0 2px 2px 0; + transform: rotate(45deg); +} diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.ts b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.ts index f9ba48308..215b1fec1 100644 --- a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.ts +++ b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.ts @@ -4,7 +4,8 @@ import {FormGroup} from "@angular/forms"; @Component({ selector: 'checkbox-form-control', - templateUrl: './checkbox.formControl.component.html' + templateUrl: './checkbox.formControl.component.html', + styleUrls : ['./checkbox.formControl.component.scss'] }) export class CheckboxFormControlComponent{ @Input() data: FormControlModel; diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html index 9b2ce8300..07fc7ab22 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html @@ -24,6 +24,17 @@ </div> <div class="col-md-6"> <div class="col-md-6"> + <div class="details-item" style="text-align: center;"> + <input type="checkbox" + #filterByUserIdCheckbox + id="filterByUserIdCheckbox" + [attr.data-tests-id]="'filterByUserIdTestId'" + [checked]="filterByUserId" + (change)="filterByUserIdChanged(filterByUserIdCheckbox.checked)" + data-toggle="toggle"> + <label class="checkbox-label" + for="'filterByUserIdTestId'">Show only mine</label> + </div> </div> <div class="col-md-6"> <input @@ -49,7 +60,7 @@ </thead> <tbody> <tr class="member-table-row" - *ngFor="let item of filterTableData | searchFilter: filterText ;" + *ngFor="let item of filterTableData | searchFilter: filterText;" (click)="selectedInstantiation = item" [ngClass]="{'selected' : selectedInstantiation && selectedInstantiation.jobId === item.jobId}" [attr.data-tests-id]="'row-' + item.jobId"> diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss index c0ce0c985..d62caf5de 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss @@ -167,7 +167,6 @@ $grid-border: 1px #d2d2d2 solid; .filter-input { float: right; - width: 50%; } .details-item { @@ -205,4 +204,48 @@ $grid-border: 1px #d2d2d2 solid; .member-table-row.selected { background: #8080808f !important; } + + + .details-item input { + cursor: pointer; + opacity: 0; + position: absolute; + z-index: 100; + width: 24px; + height: 22px; + margin: 0; + } + + .details-item label { + position: relative; + cursor: pointer; + } + + .details-item label:before { + content:''; + -webkit-appearance: none; + background-color: transparent; + border: 2px solid #0079bf; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05); + padding: 10px; + display: inline-block; + position: relative; + vertical-align: middle; + cursor: pointer; + margin-right: 5px; + } + + .details-item input:checked + label:after { + content: ''; + display: block; + position: absolute; + top: 2px; + left: 9px; + width: 6px; + height: 14px; + border: solid #0079bf; + border-width: 0 2px 2px 0; + transform: rotate(45deg); + } + } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts index 9681113e8..b37d7f9a2 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts @@ -7,7 +7,11 @@ import {InstantiationTemplatesModalService} from "./instantiation.templates.moda import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model"; import {DrawingBoardModes} from "../../../../drawingBoard/service-planning/drawing-board.modes"; import {InstantiationStatusComponentService} from "../../../../instantiationStatus/instantiationStatus.component.service"; - +import {AaiService} from "../../../services/aaiService/aai.service"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../../store/reducers"; +import * as _ from 'lodash'; +import {forkJoin} from "rxjs"; @Component({ selector: 'template-modal', templateUrl: 'instantiation.templates.modal.component.html', @@ -21,12 +25,15 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string originalTableData: InstantiationTemplatesRowModel[] = []; filterTableData : InstantiationTemplatesRowModel[] = []; filterText: string; + filterByUserId: boolean = false; constructor(dialogService: DialogService, private _iframeService: IframeService, private _serviceInfoService: ServiceInfoService, private _templateModalComponentService: InstantiationTemplatesModalService, private _instantiationStatusComponentService: InstantiationStatusComponentService, + private _aaiService: AaiService, + private _store : NgRedux<AppState>, private _route: ActivatedRoute) { super(dialogService); this.templateModalComponentService = _templateModalComponentService; @@ -37,7 +44,11 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string this._route .queryParams .subscribe(params => { - this._serviceInfoService.getServicesJobInfo(true, params['serviceModelId']).subscribe((jobs) => { + + const getServiceJobInfoRoute = this._serviceInfoService.getServicesJobInfo(true, params['serviceModelId']); + const getUserIdRoute = this._aaiService.getUserId(); + + forkJoin([getServiceJobInfoRoute, getUserIdRoute]).subscribe(([jobs]) => { this.originalTableData = this._templateModalComponentService.convertResponseToUI(jobs); this.filterTableData = this.originalTableData; }); @@ -48,6 +59,14 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string this._instantiationStatusComponentService.navigateToNewViewEdit(this.selectedInstantiation, DrawingBoardModes.RECREATE) }; + filterByUserIdChanged = (value : boolean) : void => { + this.filterByUserId = value; + const userId: string = this._store.getState().service['userId']; + if(!_.isNil(userId)){ + this.filterTableData = this.filterByUserId ? this._templateModalComponentService.filterByUserId(userId, this.originalTableData) : this.originalTableData; + } + }; + closeModal(): void { this.dialogService.removeDialog(this); } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts index 1ff0f61e2..2f044112b 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts @@ -130,4 +130,21 @@ describe('instantiation templates modal service', () => { expect(result.instanceName).toEqual('<Automatically generated>'); }); + test('filterByUserId should filter table data by userId: not empty list', () => { + const jobs : InstantiationTemplatesRowModel[] = [ + new InstantiationTemplatesRowModel({userId : 'userId_1'}), + new InstantiationTemplatesRowModel({userId : 'userId'}), + new InstantiationTemplatesRowModel({userId : 'userId'}), + new InstantiationTemplatesRowModel({userId : 'userId_1'}) + ]; + let result: InstantiationTemplatesRowModel[] = service.filterByUserId('userId', jobs); + expect(result).toHaveLength(2); + }); + + test('filterByUserId should filter table data by userId: empty list should return empty list', () => { + const jobs : InstantiationTemplatesRowModel[] = []; + let result: InstantiationTemplatesRowModel[] = service.filterByUserId('userId', jobs); + expect(result).toHaveLength(0); + }); + }); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts index 8377ccf42..36691fda5 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts @@ -1,5 +1,6 @@ import {Injectable} from "@angular/core"; import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model"; +import * as _ from 'lodash'; @Injectable() export class InstantiationTemplatesModalService { @@ -14,4 +15,14 @@ export class InstantiationTemplatesModalService { return tableRows; }; + + filterByUserId = (userId: string, originalTableData: InstantiationTemplatesRowModel[]): InstantiationTemplatesRowModel[] => { + if (!_.isNil(originalTableData)) { + return originalTableData.filter((item: InstantiationTemplatesRowModel) => { + return item.userId === userId; + }); + } + return []; + }; + } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts index e68c34b85..673709462 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts @@ -14,7 +14,7 @@ export class InstantiationTemplatesRowModel extends InstantiationBase{ constructor(data) { super(data); - this.userId = !_.isNil(data.created) ? data.userId : null; + this.userId = !_.isNil(data.userId) ? data.userId : null; this.createDate = !_.isNil(data.created) ? moment(data.created).format("YYYY-MM-DD HH:mm:ss") : null; this.instanceName = this.getInstanceName(data.serviceInstanceName); this.instantiationStatus = !_.isNil(data.jobStatus) ? data.jobStatus : null; diff --git a/vid-webpack-master/src/app/shared/utils/constants.ts b/vid-webpack-master/src/app/shared/utils/constants.ts index f793e05db..6bf5ff1f4 100644 --- a/vid-webpack-master/src/app/shared/utils/constants.ts +++ b/vid-webpack-master/src/app/shared/utils/constants.ts @@ -39,6 +39,7 @@ export module Constants { public static AAI_GET_ACTIVE_NETWORKS_PATH = '../../aai_get_active_networks/'; public static AAI_GET_VPNS_PATH = '../../aai_get_vpn_list/'; public static AAI_GET_SERVICE_GROUP_MEMBERS_PATH = '../../aai_search_group_members/'; + public static AAI_GET_USER_ID_PATH = '../../getuserID'; public static AAI_GET_VERSION_BY_INVARIANT_ID = 'aai_get_version_by_invariant_id/'; public static SEARCH_SERVICE_INSTANCES = 'search_service_instances'; public static AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE = 'get_vnf_data_by_globalid_and_service_type/'; |