aboutsummaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-07-29 16:13:45 +0300
committerMichael Lando <ml636r@att.com>2018-07-29 16:20:34 +0300
commit5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch)
tree2f9dfc45191e723da69cf74be7829784e9741b94 /test-apis-ci/src/main/java/org/openecomp
parent9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff)
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5 Issue-ID: SDC-1566 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'test-apis-ci/src/main/java/org/openecomp')
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/AttSdcTest.java25
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java787
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java62
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java5
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/InvokedMethodListener.java6
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java6
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java1
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnboardingDataProviders.java8
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java1
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactReqDetails.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentInstanceReqDetails.java13
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentReqDetails.java6
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java102
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ProductReqDetails.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceExternalReqDetails.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java8
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceRespJavaObject.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java21
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ImportTestTypesEnum.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java5
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ServiceInstantiationType.java15
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ToscaKeysEnum.java7
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java1
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java7
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java29
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java37
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java39
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java40
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java55
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java6
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java15
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java17
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java26
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java12
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java15
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java21
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java12
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java24
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java17
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java27
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java61
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java22
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java9
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/groups/GroupsTest.java164
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java27
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java67
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java64
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java33
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java2891
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java31
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java162
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java17
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java41
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java415
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java2768
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java15
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java8
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java2220
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java10
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java31
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java25
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java9
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java10
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java78
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java17
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java22
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java12
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java3
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java38
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java59
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java48
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java22
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java15
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java8
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java5085
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java25
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java22
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java47
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java20
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java24
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java16
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java37
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java1246
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java51
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java52
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java30
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java10
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java19
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/ComplexResourceBaseTest.java17
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/DownloadArtifactBaseTest.java10
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/SimpleOneRsrcOneServiceTest.java8
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest2backup.java22
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/CrudE2E.java38
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java16
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java21
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaAnnotationsTypesDefinition.java29
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java38
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java74
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsAnnotation.java51
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java22
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaNodeTemplatesTopologyTemplateDefinition.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java13
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java31
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaSubstitutionMappingsDefinition.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java9
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTypeDefinition.java26
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTypesDefinition.java26
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/VfModuleDefinition.java37
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/model/ToscaMetadataFieldsPresentationEnum.java1
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java35
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java15
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java28
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java21
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ReqCap.java41
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java33
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaTypesDefinitionUtils.java54
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java75
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java34
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils2.java38
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java405
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java20
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java32
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java29
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java13
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java139
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java7
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java50
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java61
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java41
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java45
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java30
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java16
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java8
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CategoryRestUtils.java11
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java31
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentRestUtils.java4
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java11
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java9
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java24
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/InputsRestUtils.java3
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java32
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ProductRestUtils.java5
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java634
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java32
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java5
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java234
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java9
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java9
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java1
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java60
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/BaseValidationUtils.java10
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CategoryValidationUtils.java6
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java10
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/DistributionValidationUtils.java18
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ErrorValidationUtils.java18
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ProductValidationUtils.java16
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ResourceValidationUtils.java17
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ServiceValidationUtils.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/UserValidationUtils.java15
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java458
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java5497
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java3
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java60
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java5
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java24
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java31
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java16
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/UserAPIs.java25
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java20
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/internalApis/annotations/AnnotationsTest.java201
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java4
187 files changed, 12828 insertions, 14237 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/AttSdcTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/AttSdcTest.java
index f9752febaf..e675676191 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/AttSdcTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/AttSdcTest.java
@@ -20,19 +20,9 @@
package org.openecomp.sdc.ci.tests.api;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.junit.*;
import org.junit.rules.TestName;
import org.junit.rules.TestWatcher;
import org.openecomp.sdc.ci.tests.config.Config;
@@ -43,8 +33,13 @@ import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
public abstract class AttSdcTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java
index 1d0b4040ca..c0f209fdd2 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java
@@ -20,577 +20,264 @@
package org.openecomp.sdc.ci.tests.api;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.LoggerContext;
+import com.aventstack.extentreports.ExtentTest;
+import com.aventstack.extentreports.Status;
+import com.thinkaurelius.titan.core.TitanGraph;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.log4j.Logger;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.cassandra.CassandraUtils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.ITestResult;
-import org.testng.annotations.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
-import com.aventstack.extentreports.ExtentTest;
-import com.aventstack.extentreports.Status;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
public abstract class ComponentBaseTest {
-// private static Logger logger = LoggerFactory.getLogger(ComponentBaseTest.class.getName());
-
- protected static Logger logger= Logger.getLogger(ComponentBaseTest.class);
-
-
-// public ComponentBaseTest(TestName testName, String className) {
-// super(testName, className);
-// }
-
- protected static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator;
- private static final String VERSIONS_INFO_FILE_NAME = "versions.info";
- private static final String REPORT_FILE_NAME = "SDC_CI_Extent_Report.html";
- protected static TitanGraph titanGraph;
- public static Config config;
- protected static ITestContext myContext;
-
-
-
- /**************** METHODS ****************/
- public static ExtentTest getExtendTest() {
- SomeInterface testManager = new ExtentTestManager();
- return testManager.getTest();
- }
-
- public static enum ComponentOperationEnum {
- CREATE_COMPONENT, UPDATE_COMPONENT, GET_COMPONENT, DELETE_COMPONENT, CHANGE_STATE_CHECKIN, CHANGE_STATE_CHECKOUT, CHANGE_STATE_UNDO_CHECKOUT
- };
-
- public ComponentBaseTest(TestName name, String name2) {
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- lc.getLogger("com.thinkaurelius").setLevel(Level.INFO);
- lc.getLogger("com.datastax").setLevel(Level.INFO);
- lc.getLogger("io.netty").setLevel(Level.INFO);
- lc.getLogger("c.d").setLevel(Level.INFO);
- }
-
- public static String getReportFolder() {
- return REPORT_FOLDER;
- }
-
- @BeforeSuite(alwaysRun = true)
- public void setupBeforeSuite(ITestContext context) throws Exception {
- config = Utils.getConfig();
- myContext=context;
- ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context);
- AtomicOperationUtils.createDefaultConsumer(true);
-// openTitanLogic();
- performClean();
-
-
-
- }
-
- @BeforeMethod(alwaysRun = true)
- public void setupBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception {
-
- System.out.println(" method.getName() " + method.getName());
- if (!method.getName().equals("onboardVNFShotFlow")) {
-// System.out.println("ExtentReport instance started from BeforeMethod...");
- logger.info("ExtentReport instance started from BeforeMethod...");
- ExtentTestManager.startTest(method.getName());
- ExtentTestManager.assignCategory(this.getClass());
-
- } else {
-// System.out.println("ExtentReport instance started from Test...");
- logger.debug("ExtentReport instance started from Test...");
- }
-
- }
-
- @AfterMethod(alwaysRun = true)
- public void quitAfterTest(ITestResult result, ITestContext context) throws Exception {
-
- String testName = result.getName();
- Throwable throwable = result.getThrowable();
- int status = result.getStatus();
-
- switch(status){
- case ITestResult.SUCCESS:
- getExtendTest().log(Status.PASS, "Test Result : <span class='label success'>Success</span>");
- break;
-
- case ITestResult.FAILURE:
- getExtendTest().log(Status.ERROR, "ERROR - The following exepction occured");
- getExtendTest().log(Status.ERROR, result.getThrowable());
- getExtendTest().log(Status.FAIL, "<span class='label failure'>Failure</span>");
- break;
-
- case ITestResult.SKIP:
- getExtendTest().log(Status.SKIP, "SKIP - The following exepction occured");
- break;
- default:
- break;
- }
-
-
- ExtentTestManager.endTest();
-
-
- }
-
-/* @AfterClass(alwaysRun = true)
- public synchronized static void cleanAfterClass() throws Exception{
-
-// System.out.println("<<<<<<<<class name>>>>>"+method.getDeclaringClass());
-// System.out.println("<<<<<<<<class name>>>>>"+method.getName());
-
-
- System.out.println("delete components AfterClass");
- if(!config.getSystemUnderDebug()){
- deleteCreatedComponents(getCatalogAsMap());
-// CassandraUtils.truncateAllKeyspaces();
- }else{
- System.out.println("Accordindig to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ...");
- }
-// extentReport.flush();
-
- }*/
-
- @AfterSuite(alwaysRun = true)
- public static void shutdownTitan() throws Exception {
-
- performClean();
-// shutdownTitanLogic();
-
- }
- protected static void openTitanLogic() throws Exception {
-
- logger.trace(config.toString());
- String titanConfigFilePath = config.getTitanPropertiesFile();
- titanGraph = TitanFactory.open(titanConfigFilePath);
- assertNotNull(titanGraph);
-
- }
-
-
- protected static void shutdownTitanLogic() {
- if (titanGraph.isOpen()) {
- titanGraph.close();
- }
- CassandraUtils.close();
- }
-
-
-
- public void setLog(String fromDataProvider) {
-
- String suiteName = ExtentManager.getSuiteName(myContext);
- ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + fromDataProvider);
- ExtentTestManager.assignCategory(this.getClass());
-
- }
-
- protected static void performClean() throws Exception, FileNotFoundException {
-// cleanComponents();
- if(!config.getSystemUnderDebug()){
- deleteCreatedComponents(getCatalogAsMap());
-// CassandraUtils.truncateAllKeyspaces();
- FileHandling.overWriteExistindDir("outputCsar");
- }else{
- System.out.println("Accordindig to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ...");
- }
- }
-
- public void verifyErrorCode(RestResponse response, String action, int expectedCode) {
- assertNotNull("check response object is not null after " + action, response);
- assertNotNull("check error code exists in response after " + action, response.getErrorCode());
- assertEquals("Check response code after + action" + action, expectedCode, response.getErrorCode().intValue());
- }
-
- private static void cleanComponents() throws Exception {
-
- // Components to delete
- List<String> vfResourcesToDelete = new ArrayList<String>();
- List<String> nonVfResourcesToDelete = new ArrayList<String>();
- List<String> servicesToDelete = new ArrayList<String>();
- List<String> productsToDelete = new ArrayList<String>();
-
- // Categories to delete
- List<ImmutableTriple<String, String, String>> productGroupingsToDelete = new ArrayList<>();
- List<ImmutablePair<String, String>> productSubsToDelete = new ArrayList<>();
- List<ImmutablePair<String, String>> resourceSubsToDelete = new ArrayList<>();
- List<String> productCategoriesToDelete = new ArrayList<>();
- List<String> resourceCategoriesToDelete = new ArrayList<String>();
- List<String> serviceCategoriesToDelete = new ArrayList<String>();
-
- List<String> resourcesNotToDelete = config.getResourcesNotToDelete();
- List<String> resourceCategoriesNotToDelete = config.getResourceCategoriesNotToDelete();
- List<String> serviceCategoriesNotToDelete = config.getServiceCategoriesNotToDelete();
-
- Iterable<TitanVertex> vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Resource.getName()).vertices();
- if (vertices != null) {
- Iterator<TitanVertex> iter = vertices.iterator();
- while (iter.hasNext()) {
- Vertex vertex = iter.next();
- Boolean isAbstract = vertex.value(GraphPropertiesDictionary.IS_ABSTRACT.getProperty());
- // if (!isAbstract) {
- String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
- String version = vertex.value(GraphPropertiesDictionary.VERSION.getProperty());
-
- if ((resourcesNotToDelete != null && !resourcesNotToDelete.contains(name)) || (version != null && !version.equals("1.0"))) {
- String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- String resourceType = vertex.value(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty());
- if (name.startsWith("ci")) {
- if (resourceType.equals(ResourceTypeEnum.VF.name())) {
- vfResourcesToDelete.add(id);
- } else {
- nonVfResourcesToDelete.add(id);
- }
- }
- } else if ((resourcesNotToDelete != null && !resourcesNotToDelete.contains(name)) || (version != null && version.equals("1.0"))) {
- if ((boolean) vertex.value(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()) == false) {
- vertex.property(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true);
- }
- }
- // }
- }
- }
- vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Service.getName()).vertices();
- if (vertices != null) {
- Iterator<TitanVertex> iter = vertices.iterator();
- while (iter.hasNext()) {
- Vertex vertex = iter.next();
- String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
- if (name.startsWith("ci")) {
- servicesToDelete.add(id);
- }
- }
- }
-
- vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Product.getName()).vertices();
- if (vertices != null) {
- Iterator<TitanVertex> iter = vertices.iterator();
- while (iter.hasNext()) {
- Vertex vertex = iter.next();
- String id = vertex.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- String name = vertex.value(GraphPropertiesDictionary.NAME.getProperty());
- if (name.startsWith("Ci")) {
- productsToDelete.add(id);
- }
- }
- }
-
- // Getting categories
-
- vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ResourceNewCategory.getName()).vertices();
- if (vertices != null) {
- Iterator<TitanVertex> iter = vertices.iterator();
- while (iter.hasNext()) {
- Vertex category = iter.next();
- String name = category.value(GraphPropertiesDictionary.NAME.getProperty());
- if (!resourceCategoriesNotToDelete.contains(name)) {
- String catId = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- resourceCategoriesToDelete.add(catId);
- Iterator<Vertex> subs = category.vertices(Direction.OUT, GraphEdgeLabels.SUB_CATEGORY.getProperty());
- while (subs.hasNext()) {
- Vertex sub = subs.next();
- String subCatId = sub.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- resourceSubsToDelete.add(new ImmutablePair<String, String>(catId, subCatId));
- }
- }
- }
- }
-
- vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ServiceNewCategory.getName()).vertices();
- if (vertices != null) {
- Iterator<TitanVertex> iter = vertices.iterator();
- while (iter.hasNext()) {
- Vertex category = iter.next();
- String name = category.value(GraphPropertiesDictionary.NAME.getProperty());
- if (!serviceCategoriesNotToDelete.contains(name)) {
- String id = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- serviceCategoriesToDelete.add(id);
- }
- }
- }
-
- vertices = titanGraph.query().has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ProductCategory.getName()).vertices();
- if (vertices != null) {
- Iterator<TitanVertex> iter = vertices.iterator();
- while (iter.hasNext()) {
- Vertex category = iter.next();
- String catId = category.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- productCategoriesToDelete.add(catId);
- Iterator<Vertex> subs = category.vertices(Direction.OUT, GraphEdgeLabels.SUB_CATEGORY.getProperty());
- while (subs.hasNext()) {
- Vertex sub = subs.next();
- String subCatId = sub.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- productSubsToDelete.add(new ImmutablePair<String, String>(catId, subCatId));
- Iterator<Vertex> groupings = sub.vertices(Direction.OUT, GraphEdgeLabels.GROUPING.getProperty());
- while (groupings.hasNext()) {
- Vertex grouping = groupings.next();
- String groupId = grouping.value(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- productGroupingsToDelete.add(new ImmutableTriple<String, String, String>(catId, subCatId, groupId));
- }
- }
-
- }
- }
-
- titanGraph.tx().commit();
-
- String adminId = UserRoleEnum.ADMIN.getUserId();
- /* String productStrategistId = UserRoleEnum.PRODUCT_STRATEGIST1.getUserId();*/
-
- // Component delete
-
-/* for (String id : productsToDelete) {
- RestResponse deleteProduct = ProductRestUtils.deleteProduct(id, productStrategistId);
-
- }*/
- for (String id : servicesToDelete) {
- RestResponse deleteServiceById = ServiceRestUtils.deleteServiceById(id, adminId);
-
- }
- for (String id : vfResourcesToDelete) {
- RestResponse deleteResource = ResourceRestUtils.deleteResource(id, adminId);
-
- }
-
- for (String id : nonVfResourcesToDelete) {
- RestResponse deleteResource = ResourceRestUtils.deleteResource(id, adminId);
-
- }
-
- // Categories delete - product
- /*String componentType = BaseRestUtils.PRODUCT_COMPONENT_TYPE;
- for (ImmutableTriple<String, String, String> triple : productGroupingsToDelete) {
- CategoryRestUtils.deleteGrouping(triple.getRight(), triple.getMiddle(), triple.getLeft(), productStrategistId, componentType);
- }
- for (ImmutablePair<String, String> pair : productSubsToDelete) {
- CategoryRestUtils.deleteSubCategory(pair.getRight(), pair.getLeft(), productStrategistId, componentType);
- }
- for (String id : productCategoriesToDelete) {
- CategoryRestUtils.deleteCategory(id, productStrategistId, componentType);
- }*/
-
- // Categories delete - resource
- String componentType = BaseRestUtils.RESOURCE_COMPONENT_TYPE;
- for (ImmutablePair<String, String> pair : resourceSubsToDelete) {
- CategoryRestUtils.deleteSubCategory(pair.getRight(), pair.getLeft(), adminId, componentType);
- }
- for (String id : resourceCategoriesToDelete) {
- CategoryRestUtils.deleteCategory(id, adminId, componentType);
- }
- // Categories delete - resource
- componentType = BaseRestUtils.SERVICE_COMPONENT_TYPE;
- for (String id : serviceCategoriesToDelete) {
- CategoryRestUtils.deleteCategory(id, adminId, componentType);
- }
-
- }
-
- private static void deleteCreatedComponents(Map<String, List<Component>> convertCatalogResponseToJavaObject) throws IOException {
- final String userId = UserRoleEnum.DESIGNER.getUserId();
-
- List<Component> resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.PRODUCT_PARAM_NAME);
- if (resourcesArrayList.size() > 0) {
- List<String> collect = buildCollectionUniqueId(resourcesArrayList);
- for (String uId : collect) {
- ProductRestUtils.deleteProduct(uId, userId);
- }
- }
-
-
- resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.SERVICE_PARAM_NAME);
- if (resourcesArrayList.size() > 0) {
- List<String> collect = buildCollectionUniqueId(resourcesArrayList);
- for (String uId : collect) {
- ServiceRestUtils.markServiceToDelete(uId, userId);
- }
- ServiceRestUtils.deleteMarkedServices(userId);
- }
-
-
- resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.RESOURCE_PARAM_NAME);
-
- // List<String> collect = resourcesArrayList.stream().filter(s ->
- // s.getName().startsWith("ci")).map(e ->
- // e.getUniqueId()).collect(Collectors.toList());
-
- // List<Map<String, String>> collect =
- // resourcesArrayList.stream().filter(s ->
- // s.getName().startsWith("ci")).map(e ->
- // e.getAllVersions()).collect(Collectors.toList());
- /*
- * List<String> collect = resourcesArrayList.stream().filter(s -> s.getName().startsWith("ci")) .flatMap(e -> e.getAllVersions().values().stream()).collect(Collectors.toList());
- */
-
- if (!CollectionUtils.isEmpty(resourcesArrayList)) {
- List<String> collect = buildCollectionUniqueId(resourcesArrayList);
- for (String uId : collect) {
- ResourceRestUtils.markResourceToDelete(uId, userId);
- }
- ResourceRestUtils.deleteMarkedResources(userId);
- }
-
-
-
- }
-
- private void deleteCollection(List<Component> componentArrayList, Consumer<String> deleteHandler) {
-
- if (componentArrayList.size() > 0) {
- List<String> collect = buildCollectionUniqueId(componentArrayList);
- for (String uId : collect) {
- deleteHandler.accept(uId);
- // ProductRestUtils.deleteProduct(uId, userId);
- }
- }
- }
-
- protected static List<String> buildCollectionUniqueId(List<Component> resourcesArrayList) {
-
- // Stream<String> flatMap = resourcesArrayList.stream().filter(s ->
- // s.getName().startsWith("ci")).map(e -> e.getAllVersions()).map( e ->
- // e.values()).flatMap( e -> e.stream());
-
- // List<String> collect = resourcesArrayList.stream()
- // //
- // .filter(s -> s.getName().startsWith("ci") )
- // //
- // .map(e -> e.getUniqueId())
-
- // .map( e -> e.values())
- // .filter(out -> out!=null )
- // .flatMap( e -> e.stream())
- // .collect(Collectors.toList());
-
- // List<String> collect = resourcesArrayList.stream().filter(s ->
- // s.getName().startsWith("ci"))
- // .flatMap(e ->
- // e.getAllVersions().values().stream()).collect(Collectors.toList());
- ComponentTypeEnum componentTypeEnum = resourcesArrayList.get(0).getComponentType();
-
- List<String> genericCollection = new ArrayList<String>();
-
- resourcesArrayList.stream().filter(s -> s.getName().toLowerCase().startsWith("ci") && !s.getName().toLowerCase().equals("cindervolume")).map(e -> e.getUniqueId()).collect(Collectors.toList()).forEach((i) -> {
- buildCollectionBaseOnComponentType(componentTypeEnum, genericCollection, i);
- });
-
-
- //
-
- // List<String> collect =
- // genericCollection.stream().collect(Collectors.toList());
-
- return genericCollection;
- }
-
- public static void buildCollectionBaseOnComponentType(ComponentTypeEnum componentTypeEnum,
- List<String> genericCollection, String i) {
- try {
- switch (componentTypeEnum) {
- case RESOURCE:
- RestResponse resource = ResourceRestUtils.getResource(i);
- Resource convertResourceResponseToJavaObject = ResponseParser.convertResourceResponseToJavaObject(resource.getResponse());
- Map<String, String> allVersions = convertResourceResponseToJavaObject.getAllVersions();
- Collection<String> values = allVersions.values();
- genericCollection.addAll(values);
-
- break;
- case SERVICE:
- RestResponse service = ServiceRestUtils.getService(i);
- Service convertServiceResponseToJavaObject = ResponseParser.convertServiceResponseToJavaObject(service.getResponse());
- allVersions = convertServiceResponseToJavaObject.getAllVersions();
- values = allVersions.values();
- genericCollection.addAll(values);
-
- break;
-
-
- case PRODUCT:
- RestResponse product = ProductRestUtils.getProduct(i);
- Product convertProductResponseToJavaObject = ResponseParser.convertProductResponseToJavaObject(product.getResponse());
- allVersions = convertProductResponseToJavaObject.getAllVersions();
- values = allVersions.values();
- genericCollection.addAll(values);
-
- break;
-
- // default:
- // break;
- }
- } catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
-
- protected static Map<String, List<Component>> getCatalogAsMap() throws Exception {
- RestResponse catalog = CatalogRestUtils.getCatalog(UserRoleEnum.DESIGNER.getUserId());
- Map<String, List<Component>> convertCatalogResponseToJavaObject = ResponseParser.convertCatalogResponseToJavaObject(catalog.getResponse());
- return convertCatalogResponseToJavaObject;
- }
- protected Resource createVfFromCSAR(User sdncModifierDetails, String csarId) throws Exception {
- // create new resource from Csar
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
-
- resourceDetails.setCsarUUID(csarId);
- resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- Resource createdResource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
- return createdResource;
- }
-
+ protected static Logger logger = Logger.getLogger(ComponentBaseTest.class);
+
+ protected static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator;
+ private static final String VERSIONS_INFO_FILE_NAME = "versions.info";
+ private static final String REPORT_FILE_NAME = "SDC_CI_Extent_Report.html";
+ protected static TitanGraph titanGraph;
+ public static Config config;
+ protected static ITestContext myContext;
+
+
+ /**************** METHODS ****************/
+ public static ExtentTest getExtendTest() {
+ SomeInterface testManager = new ExtentTestManager();
+ return testManager.getTest();
+ }
+
+ public static enum ComponentOperationEnum {
+ CREATE_COMPONENT, UPDATE_COMPONENT, GET_COMPONENT, DELETE_COMPONENT, CHANGE_STATE_CHECKIN, CHANGE_STATE_CHECKOUT, CHANGE_STATE_UNDO_CHECKOUT
+ }
+
+ public ComponentBaseTest(TestName name, String name2) {
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ lc.getLogger("com.thinkaurelius").setLevel(Level.INFO);
+ lc.getLogger("com.datastax").setLevel(Level.INFO);
+ lc.getLogger("io.netty").setLevel(Level.INFO);
+ lc.getLogger("c.d").setLevel(Level.INFO);
+ }
+
+ public static String getReportFolder() {
+ return REPORT_FOLDER;
+ }
+
+ @BeforeSuite(alwaysRun = true)
+ public void setupBeforeSuite(ITestContext context) throws Exception {
+ config = Utils.getConfig();
+ myContext = context;
+ ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context);
+ AtomicOperationUtils.createDefaultConsumer(true);
+ performClean();
+ }
+
+ @BeforeMethod(alwaysRun = true)
+ public void setupBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception {
+
+ System.out.println(" method.getName() " + method.getName());
+ if (!method.getName().equals("onboardVNFShotFlow")) {
+ logger.info("ExtentReport instance started from BeforeMethod...");
+ ExtentTestManager.startTest(method.getName());
+ ExtentTestManager.assignCategory(this.getClass());
+
+ } else {
+ logger.debug("ExtentReport instance started from Test...");
+ }
+
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void quitAfterTest(ITestResult result, ITestContext context) throws Exception {
+
+ String testName = result.getName();
+ Throwable throwable = result.getThrowable();
+ int status = result.getStatus();
+
+ switch (status) {
+ case ITestResult.SUCCESS:
+ getExtendTest().log(Status.PASS, "Test Result : <span class='label success'>Success</span>");
+ break;
+
+ case ITestResult.FAILURE:
+ getExtendTest().log(Status.ERROR, "ERROR - The following exepction occured");
+ getExtendTest().log(Status.ERROR, result.getThrowable());
+ getExtendTest().log(Status.FAIL, "<span class='label failure'>Failure</span>");
+ break;
+
+ case ITestResult.SKIP:
+ getExtendTest().log(Status.SKIP, "SKIP - The following exepction occured");
+ break;
+ default:
+ break;
+ }
+
+
+ ExtentTestManager.endTest();
+
+
+ }
+
+ @AfterSuite(alwaysRun = true)
+ public static void shutdownTitan() throws Exception {
+ performClean();
+ }
+
+ public void setLog(String fromDataProvider) {
+
+ String suiteName = ExtentManager.getSuiteName(myContext);
+ ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + fromDataProvider);
+ ExtentTestManager.assignCategory(this.getClass());
+
+ }
+
+ protected static void performClean() throws Exception, FileNotFoundException {
+ if (!config.getSystemUnderDebug()) {
+ deleteCreatedComponents(getCatalogAsMap());
+ FileHandling.overWriteExistindDir("outputCsar");
+ } else {
+ System.out.println("Accordindig to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ...");
+ }
+ }
+
+ public void verifyErrorCode(RestResponse response, String action, int expectedCode) {
+ assertNotNull("check response object is not null after " + action, response);
+ assertNotNull("check error code exists in response after " + action, response.getErrorCode());
+ assertEquals("Check response code after + action" + action, expectedCode, response.getErrorCode().intValue());
+ }
+
+ private static void deleteCreatedComponents(Map<String, List<Component>> convertCatalogResponseToJavaObject) throws IOException {
+ final String userId = UserRoleEnum.DESIGNER.getUserId();
+
+ /* List<Component> resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.PRODUCT_PARAM_NAME);
+ if (resourcesArrayList.size() > 0) {
+ List<String> collect = buildCollectionUniqueId(resourcesArrayList);
+ for (String uId : collect) {
+ ProductRestUtils.deleteProduct(uId, userId);
+ }
+ }*/
+
+ List<Component> resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.RESOURCE_PARAM_NAME);
+ if (!CollectionUtils.isEmpty(resourcesArrayList)) {
+ List<String> collect = buildCollectionUniqueId(resourcesArrayList);
+ for (String uId : collect) {
+ ResourceRestUtils.markResourceToDelete(uId, userId);
+ }
+ ResourceRestUtils.deleteMarkedResources(userId);
+ }
+
+ resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.SERVICE_PARAM_NAME);
+ if (resourcesArrayList.size() > 0) {
+ List<String> collect = buildCollectionUniqueId(resourcesArrayList);
+ for (String uId : collect) {
+ ServiceRestUtils.markServiceToDelete(uId, userId);
+ }
+ ServiceRestUtils.deleteMarkedServices(userId);
+ }
+ }
+
+ protected static List<String> buildCollectionUniqueId(List<Component> resourcesArrayList) {
+
+
+ List<String> genericCollection = new ArrayList<>();
+ if(resourcesArrayList.get(0) != null) {
+ ComponentTypeEnum componentTypeEnum = resourcesArrayList.get(0).getComponentType();
+ resourcesArrayList.stream().filter(a -> a != null).
+ filter(s -> s.getName().toLowerCase().startsWith("ci") && !s.getName().toLowerCase().equals("cindervolume")).
+ filter(f -> f.getUniqueId() != null).
+ map(e -> e.getUniqueId()).
+ collect(Collectors.toList()).
+ forEach((i) -> {
+ buildCollectionBaseOnComponentType(componentTypeEnum, genericCollection, i);
+ });
+ }
+ return genericCollection;
+ }
+
+ public static void buildCollectionBaseOnComponentType(ComponentTypeEnum componentTypeEnum,
+ List<String> genericCollection, String i) {
+ try {
+ switch (componentTypeEnum) {
+ case RESOURCE:
+ RestResponse resource = ResourceRestUtils.getResource(i);
+ Resource convertResourceResponseToJavaObject = ResponseParser.convertResourceResponseToJavaObject(resource.getResponse());
+ Map<String, String> allVersions = convertResourceResponseToJavaObject.getAllVersions();
+ Collection<String> values = allVersions.values();
+ genericCollection.addAll(values);
+
+ break;
+ case SERVICE:
+ RestResponse service = ServiceRestUtils.getService(i);
+ Service convertServiceResponseToJavaObject = ResponseParser.convertServiceResponseToJavaObject(service.getResponse());
+ allVersions = convertServiceResponseToJavaObject.getAllVersions();
+ values = allVersions.values();
+ genericCollection.addAll(values);
+
+ break;
+
+
+ case PRODUCT:
+ RestResponse product = ProductRestUtils.getProduct(i);
+ Product convertProductResponseToJavaObject = ResponseParser.convertProductResponseToJavaObject(product.getResponse());
+ allVersions = convertProductResponseToJavaObject.getAllVersions();
+ values = allVersions.values();
+ genericCollection.addAll(values);
+
+ break;
+ }
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ protected static Map<String, List<Component>> getCatalogAsMap() throws Exception {
+ RestResponse catalog = CatalogRestUtils.getCatalog(UserRoleEnum.DESIGNER.getUserId());
+ Map<String, List<Component>> convertCatalogResponseToJavaObject = ResponseParser.convertCatalogResponseToJavaObject(catalog.getResponse());
+ return convertCatalogResponseToJavaObject;
+ }
+
+ protected Resource createVfFromCSAR(User sdncModifierDetails, String csarId) throws Exception {
+ // create new resource from Csar
+ ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
+
+ resourceDetails.setCsarUUID(csarId);
+ resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
+ RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
+ BaseRestUtils.checkCreateResponse(createResource);
+ Resource createdResource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
+ return createdResource;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java
index 4fe9d623b2..87b4c77ec6 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java
@@ -20,58 +20,26 @@
package org.openecomp.sdc.ci.tests.api;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.CapReqDef;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.RelationshipInfo;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.ci.tests.datatypes.*;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.Assert;
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import static org.testng.AssertJUnit.*;
+
public class ComponentInstanceBaseTest extends ComponentBaseTest {
public static final String acceptHeaderData = "application/json";
// Req/cap of container component
@@ -123,9 +91,9 @@ public class ComponentInstanceBaseTest extends ComponentBaseTest {
resourceDetailsCP_02 = ElementFactory.getDefaultResourceByType("ciCP200", NormativeTypesEnum.PORT, ResourceCategoryEnum.GENERIC_DATABASE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.CP.toString());
resourceDetailsVL_01 = ElementFactory.getDefaultResourceByType("ciVL100", NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VL.toString());
resourceDetailsVL_02 = ElementFactory.getDefaultResourceByType("ciVL200", NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VL.toString());
- serviceDetails_01 = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId());
- serviceDetails_02 = ElementFactory.getDefaultService("ciNewtestservice2", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId());
- serviceDetails_03 = ElementFactory.getDefaultService("ciNewtestservice3", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId());
+ serviceDetails_01 = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
+ serviceDetails_02 = ElementFactory.getDefaultService("ciNewtestservice2", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
+ serviceDetails_03 = ElementFactory.getDefaultService("ciNewtestservice3", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
productDetails_01 = ElementFactory.getDefaultProduct("ciProduct01");
productDetails_02 = ElementFactory.getDefaultProduct("ciProduct02");
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java
index 44c4275194..194966d699 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java
@@ -20,17 +20,12 @@
package org.openecomp.sdc.ci.tests.api;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
-import org.testng.ITestContext;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.aventstack.extentreports.reporter.ExtentXReporter;
import com.aventstack.extentreports.reporter.configuration.Protocol;
import com.aventstack.extentreports.reporter.configuration.Theme;
import org.openecomp.sdc.ci.tests.config.Config;
-
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java
index 2c242d00bd..5cb5a5b442 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java
@@ -21,14 +21,12 @@
package org.openecomp.sdc.ci.tests.api;
import com.aventstack.extentreports.ExtentTest;
-import com.aventstack.extentreports.MediaEntityBuilder;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.markuputils.ExtentColor;
import com.aventstack.extentreports.markuputils.Markup;
import com.aventstack.extentreports.markuputils.MarkupHelper;
import java.io.File;
-import org.openecomp.sdc.ci.tests.api.ExtentTestManager;
public class ExtentTestActions {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
index b908dddf48..d084cb8d99 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
@@ -23,8 +23,6 @@ package org.openecomp.sdc.ci.tests.api;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import java.io.FileNotFoundException;
-
public interface Urls {
@@ -269,6 +267,7 @@ public interface Urls {
final String GET_SERVICE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/serviceName/%s/serviceVersion/%s";
final String GET_SERVICES_REQUIRMENTS_CAPABILITIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/requirmentsCapabilities/services/%s";
+ final String GET_INSTANCE_REQUIRMENTS_CAPABILITIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/filteredDataByParams?include=requirements&include=capabilities";
final String CREATE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance";
final String DELETE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s";
@@ -392,4 +391,5 @@ public interface Urls {
final String UPDATE_VSP = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s";
final String GET_VSP_COMPONENT_BY_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s";
final String GET_VLM_COMPONENT_BY_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s";
+ final String ACTION_ARCHIVE_RESTORE_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/%s/%s/actions";
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java
index f251c2dcae..c44c029c76 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java
@@ -20,6 +20,8 @@
package org.openecomp.sdc.ci.tests.config;
+import org.yaml.snakeyaml.Yaml;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -27,8 +29,6 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
-import org.yaml.snakeyaml.Yaml;
-
public class Config {
private static String WINDOWS_CONFIG_FILE = "src/main/resources/ci/conf/attsdc.yaml";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/InvokedMethodListener.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/InvokedMethodListener.java
index fbc493ffd6..bfed5dc90d 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/InvokedMethodListener.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/InvokedMethodListener.java
@@ -20,15 +20,15 @@
package org.openecomp.sdc.ci.tests.config;
-import java.util.HashMap;
-import java.util.Map;
-
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.internal.TestResult;
+import java.util.HashMap;
+import java.util.Map;
+
public class InvokedMethodListener implements IInvokedMethodListener {
static Map<String, Integer> methodFailCount = new HashMap<String, Integer>();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java
index ae2eec8d52..9060839b86 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java
@@ -1,19 +1,13 @@
package org.openecomp.sdc.ci.tests.config;
-import fj.data.Either;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
import org.yaml.snakeyaml.Yaml;
import java.io.*;
import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
import java.util.Map;
public class MainToTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java
index c6e684c020..25a3779397 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java
@@ -5,7 +5,6 @@ import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
import org.yaml.snakeyaml.Yaml;
import java.io.File;
-import java.util.HashMap;
import java.util.Map;
public class UserCredentialsFromFile {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnboardingDataProviders.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnboardingDataProviders.java
index fc75ffb78d..29de86adb3 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnboardingDataProviders.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnboardingDataProviders.java
@@ -1,13 +1,13 @@
package org.openecomp.sdc.ci.tests.dataProviders;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils;
import org.testng.annotations.DataProvider;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
public class OnboardingDataProviders {
protected static String filepath = FileHandling.getVnfRepositoryPath();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java
index 58a11b012f..b61daf8075 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProviders/OnbordingDataProviders.java
@@ -4,7 +4,6 @@ import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils;
import org.testng.annotations.DataProvider;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactReqDetails.java
index 15e1e0aab3..207d8694fd 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactReqDetails.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactReqDetails.java
@@ -20,10 +20,10 @@
package org.openecomp.sdc.ci.tests.datatypes;
-import java.util.List;
-
import org.openecomp.sdc.be.model.HeatParameterDefinition;
+import java.util.List;
+
public class ArtifactReqDetails {
public ArtifactReqDetails() {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentInstanceReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentInstanceReqDetails.java
index 13e51a092f..d6699d32d7 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentInstanceReqDetails.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentInstanceReqDetails.java
@@ -30,6 +30,7 @@ public class ComponentInstanceReqDetails {
String posY;
String name;
String uniqueId;
+ String originType;
public ComponentInstanceReqDetails() {
super();
@@ -43,9 +44,10 @@ public class ComponentInstanceReqDetails {
this.posY = componentInstance.getPosY();
// this.name = "myResourceInstance";
this.name = componentInstance.getName();
+ this.originType = componentInstance.getOriginType().name();
}
- public ComponentInstanceReqDetails(String resourceUid, String description, String posX, String posY, String name) {
+ public ComponentInstanceReqDetails(String resourceUid, String description, String posX, String posY, String name, String originType) {
super();
this.componentUid = resourceUid;
this.description = description;
@@ -53,6 +55,7 @@ public class ComponentInstanceReqDetails {
this.posY = posY;
// this.name = "myResourceInstance";
this.name = name;
+ this.originType = originType;
}
public ComponentInstanceReqDetails(String resourceUid, String description, String posX, String posY) {
@@ -111,6 +114,14 @@ public class ComponentInstanceReqDetails {
this.uniqueId = uniqueId;
}
+ public String getOriginType() {
+ return originType;
+ }
+
+ public void setOriginType(String originType) {
+ this.originType = originType;
+ }
+
@Override
public String toString() {
return "ResourceInstanceReqDetails [resourceUid=" + componentUid + ", description=" + description + ", posX="
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentReqDetails.java
index 8546732414..36c9fc8cd7 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentReqDetails.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ComponentReqDetails.java
@@ -20,13 +20,13 @@
package org.openecomp.sdc.ci.tests.datatypes;
-import java.util.ArrayList;
-import java.util.List;
-
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import java.util.ArrayList;
+import java.util.List;
+
public abstract class ComponentReqDetails {
protected String name;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java
index e7899eeeb4..d877150ceb 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ImportReqDetails.java
@@ -20,35 +20,24 @@
package org.openecomp.sdc.ci.tests.datatypes;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.yaml.snakeyaml.Yaml;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.*;
+import java.util.*;
+
+import static org.testng.AssertJUnit.*;
public class ImportReqDetails extends ResourceReqDetails {
+ private static final String CAPS = "capabilities";
private String payloadName;
private String payloadData;
@@ -62,6 +51,12 @@ public class ImportReqDetails extends ResourceReqDetails {
String vendorName, String vendorRelease, String contactId, String icon) {
super(resourceName, description, tags, null, derivedFrom, vendorName, vendorRelease, contactId, icon);
}
+
+ public ImportReqDetails(Resource resource, String payloadName, String payloadData){
+ super(resource);
+ this.payloadData = payloadData;
+ this.payloadName = payloadName;
+ }
public String getPayloadName() {
return payloadName;
@@ -84,8 +79,7 @@ public class ImportReqDetails extends ResourceReqDetails {
return "ImportReqDetails [payloadName=" + payloadName + ", payloadData=" + payloadData + "]";
}
- public void setReqirementsAndCapabilities(String path, String fileName, User user, String derivedFromSource)
- throws Exception {
+ public void setReqirementsAndCapabilities(String path, String fileName, User user, String derivedFromSource) throws IOException, JSONException{
setRequirements(path, fileName, user, derivedFromSource);
setCapabilities(path, fileName, user, derivedFromSource);
}
@@ -110,14 +104,15 @@ public class ImportReqDetails extends ResourceReqDetails {
return requirements;
}
- public void setRequirements(String path, String fileName, User user, String derivedFromSource) throws Exception {
+ public void setRequirements(String path, String fileName, User user, String derivedFromSource) throws IOException, JSONException {
Map<String, Object> requirementsFromFile = getRequirementsMapFromFile(path + File.separator + fileName,
toscaResourceName, "requirements");
- Map<String, Object> requirements = organizeRequirementsMap(requirementsFromFile);
- getDerivedReqCap(user, requirements, "requirements", derivedFromSource);
- this.requirements = requirements;
+ Map<String, Object> reqs = organizeRequirementsMap(requirementsFromFile);
+ getDerivedReqCap(user, reqs, "requirements", derivedFromSource);
+ this.requirements = reqs;
}
+ @SuppressWarnings("unchecked")
private void getDerivedReqCap(User user, Map<String, Object> reqCapMap, String field, String derivedFromResource)
throws IOException, JSONException {
@@ -134,17 +129,16 @@ public class ImportReqDetails extends ResourceReqDetails {
List<Object> lst = (List<Object>) parsedFieldFromResponseAsMap.get(type);
convertListToMap = convertListToMap(lst);
- if (field.equals("capabilities")) {
+ if (field.equals(CAPS)) {
convertListToMap.replace("capabilitySources", derivedList);
- lst = new ArrayList<Object>(Arrays.asList(convertListToMap));
+ lst = new ArrayList<>(Arrays.asList(convertListToMap));
}
Object existingValue = reqCapMap.get(type);
if (existingValue != null) {
Map<String, Object> convertedExistingValue = convertListToMap((List<Object>) existingValue);
- if (convertedExistingValue.get("name").toString().toLowerCase()
- .equals(convertListToMap.get("name").toString().toLowerCase())) {
- lst = new ArrayList<Object>(Arrays.asList(convertedExistingValue));
+ if (convertedExistingValue.get("name").toString().equalsIgnoreCase(convertListToMap.get("name").toString())) {
+ lst = new ArrayList<>(Arrays.asList(convertedExistingValue));
} else {
lst.add(convertedExistingValue);
}
@@ -174,19 +168,20 @@ public class ImportReqDetails extends ResourceReqDetails {
return capabilities;
}
- public void setCapabilities(String path, String fileName, User user, String derivedFromSource) throws Exception {
+ public void setCapabilities(String path, String fileName, User user, String derivedFromSource) throws IOException, JSONException {
Map<String, Object> capabilitiesFromFile = getCapabilitiesMapFromFile(path + File.separator + fileName,
- toscaResourceName, "capabilities");
- Map<String, Object> capabilities = organizeCapabilitiesMap(capabilitiesFromFile);
- getDerivedReqCap(user, capabilities, "capabilities", derivedFromSource);
- this.capabilities = capabilities;
+ toscaResourceName, CAPS);
+ Map<String, Object> caps = organizeCapabilitiesMap(capabilitiesFromFile);
+ getDerivedReqCap(user, caps, CAPS, derivedFromSource);
+ this.capabilities = caps;
}
+ @SuppressWarnings("unchecked")
private Map<String, Object> organizeCapabilitiesMap(Map<String, Object> capabilitiesFromFile) {
Iterator<String> iterator = capabilitiesFromFile.keySet().iterator();
- Map<String, Object> capMap = new HashMap<String, Object>();
+ Map<String, Object> capMap = new HashMap<>();
while (iterator.hasNext()) {
- List<Object> valueList = new ArrayList<Object>();
+ List<Object> valueList = new ArrayList<>();
String next = iterator.next();
Map<String, Object> valuesMap = (Map<String, Object>) capabilitiesFromFile.get(next);
String key = valuesMap.remove("type").toString();
@@ -204,26 +199,28 @@ public class ImportReqDetails extends ResourceReqDetails {
valueList.add(valuesMap);
} else {
Map<String, Object> convertValue = convertListToMap((List<Object>) tempValue);
- valueList = new ArrayList<Object>(Arrays.asList(convertValue, valuesMap));
+ valueList = new ArrayList<>(Arrays.asList(convertValue, valuesMap));
}
capMap.put(key, valueList);
}
return capMap;
}
+ @SuppressWarnings("unchecked")
private Map<String, Object> getCapabilitiesMapFromFile(String fileName, String toscaResourceName,
- String fieldToTest) throws Exception {
+ String fieldToTest) throws FileNotFoundException {
Map<String, Object> resourceToscaMap = getToscaResourceFromFile(fileName, toscaResourceName);
Object capMap = resourceToscaMap.get(fieldToTest);
if (capMap == null) {
- return new HashMap<String, Object>();
+ return new HashMap<>();
}
return (Map<String, Object>) capMap;
}
+ @SuppressWarnings("unchecked")
private Map<String, Object> organizeRequirementsMap(Map<String, Object> requirementsFromFile) {
- Map<String, Object> reqMap = new HashMap<String, Object>();
- List<Object> valueList = new ArrayList<Object>();
+ Map<String, Object> reqMap = new HashMap<>();
+ List<Object> valueList = new ArrayList<>();
Iterator<String> iterator = requirementsFromFile.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
@@ -244,19 +241,19 @@ public class ImportReqDetails extends ResourceReqDetails {
return reqMap;
}
+ @SuppressWarnings("unchecked")
private Map<String, Object> getRequirementsMapFromFile(String fileName, String toscaResourceName,
- String fieldToTest) throws Exception {
+ String fieldToTest) throws FileNotFoundException {
Map<String, Object> resourceToscaMap = getToscaResourceFromFile(fileName, toscaResourceName);
List<Object> reqListFromFile = (List<Object>) resourceToscaMap.get(fieldToTest);
if (reqListFromFile == null) {
- return new HashMap<String, Object>();
+ return new HashMap<>();
}
- Map<String, Object> testedMapFromFile = convertListToMap(reqListFromFile);
- return testedMapFromFile;
+ return convertListToMap(reqListFromFile);
}
- private Map<String, Object> getToscaResourceFromFile(String fullFileName, String toscaResourceName)
- throws Exception {
+ @SuppressWarnings("unchecked")
+ private Map<String, Object> getToscaResourceFromFile(String fullFileName, String toscaResourceName) throws FileNotFoundException{
Map<String, Object> nodesTypesMap = getNodesTypesMapFromFile(fullFileName);
Map<String, Object> resourceToscaMap = (Map<String, Object>) nodesTypesMap.get(toscaResourceName);
@@ -265,17 +262,18 @@ public class ImportReqDetails extends ResourceReqDetails {
return resourceToscaMap;
}
+ @SuppressWarnings("unchecked")
private Map<String, Object> getNodesTypesMapFromFile(String fullFileName) throws FileNotFoundException {
Yaml yaml = new Yaml();
File file = new File(fullFileName);
InputStream inputStream = new FileInputStream(file);
Map<?, ?> mapFromFile = (Map<?, ?>) yaml.load(inputStream);
- Map<String, Object> nodesTypesMap = (Map<String, Object>) mapFromFile.get("node_types");
- return nodesTypesMap;
+ return (Map<String, Object>) mapFromFile.get("node_types");
}
+ @SuppressWarnings("unchecked")
private Map<String, Object> convertListToMap(List<Object> testedListFromFile) {
- Map<String, Object> testedMapFromFile = new HashMap<String, Object>();
+ Map<String, Object> testedMapFromFile = new HashMap<>();
for (int i = 0; i < testedListFromFile.size(); i++) {
Object req = testedListFromFile.get(i);
ObjectMapper m = new ObjectMapper();
@@ -285,6 +283,7 @@ public class ImportReqDetails extends ResourceReqDetails {
return testedMapFromFile;
}
+ @SuppressWarnings("unchecked")
public void compareRequirementsOrCapabilities(Map<String, Object> exepectedReq, Map<String, Object> actualReq) {
Iterator<String> iterator = exepectedReq.keySet().iterator();
while (iterator.hasNext()) {
@@ -317,14 +316,15 @@ public class ImportReqDetails extends ResourceReqDetails {
}
}
+ @SuppressWarnings("unchecked")
private List<Map<String, Object>> convertListToMapList(List<Object> testedListFromFile) {
- List<Map<String, Object>> listOfMaps = new ArrayList<Map<String, Object>>();
+ List<Map<String, Object>> listOfMaps = new ArrayList<>();
for (int i = 0; i < testedListFromFile.size(); i++) {
Object req = testedListFromFile.get(i);
ObjectMapper m = new ObjectMapper();
Map<? extends String, ? extends String> mappedObject = m.convertValue(req, Map.class);
mappedObject.remove("uniqueId");
- Map<String, Object> testedMapFromFile = new HashMap<String, Object>();
+ Map<String, Object> testedMapFromFile = new HashMap<>();
testedMapFromFile.putAll(mappedObject);
listOfMaps.add(testedMapFromFile);
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ProductReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ProductReqDetails.java
index f2484e274d..61d923e6c4 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ProductReqDetails.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ProductReqDetails.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.ci.tests.datatypes;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
+
import java.util.ArrayList;
import java.util.List;
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-
public class ProductReqDetails extends ComponentReqDetails {
private String fullName;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceExternalReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceExternalReqDetails.java
index 4d5806b90f..5a968fdcd4 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceExternalReqDetails.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceExternalReqDetails.java
@@ -20,10 +20,10 @@
package org.openecomp.sdc.ci.tests.datatypes;
-import java.util.List;
-
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import java.util.List;
+
public class ResourceExternalReqDetails extends ComponentReqDetails {
String vendorName;
String vendorRelease;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java
index e3517a8ab4..cfb7845c63 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceReqDetails.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.ci.tests.datatypes;
-import java.util.List;
-
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.Resource;
+import java.util.List;
+
public class ResourceReqDetails extends ComponentReqDetails {
List<String> derivedFrom;
String vendorName;
@@ -72,7 +72,6 @@ public class ResourceReqDetails extends ComponentReqDetails {
this.name = resource.getName();
this.description = resource.getDescription();
this.tags = resource.getTags();
- // this.category = resource.getCategories();
this.derivedFrom = resource.getDerivedFrom();
this.vendorName = resource.getVendorName();
this.vendorRelease = resource.getVendorRelease();
@@ -99,7 +98,6 @@ public class ResourceReqDetails extends ComponentReqDetails {
ResourceTypeEnum.VFC.toString());
}
- // new
public ResourceReqDetails(String resourceName, String description, List<String> tags, String category,
List<String> derivedFrom, String vendorName, String vendorRelease, String contactId, String icon,
String resourceType) {
@@ -108,7 +106,6 @@ public class ResourceReqDetails extends ComponentReqDetails {
this.name = resourceName;
this.description = description;
this.tags = tags;
- // this.category = category;
this.derivedFrom = derivedFrom;
this.vendorName = vendorName;
this.vendorRelease = vendorRelease;
@@ -128,7 +125,6 @@ public class ResourceReqDetails extends ComponentReqDetails {
this.name = originalResource.getName();
this.description = originalResource.getDescription();
this.tags = originalResource.getTags();
- // this.category = originalResource.getCategory();
this.derivedFrom = originalResource.getDerivedFrom();
this.vendorName = originalResource.getVendorName();
this.vendorRelease = originalResource.getVendorRelease();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceRespJavaObject.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceRespJavaObject.java
index a915af4eb2..78408bd3ed 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceRespJavaObject.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceRespJavaObject.java
@@ -20,10 +20,10 @@
package org.openecomp.sdc.ci.tests.datatypes;
-import java.util.List;
-
import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import java.util.List;
+
public class ResourceRespJavaObject {
String uniqueId;
String name;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java
index fbcbfd4fe0..76c17f0375 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceReqDetails.java
@@ -20,10 +20,11 @@
package org.openecomp.sdc.ci.tests.datatypes;
-import java.util.ArrayList;
-
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceInstantiationType;
+
+import java.util.ArrayList;
public class ServiceReqDetails extends ComponentReqDetails {
@@ -31,6 +32,7 @@ public class ServiceReqDetails extends ComponentReqDetails {
protected String serviceRole = "MyServiceRole";
protected String namingPolicy = "MyServiceNamingPolicy";
protected Boolean ecompGeneratedNaming = true;
+ protected String instantiationType = ServiceInstantiationType.A_LA_CARTE.getValue();
public String getServiceType() {
return serviceType;
@@ -39,7 +41,11 @@ public class ServiceReqDetails extends ComponentReqDetails {
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
-
+
+ public String getInstantiationType() {
+ return instantiationType;
+ }
+
public String getServiceRole() {
return serviceRole;
}
@@ -65,9 +71,8 @@ public class ServiceReqDetails extends ComponentReqDetails {
}
public ServiceReqDetails(String serviceName, String category, ArrayList<String> tags, String description,
- String contactId, String icon) {
+ String contactId, String icon, String instantiationType) {
this.name = serviceName;
- // this.category = category;
this.tags = tags;
this.description = description;
this.contactId = contactId;
@@ -107,13 +112,13 @@ public class ServiceReqDetails extends ComponentReqDetails {
@Override
public String toString() {
- return "ServiceDetails [name=" + name + ", category=" + getCategory() + ", tags=" + tags + ", description="
- + description + ", contactId=" + contactId + ", icon=" + icon + "]";
+ return "ServiceDetails [name = " + name + ", category = " + getCategory() + ", tags = " + tags + ", description = "
+ + description + ", contactId = " + contactId + ", icon = " + icon + ", instantiation type = " + getInstantiationType() + "]";
}
public ServiceReqDetails(ServiceReqDetails aService) {
this(aService.getName(), aService.getCategory(), (ArrayList<String>) aService.getTags(),
- aService.getDescription(), aService.getContactId(), aService.getIcon());
+ aService.getDescription(), aService.getContactId(), aService.getIcon(), aService.getInstantiationType());
uniqueId = aService.getUniqueId();
version = aService.getVersion();
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ImportTestTypesEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ImportTestTypesEnum.java
index 21901e4635..ed71faa8ce 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ImportTestTypesEnum.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ImportTestTypesEnum.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.ci.tests.datatypes.enums;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+
import java.util.Arrays;
import java.util.List;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-
public enum ImportTestTypesEnum {
MISSING_CONTACT("tosca.nodes.missing_contact", "missing_contact", ActionStatus.COMPONENT_MISSING_CONTACT, Arrays.asList("Resource"), true),
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java
index a0b13b7539..1ba6c5c7f1 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ResourceCategoryEnum.java
@@ -20,11 +20,6 @@
package org.openecomp.sdc.ci.tests.datatypes.enums;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-
import java.util.Random;
public enum ResourceCategoryEnum {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ServiceInstantiationType.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ServiceInstantiationType.java
new file mode 100644
index 0000000000..80fa95b546
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ServiceInstantiationType.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.ci.tests.datatypes.enums;
+
+public enum ServiceInstantiationType {
+ A_LA_CARTE("A-la-carte"), MACRO("Macro");
+
+ private String value;
+
+ public String getValue() {
+ return value;
+ }
+
+ private ServiceInstantiationType(String value) {
+ this.value = value;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ToscaKeysEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ToscaKeysEnum.java
index b8635b3bda..24adc49ebe 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ToscaKeysEnum.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/ToscaKeysEnum.java
@@ -22,7 +22,12 @@ package org.openecomp.sdc.ci.tests.datatypes.enums;
public enum ToscaKeysEnum {
- TOSCA_DEFINITION_VERSION("tosca_definitions_version"), METADATA("metadata"), IMPORTS("imports"), NODE_TYPES("node_types"), TOPOLOGY_TEMPLATE("topology_template");
+ TOSCA_DEFINITION_VERSION("tosca_definitions_version"),
+ METADATA("metadata"),
+ IMPORTS("imports"),
+ NODE_TYPES("node_types"),
+ TOPOLOGY_TEMPLATE("topology_template"),
+ ANNOTATION_TYPES("annotation_types");
private String toscaKey;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java
index 2435b10dd5..0e81a7b2ac 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/http/HttpRequest.java
@@ -23,7 +23,6 @@ package org.openecomp.sdc.ci.tests.datatypes.http;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpPost;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java
index 3af40c5bb8..fc0e33d3a8 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/TODO/ImportCapabilityTypeCITest.java
@@ -20,9 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.TODO;
-import java.io.File;
-import java.io.IOException;
-
+import fj.data.Either;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
@@ -39,7 +37,8 @@ import org.testng.AssertJUnit;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-import fj.data.Either;
+import java.io.File;
+import java.io.IOException;
public class ImportCapabilityTypeCITest {
public static final DbUtils DbUtils = new DbUtils();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java
index 66e450b077..c735169e77 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ArtifactServletTest.java
@@ -20,11 +20,9 @@
package org.openecomp.sdc.ci.tests.execute.artifacts;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import fj.data.Either;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpResponseException;
@@ -37,7 +35,6 @@ import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
@@ -46,11 +43,7 @@ import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
@@ -63,11 +56,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.util.GeneralUtility;
@@ -77,10 +66,10 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.Gson;
-
-import fj.data.Either;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
public class ArtifactServletTest extends ComponentBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java
index ff99a6bb10..5072f58112 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/CrudArt.java
@@ -20,30 +20,12 @@
package org.openecomp.sdc.ci.tests.execute.artifacts;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
@@ -56,12 +38,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ArtifactValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
@@ -72,6 +49,16 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import static org.testng.AssertJUnit.*;
+
public class CrudArt extends ComponentBaseTest {
private static Logger logger = LoggerFactory.getLogger(CrudArt.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java
index fb620c9b82..02bf110c8d 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/DownloadComponentArt.java
@@ -20,12 +20,11 @@
package org.openecomp.sdc.ci.tests.execute.artifacts;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import fj.data.Either;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -39,7 +38,6 @@ import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
@@ -47,26 +45,14 @@ import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
@@ -91,12 +77,11 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import fj.data.Either;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
public class DownloadComponentArt extends ComponentBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java
index bc57512a11..80e0a54ee4 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java
@@ -20,42 +20,32 @@
package org.openecomp.sdc.ci.tests.execute.artifacts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.codec.binary.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceInstantiationType;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.annotations.Test;
import org.yaml.snakeyaml.Yaml;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
public class HeatEnvArtifact extends ComponentBaseTest {
@Rule
@@ -78,7 +68,9 @@ public class HeatEnvArtifact extends ComponentBaseTest {
Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(certifyState.getResponse(), Resource.class);
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId());
+ ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(
+ "ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId(),
+ ServiceInstantiationType.A_LA_CARTE.getValue());
// 2 create service
RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifierDetails);
@@ -128,7 +120,9 @@ public class HeatEnvArtifact extends ComponentBaseTest {
Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(certifyState.getResponse(), Resource.class);
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId());
+ ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(
+ "ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId(),
+ ServiceInstantiationType.A_LA_CARTE.getValue());
// 2 create service
RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifierDetails);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java
index 02bef89f2c..b15da07139 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/PlaceHolderValidations.java
@@ -21,61 +21,38 @@
package org.openecomp.sdc.ci.tests.execute.artifacts;
//import static org.junit.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.javatuples.Pair;
+import fj.data.Either;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.cassandra.CassandraUtils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.datastax.driver.core.Row;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
-import fj.data.Either;
+import static org.testng.AssertJUnit.*;
public class PlaceHolderValidations extends ComponentBaseTest {
private static Logger logger = LoggerFactory.getLogger(PlaceHolderValidations.class.getName());
@@ -140,7 +117,7 @@ public class PlaceHolderValidations extends ComponentBaseTest {
}
}
- private void validateToscaArtifactsBeforeAndAfterSFT(ResourceReqDetails resourceDetails)
+ /*private void validateToscaArtifactsBeforeAndAfterSFT(ResourceReqDetails resourceDetails)
throws IOException, Exception {
RestResponse componentResponse = ResourceRestUtils.getResource(resourceDetails, sdncDesignerDetails1);
Component component = ResponseParser.convertResourceResponseToJavaObject(componentResponse.getResponse());
@@ -161,15 +138,15 @@ public class PlaceHolderValidations extends ComponentBaseTest {
List<Row> fetchFromTable = CassandraUtils.fetchFromTableQuery("sdcartifact", "resources", fields);
assertTrue(1 == fetchFromTable.size());
}
- }
+ }*/
- @Test
+ /*@Test
public void validateToscaArtifactsBeforeAndAfterSFT() throws IOException, Exception {
// TODO ADD VF and Service
validateToscaArtifactsBeforeAndAfterSFT(resourceDetails1);
validateToscaArtifactsBeforeAndAfterSFT(resourceCP);
validateToscaArtifactsBeforeAndAfterSFT(resourceVL);
- }
+ }*/
@Test
public void validateToscaPlaceHoldersByConfig() throws IOException, Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java
index c049211e97..be9b8b8135 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateArtResponse.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.artifacts;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition;
@@ -53,6 +46,13 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.yaml.snakeyaml.Yaml;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class ValidateArtResponse extends ComponentBaseTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java
index 8a7a2f65fa..09c4d387a2 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/ValidateHeatArtFieldsTypes.java
@@ -20,9 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.artifacts;
-import java.util.Arrays;
-import java.util.List;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -46,6 +43,9 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
+import java.util.Arrays;
+import java.util.List;
+
public class ValidateHeatArtFieldsTypes extends ComponentBaseTest {
protected User sdncDesignerDetails;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
index 537a70984e..0033e37932 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
@@ -20,12 +20,8 @@
package org.openecomp.sdc.ci.tests.execute.attribute;
-import static org.junit.Assert.assertEquals;
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.swallowException;
-
-import java.io.File;
-import java.util.function.Function;
-
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -41,8 +37,11 @@ import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import java.io.File;
+import java.util.function.Function;
+
+import static org.junit.Assert.assertEquals;
+import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.swallowException;
public class ComponentInstanceAttributeTest extends ComponentBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java
index 61c9442f44..0385bbc23f 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CatalogDataApiTest.java
@@ -20,10 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.category;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
@@ -35,10 +32,7 @@ import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
@@ -53,7 +47,9 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
public class CatalogDataApiTest extends ComponentBaseTest {
@@ -201,9 +197,10 @@ public class CatalogDataApiTest extends ComponentBaseTest {
String vendorRelease = "0.1";
String contactId = "al1976";
String icon = "myIcon";
+ String instantiationType = ServiceInstantiationType.A_LA_CARTE.getValue();
ServiceReqDetails svcdetails = new ServiceReqDetails(serviceName, category, serviceTags, description,
- contactId, icon);
+ contactId, icon, instantiationType);
return svcdetails;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java
index ade662a20c..ed41149f21 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/CategoriesTests.java
@@ -20,25 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.category;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.RESOURCE_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.SERVICE_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.lang3.text.WordUtils;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
@@ -64,6 +45,13 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.File;
+import java.util.*;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
public class CategoriesTests extends CategoriesBaseTest {
private static final String GET_CATEGORY_HIERARCHY = "GetCategoryHierarchy";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java
index ec36798bc1..3d2b3a06cf 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/ElementsApiTest.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.category;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.util.HashMap;
-import java.util.Map;
-
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
@@ -38,6 +32,12 @@ import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
import org.testng.annotations.Test;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+
public class ElementsApiTest extends ComponentBaseTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java
index 7858b3259f..b0e7bd3eff 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/GroupingTest.java
@@ -20,18 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.category;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.RESOURCE_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.SERVICE_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_NOT_FOUND;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-import static org.testng.AssertJUnit.assertEquals;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -54,6 +42,9 @@ import org.testng.SkipException;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*;
+import static org.testng.AssertJUnit.assertEquals;
+
public class GroupingTest extends CategoriesBaseTest {
protected static final String ADD_GROUPING = "AddGrouping";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java
index dd96ebfc2f..eada2b43b1 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/category/SubCategoriesTest.java
@@ -20,21 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.category;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.RESOURCE_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.SERVICE_COMPONENT_TYPE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_NOT_FOUND;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.util.ArrayList;
-import java.util.List;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -56,6 +41,12 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*;
+import static org.testng.AssertJUnit.assertEquals;
+
public class SubCategoriesTest extends ComponentBaseTest {
protected static final String ADD_SUB_CATEGORY = "AddSubCategory";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
index 586856bd72..ab6551f49e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.devCI;
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
@@ -34,6 +28,12 @@ import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinitio
import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
public class AndreyTest {
private static ToscaDefinition parseToscaYamlToJavaObject;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java
index 4cb46a3810..7a69d374eb 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java
@@ -20,6 +20,14 @@
package org.openecomp.sdc.ci.tests.execute.devCI;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition;
+import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
+import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition;
+import org.openecomp.sdc.ci.tests.utils.CsarParserUtils;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -28,25 +36,11 @@ import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition;
-import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
-import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition;
-import org.openecomp.sdc.ci.tests.utils.CsarParserUtils;
-
public class ArtifactFromCsar {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java
index 99890c1105..9e77526654 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarUpdate.java
@@ -226,7 +226,7 @@ public class ImportCsarUpdate extends ComponentBaseTest {
}
- @Test
+ /*@Test
public void updateVFsearchByCsarStartCertifaicationState() throws Exception {
ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
@@ -256,7 +256,7 @@ public class ImportCsarUpdate extends ComponentBaseTest {
resourceFirstImport.getGroups().equals(resourceSecondImport.getGroups());
- }
+ }*/
@Test
public void updateVFsearchBySystemNameCheckInState() throws Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java
index 49e5950db5..802de24d4f 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ImportCsarValidateArtifacts.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.devCI;
-import static org.testng.AssertJUnit.assertTrue;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -38,6 +36,8 @@ import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.assertTrue;
+
public class ImportCsarValidateArtifacts extends ComponentBaseTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java
index 7acf1206e7..49b13b587b 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/test1.java
@@ -20,10 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.devCI;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
+import fj.data.Either;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -32,13 +29,7 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.DistributionNotificationStatusEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
@@ -46,7 +37,9 @@ import org.openecomp.sdc.ci.tests.utils.validation.DistributionValidationUtils;
import org.openecomp.sdc.externalApis.CRUDExternalAPI;
import org.testng.annotations.Test;
-import fj.data.Either;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
public class test1 extends ComponentBaseTest{
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java
index b4a9bb87ce..7f97ca36be 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/AuthanticationTests.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.distribution;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
@@ -54,6 +47,13 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
+
public class AuthanticationTests extends ComponentBaseTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java
index e2a9207718..94715b2495 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java
@@ -20,16 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.distribution;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.ZipInputStream;
-
import org.apache.commons.codec.binary.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
@@ -53,12 +43,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ConsumerRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.util.GeneralUtility;
@@ -67,6 +52,16 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipInputStream;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+
public class DistributionDownloadArtifactTest extends ComponentBaseTest {
protected static ResourceReqDetails resourceDetails;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java
index 80b70d675e..e49c912ef4 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java
@@ -20,62 +20,35 @@
package org.openecomp.sdc.ci.tests.execute.externalapi;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.*;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.*;
public class DownloadArtifactsTest extends ComponentBaseTest {
@Rule
@@ -127,9 +100,11 @@ public class DownloadArtifactsTest extends ComponentBaseTest {
ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(),
ResourceTypeEnum.CP.toString());
serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY,
- sdncDesignerDetails.getUserId());
+ sdncDesignerDetails.getUserId(),
+ ServiceInstantiationType.A_LA_CARTE.getValue());
serviceDetails_02 = ElementFactory.getDefaultService("newtestservice2", ServiceCategoriesEnum.MOBILITY,
- sdncDesignerDetails.getUserId());
+ sdncDesignerDetails.getUserId(),
+ ServiceInstantiationType.A_LA_CARTE.getValue());
}
@Test
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java
index c3371493d9..404ed04766 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java
@@ -21,15 +21,6 @@
//US505653
package org.openecomp.sdc.ci.tests.execute.general;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.codec.binary.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
@@ -54,11 +45,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ConsumerRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.common.util.ValidationUtils;
@@ -67,6 +54,13 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.*;
+
public class BasicHttpAuthenticationTest extends ComponentBaseTest {
protected static final String AUTH_FAILED_INVALID_AUTHENTICATION_HEADER = "AUTH_FAILED_INVALID_AUTHENTICATION_HEADER";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java
index eea4e8ad5a..0934ebb4c2 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/ManageEcompConsumerCredentials.java
@@ -20,10 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.general;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.util.HashMap;
-
+import com.google.gson.Gson;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -43,7 +40,9 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.util.HashMap;
+
+import static org.testng.AssertJUnit.assertEquals;
public class ManageEcompConsumerCredentials extends ComponentBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java
index acb7e15c6c..e460614d8c 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/UuidTest.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.general;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.UUID;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
@@ -38,6 +31,13 @@ import org.openecomp.sdc.common.api.Constants;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
+import java.io.IOException;
+import java.util.List;
+import java.util.UUID;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
public class UuidTest extends ComponentBaseTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/groups/GroupsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/groups/GroupsTest.java
new file mode 100644
index 0000000000..4a2f98e588
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/groups/GroupsTest.java
@@ -0,0 +1,164 @@
+package org.openecomp.sdc.ci.tests.execute.groups;
+
+import fj.data.Either;
+import org.apache.commons.collections.MapUtils;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
+import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest;
+import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
+import org.testng.annotations.Test;
+import org.testng.collections.Lists;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.Assert.*;
+import static org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils.*;
+import static org.testng.Assert.assertNull;
+
+public class GroupsTest extends ComponentBaseTest {
+ @Rule
+ public static TestName name = new TestName();
+
+ public static final String groupName = "x_group";
+ public static final String capabilityName = "vlan_assignment";
+ public static final String propertyName = "vfc_instance_group_reference";
+ public static final String csarsFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ;
+
+ public GroupsTest() {
+ super(name, GroupsTest.class.getName());
+ }
+
+ @Test
+ public void importResourceWithGroupsTest() throws Exception {
+ importResource("with_groups.csar");
+ }
+
+ @Test
+ public void importResourceWitIncorrectCapabilityNameTest() throws Exception {
+ RestResponse createResource = getCreateResourceRestResponse(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, "incorrect_cap.csar", csarsFilePath);
+ BaseRestUtils.checkErrorResponse(createResource, ActionStatus.MISSING_CAPABILITIES,(Lists.newArrayList("vlan_assignment1")).toString(), "group", "x_group");
+ }
+
+ @Test
+ public void importResourceWithoutCapabilitiesTest() throws Exception {
+ Resource resource = importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, "without_caps.csar", csarsFilePath);
+ validateComponentGroupCapabilityPropertyValue(resource, null);
+ }
+
+ @Test
+ public void updateResourceWithGroupsTest() throws Exception {
+ Resource resource = importResource("with_groups.csar");
+ updateResource(resource, "with_groups_update.csar");
+ }
+
+ @Test
+ public void supportGroupsWithCapabilitiesServiceLevelTest() throws Exception {
+ Resource resource = importCertifiedResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, "VLANTaggingFromAmdox1303_2018.csar", csarsFilePath);
+ CapReqDef caps = ComponentInstanceRestUtils.getInstancesCapabilitiesRequirements(resource, UserRoleEnum.DESIGNER.getUserId());
+ validateVlanAssignmentGroupCapabilitiesInvisible(caps.getCapabilities());
+
+ Service service1 = createCertifiedServiceWithInstance(ServiceCategoriesEnum.MOBILITY, resource);
+ caps = ComponentInstanceRestUtils.getInstancesCapabilitiesRequirements(service1, UserRoleEnum.DESIGNER.getUserId());
+ validateVlanAssignmentGroupCapabilitiesVisible(caps.getCapabilities());
+
+ Service service2 = createCertifiedServiceWithInstance(ServiceCategoriesEnum.NETWORK_L4, resource);
+ caps = ComponentInstanceRestUtils.getInstancesCapabilitiesRequirements(service2, UserRoleEnum.DESIGNER.getUserId());
+ validateVlanAssignmentGroupCapabilitiesVisible(caps.getCapabilities());
+
+ Service serviceContainer = createCertifiedServiceWithProxyInstances(ServiceCategoriesEnum.NETWORK_L3, service1, service2);
+ caps = ComponentInstanceRestUtils.getInstancesCapabilitiesRequirements(serviceContainer, UserRoleEnum.DESIGNER.getUserId());
+ validateVlanAssignmentGroupCapabilitiesVisible(caps.getCapabilities());
+
+ assertTrue(serviceContainer.getComponentInstances()!=null);
+ }
+
+ private void validateVlanAssignmentGroupCapabilitiesVisible(Map<String, List<CapabilityDefinition>> capabilities) {
+ if(MapUtils.isNotEmpty(capabilities)){
+ validateVlanAssignmentGroupCapabilitiesVisibility(capabilities, true);
+ }
+ }
+
+ private void validateVlanAssignmentGroupCapabilitiesInvisible(Map<String, List<CapabilityDefinition>> capabilities) {
+ if(MapUtils.isNotEmpty(capabilities)){
+ validateVlanAssignmentGroupCapabilitiesVisibility(capabilities, false);
+ }
+ }
+ private void validateVlanAssignmentGroupCapabilitiesVisibility(Map<String, List<CapabilityDefinition>> capabilities, boolean shouldBeVisible) {
+ assertTrue(capabilities.containsKey("org.openecomp.capabilities.VLANAssignment") == shouldBeVisible);
+ }
+
+ private Service createCertifiedServiceWithProxyInstances(ServiceCategoriesEnum category, Service service1, Service service2) throws Exception {
+ Either<Service, RestResponse> createServiceRes = createServiceByCategory(category, UserRoleEnum.DESIGNER, true);
+ assertTrue(createServiceRes.isLeft());
+ Either<ComponentInstance, RestResponse> result = addComponentInstanceToComponentContainer(service1, createServiceRes.left().value());
+ assertTrue(result.isLeft());
+ result = addComponentInstanceToComponentContainer(service2, createServiceRes.left().value());
+ assertTrue(result.isLeft());
+ return certifyService(createServiceRes);
+ }
+
+ private Service createCertifiedServiceWithInstance(ServiceCategoriesEnum category, Resource resource) throws Exception {
+ Either<Service, RestResponse> createServiceRes = createServiceByCategory(category, UserRoleEnum.DESIGNER, true);
+ assertTrue(createServiceRes.isLeft());
+ Either<ComponentInstance, RestResponse> result = addComponentInstanceToComponentContainer(resource, createServiceRes.left().value());
+ assertTrue(result.isLeft());
+ return certifyService(createServiceRes);
+ }
+
+ private Service certifyService(Either<Service, RestResponse> serviceProxy1) throws Exception {
+ Service service = getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceProxy1.left().value().getName(), "0.1" );
+ assertNotNull(service);
+ ServiceReqDetails serviceReqDetails = new ServiceReqDetails(service);
+ RestResponse restResponseService = LCSbaseTest.certifyService(serviceReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
+ assertTrue(restResponseService.getErrorCode()==200);
+ return getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceProxy1.left().value().getName(), "1.0" );
+ }
+
+ private static Resource updateResource(Resource resource, String csarFileName) throws Exception {
+ Resource updatedResource = updateResourceFromCsar(resource, UserRoleEnum.DESIGNER, csarFileName, csarsFilePath);
+ validateComponentGroupCapabilityPropertyValue(updatedResource, "new_value");
+ return updatedResource;
+ }
+
+ private static Resource importResource(String csarFileName) throws Exception {
+ Resource resource = importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, csarFileName, csarsFilePath);
+ validateComponentGroupCapabilityPropertyValue(resource, "success");
+ return resource;
+ }
+
+ private static void validateComponentGroupCapabilityPropertyValue(Component component, String propertyValue) {
+ assertNotNull(component);
+ assertNotNull(component.getGroups());
+ assertFalse(component.getGroups().isEmpty());
+ assertTrue(component.getGroups().size() == 5);
+ Optional<GroupDefinition> vfcInstanceGroup = component.getGroups().stream().filter(g->g.getName().equals(groupName)).findFirst();
+ assertTrue(vfcInstanceGroup.isPresent());
+ assertFalse(vfcInstanceGroup.get().getCapabilities().isEmpty());
+ assertTrue(vfcInstanceGroup.get().getCapabilities().size() == 1);
+ assertNotNull(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment"));
+ assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").size() == 1);
+ assertNotNull(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0));
+ assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getName().equals(capabilityName));
+ assertNotNull(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties());
+ assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties().size() == 1);
+ assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties().get(0).getName().equals(propertyName));
+ if(propertyValue == null)
+ assertNull(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties().get(0).getValue());
+ else
+ assertTrue(vfcInstanceGroup.get().getCapabilities().get("org.openecomp.capabilities.VLANAssignment").get(0).getProperties().get(0).getValue().equals(propertyValue));
+ }
+
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java
index 6b351c12d0..56502757de 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java
@@ -20,28 +20,12 @@
package org.openecomp.sdc.ci.tests.execute.imports;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
import org.apache.commons.codec.binary.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
@@ -56,6 +40,15 @@ import org.openecomp.sdc.common.util.YamlToObjectConverter;
import org.testng.annotations.Test;
import org.yaml.snakeyaml.Yaml;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import static org.junit.Assert.*;
+
public class CsarUtilsTest extends ComponentBaseTest {
public static final String ASSET_TOSCA_TEMPLATE = "assettoscatemplate";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java
index a6088deac0..3f017f448c 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java
@@ -20,70 +20,40 @@
package org.openecomp.sdc.ci.tests.execute.imports;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
+import com.google.gson.Gson;
+import com.google.gson.JsonParser;
+import com.google.gson.reflect.TypeToken;
import org.apache.commons.codec.binary.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstInputsMap;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceInput;
-import org.openecomp.sdc.be.model.ComponentInstancePropInput;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.InputDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.InputsRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
import org.openecomp.sdc.common.api.Constants;
import org.testng.annotations.Test;
import org.yaml.snakeyaml.Yaml;
-import com.google.gson.Gson;
-import com.google.gson.JsonParser;
-import com.google.gson.reflect.TypeToken;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.*;
public class ExportToscaTest extends ComponentBaseTest {
@Rule
@@ -283,7 +253,9 @@ public class ExportToscaTest extends ComponentBaseTest {
Resource createdResource = createVfFromCSAR(sdncModifierDetails, "csar_1");
RestResponse checkinState = LifecycleRestUtils.changeComponentState(createdResource, sdncModifierDetails, LifeCycleStatesEnum.CHECKIN);
BaseRestUtils.checkSuccess(checkinState);
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId());
+ ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(
+ "ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncModifierDetails.getUserId(),
+ ServiceInstantiationType.A_LA_CARTE.getValue());
//2 create service
RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifierDetails);
@@ -377,7 +349,6 @@ public class ExportToscaTest extends ComponentBaseTest {
}
-
// ----------------------------------------
private void validateInput(InputDefinition inputDef, Map<String, Object> inputInFile) {
assertEquals("validate input type", inputDef.getType(), (String) inputInFile.get("type"));
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java
index 8ea66700cf..eed10581e2 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java
@@ -20,23 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.imports;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
+import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.WordUtils;
import org.junit.Rule;
@@ -44,46 +28,34 @@ import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.*;
import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceInstantiationType;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.GroupRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static org.testng.AssertJUnit.*;
public class ImportCsarResourceTest extends ComponentBaseTest {
private static Logger log = LoggerFactory.getLogger(ImportCsarResourceTest.class.getName());
@@ -558,10 +530,10 @@ public class ImportCsarResourceTest extends ComponentBaseTest {
LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKIN);
LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+/* lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.STARTCERTIFICATION);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
+ LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);*/
lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.CERTIFY);
LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKOUT);
@@ -1554,10 +1526,10 @@ public class ImportCsarResourceTest extends ComponentBaseTest {
LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CHECKIN);
LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
- lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+/* lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUserId, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.STARTCERTIFICATION);
- LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
+ LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);*/
lifecycleChangeResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUserId, LifeCycleStatesEnum.CERTIFY);
LifecycleRestUtils.checkSuccess(lifecycleChangeResponse);
Resource certifiedResource = ResponseParser.parseToObjectUsingMapper(lifecycleChangeResponse.getResponse(), Resource.class);
@@ -1566,7 +1538,9 @@ public class ImportCsarResourceTest extends ComponentBaseTest {
User modifier = new User();
modifier.setUserId(designerUserId);
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY, designerUserId);
+ ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(
+ "newtestservice1", ServiceCategoriesEnum.MOBILITY, designerUserId,
+ ServiceInstantiationType.A_LA_CARTE.getValue());
RestResponse serviceRes = ServiceRestUtils.createService(serviceDetails, modifier);
ResourceRestUtils.checkCreateResponse(serviceRes);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java
index 873d33979f..f10aa5da3c 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportGenericResourceCITest.java
@@ -20,22 +20,8 @@
package org.openecomp.sdc.ci.tests.execute.imports;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import com.google.gson.Gson;
+import fj.data.Either;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -53,11 +39,7 @@ import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ImportTestTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.RespJsonKeysEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.execute.TODO.ImportCapabilityTypeCITest;
@@ -74,9 +56,14 @@ import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.util.*;
+import java.util.Map.Entry;
-import fj.data.Either;
+import static org.testng.AssertJUnit.*;
public class ImportGenericResourceCITest extends ComponentBaseTest {
private static Logger log = LoggerFactory.getLogger(ImportGenericResourceCITest.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java
index 61c846242c..f529f00cf9 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java
@@ -20,18 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.imports;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpStatus;
import org.junit.Rule;
@@ -46,12 +35,7 @@ import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ImportTestTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
@@ -70,1455 +54,1458 @@ import org.openecomp.sdc.common.util.GeneralUtility;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.*;
+
+import static org.testng.AssertJUnit.*;
public class ImportNewResourceCITest extends ComponentBaseTest {
- // public static UserUtils userUtils = new UserUtils();
- // public ResourceUtils resourceUtils = new ResourceUtils();
- // public AuditValidationUtils AuditValidationUtils = new
- // AuditValidationUtils();
- // protected ArtifactUtils artifactUtils = new ArtifactUtils();
-
- protected String resourceVersion = null;
- protected String auditAction = null;
- public User sdncModifierDetails = new User();
- protected String artifactName1 = "data_artifact1.sh";
- protected String artifactName2 = "data_artifact2.sh";
- protected String interfaze = "standard";
- protected String interfaceArtifactName = "data_interface1.sh";
-
- private String SPECIAL_CHARACTERS = "~!#@~$%^*()[];:'\"|\\/";
-
- public ResourceReqDetails resourceDetails = new ResourceReqDetails();
-
- public Gson gson = new Gson();
-
- @Rule
- public static TestName name = new TestName();
-
- public ImportNewResourceCITest() {
- super(name, ImportNewResourceCITest.class.getName());
- }
-
- @BeforeMethod
- public void before() throws Exception {
-
- // init user
- sdncModifierDetails.setUserId(UserRoleEnum.ADMIN.getUserId());
- // init resource details
- resourceDetails = ElementFactory.getDefaultResource("importResource4test", NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, "jh0003");
- }
-
- @Test
- public void importAllTestResources_toValidateNewAPI() throws Exception {
-
- for (ImportTestTypesEnum currResource : ImportTestTypesEnum.values()) {
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import testResources trough newResource API
- RestResponse importResponse = ImportRestUtils.importNewResourceByName(currResource.getFolderName(),
- UserRoleEnum.ADMIN);
- System.err.println("import Resource " + "<" + currResource.getFolderName() + ">" + "response: "
- + importResponse.getErrorCode());
-
- // validate response
- ImportRestUtils.validateImportTestTypesResp(currResource, importResponse);
- if (currResource.getvalidateAudit() == true) {
- // validate audit
- // String baseVersion="0.1";
- String baseVersion = "";
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(currResource.getActionStatus().name());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
- String auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
- expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
- expectedResourceAuditJavaObject.setResourceName(currResource.getNormativeName());
- expectedResourceAuditJavaObject.setResourceType("Resource");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrVersion(baseVersion);
- expectedResourceAuditJavaObject.setPrevState("");
- // expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
- expectedResourceAuditJavaObject.setCurrState("");
- expectedResourceAuditJavaObject.setComment(null);
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- List<String> variables = (currResource.getErrorParams() != null ? currResource.getErrorParams()
- : new ArrayList<String>());
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
- AuditValidationUtils.validateAuditImport(expectedResourceAuditJavaObject, auditAction);
- }
- }
- }
-
- protected RestResponse importNewResource(UserRoleEnum userRoleEnum) throws Exception {
-
- // init user
- sdncModifierDetails.setUserId(userRoleEnum.getUserId());
- // init resource details
- resourceDetails = ElementFactory.getDefaultResource("importResource4test", NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, "jh0003");
- // clean ES DB
- DbUtils.cleanAllAudits();
- // import new resource (expected checkOut state)
- RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4test", userRoleEnum);
- return importResponse;
- }
-
- @Test(enabled = false)
- public void importUIResource() throws IOException {
- String payload = "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n"
- + " org.openecomp.resource.importResource4test:\r\n" + " derived_from: tosca.nodes.Root\r\n"
- + " description: someDesc";
-
- String encodedPayload = new String(Base64.encodeBase64(payload.getBytes()));
-
- String json = "{\r\n" + " \"resourceName\": \"importResource4test\",\r\n"
- + " \"payloadName\": \"importResource4test.yml\",\r\n"
- + " \"categories\": [{\"name\": \"Application L4+\",\"normalizedName\": \"application l4+\",\"uniqueId\": \"resourceNewCategory.application l4+\",\"subcategories\": [{\"name\": \"Web Server\"}]}],\r\n"
- + " \"description\": \"ResourceDescription\",\r\n" + " \"vendorName\": \"VendorName\",\r\n"
- + " \"vendorRelease\": \"VendorRelease\",\r\n" + " \"contactId\": \"AT1234\",\r\n"
- + " \"icon\": \"router\",\r\n" + " \"tags\": [\r\n" + " \"importResource4test\"\r\n" + " ],\r\n"
- + " \"payloadData\": \"" + encodedPayload + "\"\r\n" + "}";
-
- String md5 = GeneralUtility.calculateMD5Base64EncodedByString(json);
-
- Map<String, String> headers = new HashMap<String, String>();
- headers.put(Constants.MD5_HEADER, md5);
- headers.put(Constants.USER_ID_HEADER, UserRoleEnum.ADMIN.getUserId());
- headers.put(Constants.CONTENT_TYPE_HEADER, "application/json");
-
- String url = String.format(Urls.CREATE_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort());
-
- HttpRequest httpUtil = new HttpRequest();
- RestResponse httpSendPost = httpUtil.httpSendPost(url, json, headers);
- Integer errorCode = httpSendPost.getErrorCode();
- assertTrue(errorCode == HttpStatus.SC_CREATED);
-
- }
-
- // TODO DE171337
- @Test(enabled = false)
- public void importNewResource_suc() throws Exception {
-
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
-
- // validate response
-
- resourceVersion = "0.1";
-
- // ResourceRespJavaObject resourceRespJavaObject =
- // Convertor.constructFieldsForRespValidation(resourceDetails,
- // resourceVersion);
- // resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // ResourceValidationUtils.validateResp(importResponse,
- // resourceRespJavaObject);
- //
- // //validate get response
- //
- // RestResponse resourceGetResponse =
- // ResourceRestUtils.getResource(sdncModifierDetails, resourceVersion);
- // ResourceValidationUtils.validateResp(resourceGetResponse,
- // resourceRespJavaObject);
- Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- assertNotNull(resourceFromImport);
-
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
- resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
-
- // validate get response
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceRespJavaObject.getUniqueId());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // validate
- ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
-
- // validate audit
- resourceDetails.setVersion(resourceDetails.getVersion());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
-
- auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setStatus("201");
- expectedResourceAuditJavaObject.setDesc("OK");
- expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- @Test
- public void importNewResource_byTester_failed() throws Exception {
-
- RestResponse importResponse = importNewResource(UserRoleEnum.TESTER);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 409, importResponse.getErrorCode().intValue());
-
- }
-
- // TODO DE171337
- @Test(enabled = false)
- public void importNewResource_existInCheckout_updateVendorName_updateCategory() throws Exception {
-
- // import new resource
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in other state
- importResponse = ImportRestUtils.importNewResourceByName("importResource4testUpdateVendorNameAndCategory",
- UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue());
-
- // validate response
- Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- assertNotNull(resourceFromImport);
-
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
- resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
-
- // validate get response
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceRespJavaObject.getUniqueId());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // validate
- ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
-
- // validate audit
- resourceDetails.setVersion(resourceDetails.getVersion());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails);
-
- auditAction = "ResourceImport";
- resourceVersion = "0.1";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
- expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- @Test
- public void importNewResource_perfromByAdmin_ownedBy_diffrentUser() throws Exception {
-
- RestResponse importResponse = importNewResource(UserRoleEnum.DESIGNER);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
-
- Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- // clean audit
- DbUtils.cleanAllAudits();
-
- importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), importResponse.getErrorCode());
-
- String[] split = resourceFromImport.getLastUpdaterFullName().split(" ");
- String firstName = split[0];
- String lastName = split[1];
- List<String> variables = Arrays.asList(resourceFromImport.getName(), "resource", firstName, lastName,
- resourceFromImport.getLastUpdaterUserId());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name(), variables,
- importResponse.getResponse());
-
- }
-
- @Test
- public void importNewResource_perfromByDesigner_ownedBy_diffrentUser() throws Exception {
-
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- // clean audit
- DbUtils.cleanAllAudits();
-
- importResponse = importNewResource(UserRoleEnum.DESIGNER);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
-
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name());
- assertEquals("Check response code after adding artifact", errorInfo.getCode(), importResponse.getErrorCode());
-
- String[] split = resourceFromImport.getLastUpdaterFullName().split(" ");
- String firstName = split[0];
- String lastName = split[1];
- List<String> variables = Arrays.asList(resourceFromImport.getName(), "resource", firstName, lastName,
- resourceFromImport.getLastUpdaterUserId());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name(), variables,
- importResponse.getResponse());
-
- }
-
- @Test(enabled = false)
- public void importNewResource_nameSpace_vf() throws Exception {
- RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVF",
- UserRoleEnum.DESIGNER);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResponse.getResponse());
- assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VF));
-
- }
-
- @Test
- public void importNewResource_nameSpace_vfc() throws Exception {
- RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVFC",
- UserRoleEnum.DESIGNER);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResponse.getResponse());
- assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VFC));
- }
-
- @Test
- public void importNewResource_nameSpace_vl() throws Exception {
- RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVL",
- UserRoleEnum.DESIGNER);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResponse.getResponse());
- assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VL));
-
- }
-
- @Test
- public void importNewResource_nameSpace_cp() throws Exception {
- RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testCP",
- UserRoleEnum.DESIGNER);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
-
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResponse.getResponse());
- assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.CP));
- }
-
- @Test
- public void importNewResource_nameSpace_unknown() throws Exception {
- RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4test",
- UserRoleEnum.DESIGNER);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(importResponse.getResponse());
- assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VFC));
-
- }
-
- @Test
- public void importNewResource_MissingNameSpace() throws Exception {
- RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testMissingNameSpace",
- UserRoleEnum.DESIGNER);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 400, importResponse.getErrorCode().intValue());
-
- }
-
- // TODO DE171337
- @Test(enabled = false)
- public void importNewResource_existInCheckOut() throws Exception {
-
- // import new resource
-
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in CHECKOUT state
-
- importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue());
-
- // validate response
- Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- assertNotNull(resourceFromImport);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
- resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
-
- // validate get response
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceRespJavaObject.getUniqueId());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // validate
- ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
-
- // validate audit
- resourceDetails.setVersion(resourceDetails.getVersion());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails);
-
- auditAction = "ResourceImport";
- resourceVersion = "0.1";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
- expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- // TODO DE171337
- @Test(enabled = false)
- public void importNewResource_existIn_CheckIn_state() throws Exception {
-
- // import new resource
-
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- // checkIn resource
-
- resourceVersion = resourceDetails.getVersion();
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
-
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in CHECKIN state
-
- importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue());
-
- // validate response
- Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- assertNotNull(resourceFromImport);
-
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
- resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
-
- // validate get response
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceRespJavaObject.getUniqueId());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // validate
- ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
-
- // validate audit
- resourceDetails.setVersion(resourceDetails.getVersion());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails);
-
- resourceVersion = "0.2";
- auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
- expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- @Test
- public void importNewResource_existIn_Ready4cert_state_performByTester() throws Exception {
- // import new resource
-
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
-
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceVersion = resourceDetails.getVersion();
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- // add mandatory artifacts
- // // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // resourceGetResponse);
- resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // checkIn resource
- resourceVersion = resourceDetails.getVersion();
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
-
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(checkInResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(checkInResponse.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // req4cert resource
- RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertNotNull("check response object is not null after resource request for certification", request4cert);
- assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in CHECKIN state
- importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.TESTER);
-
- // validate response
- resourceVersion = resourceDetails.getVersion();
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- assertNotNull("check response object is not null after create resouce", importResponse);
- assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
- importResponse.getResponse());
-
- // validate audit
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
-
- String auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setResourceName("");
- expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.TESTER.getUserId());
- expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.TESTER.getUserName());
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setCurrState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrVersion("");
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
-
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- // TODO DE171337
- @Test(enabled = false)
- public void importNewResource_existIn_Ready4cert_state_performByDesigner() throws Exception {
- // import new resource
-
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
-
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceVersion = resourceDetails.getVersion();
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- // add mandatory artifacts
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // resourceGetResponse);
- resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // checkIn resource
- resourceVersion = resourceDetails.getVersion();
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
-
- // req4cert resource
- RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertNotNull("check response object is not null after resource request for certification", request4cert);
- assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in other state
- importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.DESIGNER);
-
- // validate response
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION.name());
- assertNotNull("check response object is not null after create resouce", importResponse);
- assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
- String[] split = resourceFromGet.getLastUpdaterFullName().split(" ");
- String firstName = split[0];
- String lastName = split[1];
- List<String> variables = Arrays.asList(resourceFromGet.getName(), "resource", firstName, lastName,
- resourceFromGet.getLastUpdaterUserId());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION.name(), variables,
- importResponse.getResponse());
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
- String auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.DESIGNER.getUserId());
- expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.DESIGNER.getUserName());
- expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.READY_FOR_CERTIFICATION).toString());
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState("");
- expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
- expectedResourceAuditJavaObject.setCurrVersion("");
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- // TODO DE171337
- @Test(enabled = false)
- public void importNewResource_existIn_Ready4cert_state_performByAdmin() throws Exception {
-
- // import new resource
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceVersion = resourceDetails.getVersion();
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // add mandatory artifacts
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // resourceGetResponse);
- resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // checkIn resource
- resourceVersion = resourceDetails.getVersion();
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
-
- // req4cert resource
- RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertNotNull("check response object is not null after resource request for certification", request4cert);
- assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in other state
- importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
- resourceVersion = resourceDetails.getVersion();
- // resourceVersion="0.2";
-
- // validate response
- Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- assertNotNull(resourceFromImport);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
- resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
-
- // validate get response
- resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceRespJavaObject.getUniqueId());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // validate
- ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
- auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
- expectedResourceAuditJavaObject.setStatus("200");
- expectedResourceAuditJavaObject.setDesc("OK");
- expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- @Test
- public void importNewResource_existIn_CerInProgress_state_performByTester() throws Exception {
-
- // import new resource
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceVersion = resourceDetails.getVersion();
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // add mandatory artifacts
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // resourceGetResponse);
- resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // checkIn resource
- resourceVersion = resourceDetails.getVersion();
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
-
- // req4cert resource
- RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertNotNull("check response object is not null after resource request for certification", request4cert);
- assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // startCert
- RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertNotNull("check response object is not null after resource request start certification", startCert);
- assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in other state
- importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.TESTER);
-
- // validate response
- resourceVersion = resourceDetails.getVersion();
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- assertNotNull("check response object is not null after create resouce", importResponse);
- assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
- List<String> variables = Arrays.asList();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
- importResponse.getResponse());
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
- String auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setResourceName("");
- expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.TESTER.getUserId());
- expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.TESTER.getUserName());
- expectedResourceAuditJavaObject.setPrevState("");
- expectedResourceAuditJavaObject.setCurrState("");
- expectedResourceAuditJavaObject.setPrevVersion("");
- expectedResourceAuditJavaObject.setCurrVersion("");
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
- }
-
- // TODO DE171337
- @Test(enabled = false)
- public void importNewResource_existIn_CerInProgress_state_performByDesigner() throws Exception {
-
- User sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- // import new resource
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceVersion = resourceDetails.getVersion();
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // add mandatory artifacts
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // resourceGetResponse);
- resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // checkIn resource
- resourceVersion = resourceDetails.getVersion();
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
-
- // req4cert resource
- RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertNotNull("check response object is not null after resource request for certification", request4cert);
- assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // startCert
- RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertNotNull("check response object is not null after resource request start certification", startCert);
- assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
- resourceVersion = resourceDetails.getVersion();
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in other state
- importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.DESIGNER);
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
- assertNotNull("check response object is not null after create resouce", importResponse);
- assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
- List<String> variables = Arrays.asList(resourceDetails.getName(), "resource", sdncAdminUser.getFirstName(),
- sdncAdminUser.getLastName(), sdncAdminUser.getUserId());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name(),
- variables, importResponse.getResponse());
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
- String auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.DESIGNER.getUserId());
- expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.DESIGNER.getUserName());
- expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.CERTIFICATION_IN_PROGRESS).toString());
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState("");
- expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
- expectedResourceAuditJavaObject.setCurrVersion("");
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- // TODO DE171337
- @Test(enabled = false)
- public void importNewResource_existIn_CerInProgress_state_performByAdmin() throws Exception {
-
- User sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // import new resource
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceVersion = resourceDetails.getVersion();
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
-
- // add mandatory artifacts
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // resourceGetResponse);
- resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // checkIn resource
- resourceVersion = resourceDetails.getVersion();
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
-
- // req4cert resource
- RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertNotNull("check response object is not null after resource request for certification", request4cert);
- assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- // startCert
- RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertNotNull("check response object is not null after resource request start certification", startCert);
- assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
- resourceVersion = resourceDetails.getVersion();
-
- // clean audit
- DbUtils.cleanAllAudits();
-
- // import new resource while resource already exist in other state
- importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN);
-
- // validate response
- ErrorInfo errorInfo = ErrorValidationUtils
- .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
- assertNotNull("check response object is not null after create resouce", importResponse);
- assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
- assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
- List<String> variables = Arrays.asList(resourceDetails.getName(), "resource", sdncAdminUser.getFirstName(),
- sdncAdminUser.getLastName(), sdncAdminUser.getUserId());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name(),
- variables, importResponse.getResponse());
-
- // validate audit
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
- .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
- String auditAction = "ResourceImport";
- expectedResourceAuditJavaObject.setAction(auditAction);
- expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
- expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
- expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.CERTIFICATION_IN_PROGRESS).toString());
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState("");
- expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
- expectedResourceAuditJavaObject.setCurrVersion("");
- expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
- expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
- String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
- expectedResourceAuditJavaObject.setDesc(auditDesc);
- AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
-
- }
-
- // TODO DE171337
- // @Test(enabled = false)
- // public void
- // importNewResource_existIn_Certified_state_chnage_reqAndCap_byDesigner()
- // throws Exception{
- //
- // // Andrey - set default artifact details
- // ArtifactDefinition artifactDefinition =
- // artifactUtils.constructDefaultArtifactInfo();
- //
- // // import new resource
- // RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
- // assertNotNull("check response object is not null after import resource",
- // importResponse);
- // assertNotNull("check error code exists in response after import
- // resource", importResponse.getErrorCode());
- // assertEquals("Check response code after import resource", 201,
- // importResponse.getErrorCode().intValue());
- // String resourceId =
- // ResponseParser.getUniqueIdFromResponse(importResponse);
- // resourceDetails =
- // ResponseParser.parseToObject(importResponse.getResponse(),
- // ResourceReqDetails.class);
- // resourceVersion = resourceDetails.getVersion();
- // RestResponse resourceGetResponse =
- // ResourceRestUtils.getResource(sdncModifierDetails,
- // resourceDetails.getUniqueId());
- // assertEquals("Check response code after get resource", 200,
- // resourceGetResponse.getErrorCode().intValue());
- // Resource resourceFromGet =
- // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- // assertNotNull(resourceFromGet);
- //
- // // add mandatory artifacts
- // // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // resourceGetResponse);
- // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- // resourceDetails.getUniqueId());
- // assertEquals("Check response code after get resource", 200,
- // resourceGetResponse.getErrorCode().intValue());
- // resourceFromGet =
- // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- // assertNotNull(resourceFromGet);
- // resourceDetails =
- // ResponseParser.parseToObject(importResponse.getResponse(),
- // ResourceReqDetails.class);
- // resourceDetails.setVersion(resourceFromGet.getVersion());
- //
- // // add artifact
- // artifactDefinition.setArtifactName(artifactName1);
- // ArtifactRestUtils.addInformationalArtifactToResource(resourceDetails,
- // sdncModifierDetails, resourceVersion , artifactDefinition);
- //
- // // add artifact
- // artifactDefinition.setArtifactName(artifactName2);
- // resourceUtils.add_artifact(resourceDetails, sdncModifierDetails,
- // resourceVersion , artifactDefinition);
- //
- // // add interface
- // artifactDefinition.setArtifactName(interfaceArtifactName);
- // ResourceRestUtils.add_interface(resourceDetails, sdncModifierDetails,
- // resourceVersion , artifactDefinition);
- //
- // //construct fields for validation
- // resourceVersion="1.0";
- //
- // ResourceRespJavaObject resourceRespJavaObject =
- // Convertor.constructFieldsForRespValidation(resourceDetails,
- // resourceVersion);
- // ArrayList<String> artifacts = new ArrayList<String>();
- //
- // artifacts.add(resourceId+":"+artifactName1);
- // artifacts.add(resourceId+":"+artifactName2);
- // resourceRespJavaObject.setArtifacts(artifacts);
- // ArrayList<String> interfaces = new ArrayList<String>();
- //
- // interfaces.add(interfaze);
- // resourceRespJavaObject.setInterfaces(interfaces);
- //
- // // checkIn resource
- // resourceVersion = resourceDetails.getVersion();
- // String checkinComment = "good checkin";
- // String checkinComentJson = "{\"userRemarks\": \""+checkinComment+"\"}";
- // RestResponse checkInResponse =
- // LifecycleRestUtils.changeResourceState(resourceDetails,
- // sdncModifierDetails, resourceVersion, LifeCycleStatesEnum.CHECKIN,
- // checkinComentJson);
- // assertNotNull("check response object is not null after import resource",
- // checkInResponse);
- // assertEquals("Check response code after checkout resource", 200,
- // checkInResponse.getErrorCode().intValue());
- //
- // // req4cert resource
- // RestResponse request4cert =
- // LifecycleRestUtils.changeResourceState(resourceDetails,
- // sdncModifierDetails, resourceVersion,
- // LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- // assertNotNull("check response object is not null after resource request
- // for certification", request4cert);
- // assertEquals("Check response code after checkout resource", 200,
- // request4cert.getErrorCode().intValue());
- // resourceFromGet =
- // ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
- // assertNotNull(resourceFromGet);
- // resourceDetails =
- // ResponseParser.parseToObject(request4cert.getResponse(),
- // ResourceReqDetails.class);
- // resourceDetails.setVersion(resourceFromGet.getVersion());
- //
- // // startCert
- // RestResponse startCert =
- // LifecycleRestUtils.changeResourceState(resourceDetails,
- // sdncModifierDetails, resourceVersion,
- // LifeCycleStatesEnum.STARTCERTIFICATION);
- // assertNotNull("check response object is not null after resource request
- // start certification", startCert);
- // assertEquals("Check response code after checkout resource", 200,
- // startCert.getErrorCode().intValue());
- // resourceFromGet =
- // ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
- // assertNotNull(resourceFromGet);
- // resourceDetails = ResponseParser.parseToObject(startCert.getResponse(),
- // ResourceReqDetails.class);
- // resourceDetails.setVersion(resourceFromGet.getVersion());
- //
- // // certify
- // RestResponse certify =
- // LifecycleRestUtils.changeResourceState(resourceDetails,
- // sdncModifierDetails, resourceVersion, LifeCycleStatesEnum.CERTIFY);
- // assertNotNull("check response object is not null after resource request
- // certify", certify);
- // assertEquals("Check response code after certify resource", 200,
- // certify.getErrorCode().intValue());
- // resourceFromGet =
- // ResponseParser.convertResourceResponseToJavaObject(certify.getResponse());
- // assertNotNull(resourceFromGet);
- // resourceDetails = ResponseParser.parseToObject(certify.getResponse(),
- // ResourceReqDetails.class);
- // resourceDetails.setVersion(resourceFromGet.getVersion());
- //
- // // clean audit
- // DbUtils.cleanAllAudits();
- //
- // // change resource details
- //
- // // import new resource while resource already exist in other state
- // importResponse =
- // ImportRestUtils.importNewResourceByName("importResource4testUpdateWithoutReqCap",
- // UserRoleEnum.ADMIN);
- // assertNotNull("check response object is not null after import resource",
- // importResponse);
- // assertNotNull("check error code exists in response after import
- // resource", importResponse.getErrorCode());
- // assertEquals("Check response code after import resource", 200,
- // importResponse.getErrorCode().intValue());
- // resourceDetails =
- // ResponseParser.parseToObject(importResponse.getResponse(),
- // ResourceReqDetails.class);
- // resourceVersion = resourceDetails.getVersion();
- // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- // resourceDetails.getUniqueId());
- // assertEquals("Check response code after get resource", 200,
- // resourceGetResponse.getErrorCode().intValue());
- // resourceFromGet =
- // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- // assertNotNull(resourceFromGet);
- //
- // // validate response
- // Resource resourceFromImport =
- // ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
- // assertNotNull(resourceFromImport);
- //
- // resourceDetails =
- // ResponseParser.parseToObject(importResponse.getResponse(),
- // ResourceReqDetails.class);
- // resourceRespJavaObject =
- // Convertor.constructFieldsForRespValidation(resourceDetails);
- // resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- //
- // // validate get response
- // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- // resourceRespJavaObject.getUniqueId());
- // resourceFromGet =
- // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- // assertNotNull(resourceFromGet);
- //
- // // validate
- // ResourceValidationUtils.validateModelObjects(resourceFromImport,
- // resourceFromGet);
- //
- // // validate audit
- // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
- // Convertor.constructFieldsForAuditValidation(resourceDetails,
- // resourceVersion);
- // auditAction="ResourceImport";
- // expectedResourceAuditJavaObject.setAction(auditAction);
- // expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- // expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
- // expectedResourceAuditJavaObject.setStatus("200");
- // expectedResourceAuditJavaObject.setDesc("OK");
- // expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
- // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
- // auditAction, null, false);
- // }
-
- @Test
- public void importNewResource_uuidTest() throws Exception {
- RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
-
- assertNotNull("check response object is not null after import resource", importResponse);
- assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
- assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
- String oldUuid = ResponseParser.getValueFromJsonResponse(importResponse.getResponse(), "uuid");
-
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceVersion = resourceDetails.getVersion();
- RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- Resource resourceFromGet = ResponseParser
- .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- // add mandatory artifacts
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // resourceGetResponse);
- resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
- assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- "0.1", LifeCycleStatesEnum.CHECKIN);
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
-
- String newUuid = ResponseParser.getValueFromJsonResponse(checkInResponse.getResponse(), "uuid");
- assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid));
-
- // req4cert resource
- RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertNotNull("check response object is not null after resource request for certification", request4cert);
- assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- String newUuid2 = ResponseParser.getValueFromJsonResponse(request4cert.getResponse(), "uuid");
- assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid2));
-
- // startCert
- RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertNotNull("check response object is not null after resource request start certification", startCert);
- assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue());
- resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
- assertNotNull(resourceFromGet);
- resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class);
- resourceDetails.setVersion(resourceFromGet.getVersion());
-
- String newUuid3 = ResponseParser.getValueFromJsonResponse(startCert.getResponse(), "uuid");
- assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid3));
-
- RestResponse certify = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, "0.1",
- LifeCycleStatesEnum.CERTIFY);
- assertNotNull("check response object is not null after import resource", certify);
- assertEquals("Check response code after checkout resource", 200, certify.getErrorCode().intValue());
-
- String newUuid4 = ResponseParser.getValueFromJsonResponse(certify.getResponse(), "uuid");
- assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid4));
-
- RestResponse checkoutResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- "1.0", LifeCycleStatesEnum.CHECKOUT);
- assertNotNull("check response object is not null after import resource", checkInResponse);
- assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
-
- String newUuid5 = ResponseParser.getValueFromJsonResponse(checkoutResponse.getResponse(), "uuid");
- assertFalse(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid5));
- }
-
- @Test
- public void importNewResource_propertiesMapInternalUrlCredential() throws Exception {
- String folderName = "validateProporties_typeMap_valueUrlCredential";
- RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER);
-
- Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class);
-
- List<PropertyDefinition> properties = resource.getProperties();
- assertEquals("check properties size", 3, properties.size());
-
- PropertyDefinition propertyDefinition = properties.stream().filter(p -> p.getName().equals("validation_test"))
- .findFirst().get();
- String defaultValue = propertyDefinition.getDefaultValue();
-
- Map mapValue = gson.fromJson(defaultValue, Map.class);
- assertEquals("check Map value size", 2, mapValue.size());
- checkMapValues(mapValue, "key", 1, null);
- checkMapValues(mapValue, "key", 2, null);
-
- System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode());
-
- }
-
- @Test
- public void importNewResource_propertiesListInternalUrlCredential() throws Exception {
- String folderName = "validateProporties_typeList_valueUrlCredential";
- RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER);
-
- Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class);
-
- List<PropertyDefinition> properties = resource.getProperties();
- assertEquals("check properties size", 3, properties.size());
-
- PropertyDefinition propertyDefinition = properties.stream().filter(p -> p.getName().equals("validation_test"))
- .findFirst().get();
- String defaultValue = propertyDefinition.getDefaultValue();
-
- List listValue = gson.fromJson(defaultValue, List.class);
- assertEquals("check List value size", 2, listValue.size());
- checkListValues(listValue.get(0), 1, SPECIAL_CHARACTERS);
- checkListValues(listValue.get(1), 2, SPECIAL_CHARACTERS);
-
- // Verify attributes
- List<PropertyDefinition> attributes = resource.getAttributes();
+ // public static UserUtils userUtils = new UserUtils();
+ // public ResourceUtils resourceUtils = new ResourceUtils();
+ // public AuditValidationUtils AuditValidationUtils = new
+ // AuditValidationUtils();
+ // protected ArtifactUtils artifactUtils = new ArtifactUtils();
+
+ protected String resourceVersion = null;
+ protected String auditAction = null;
+ public User sdncModifierDetails = new User();
+ protected String artifactName1 = "data_artifact1.sh";
+ protected String artifactName2 = "data_artifact2.sh";
+ protected String interfaze = "standard";
+ protected String interfaceArtifactName = "data_interface1.sh";
+
+ private String SPECIAL_CHARACTERS = "~!#@~$%^*()[];:'\"|\\/";
+
+ public ResourceReqDetails resourceDetails = new ResourceReqDetails();
+
+ public Gson gson = new Gson();
+
+ @Rule
+ public static TestName name = new TestName();
+
+ public ImportNewResourceCITest() {
+ super(name, ImportNewResourceCITest.class.getName());
+ }
+
+ @BeforeMethod
+ public void before() throws Exception {
+
+ // init user
+ sdncModifierDetails.setUserId(UserRoleEnum.ADMIN.getUserId());
+ // init resource details
+ resourceDetails = ElementFactory.getDefaultResource("importResource4test", NormativeTypesEnum.ROOT,
+ ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, "jh0003");
+ }
+
+ @Test
+ public void importAllTestResources_toValidateNewAPI() throws Exception {
+
+ for (ImportTestTypesEnum currResource : ImportTestTypesEnum.values()) {
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import testResources trough newResource API
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName(currResource.getFolderName(),
+ UserRoleEnum.ADMIN);
+ System.err.println("import Resource " + "<" + currResource.getFolderName() + ">" + "response: "
+ + importResponse.getErrorCode());
+
+ // validate response
+ ImportRestUtils.validateImportTestTypesResp(currResource, importResponse);
+ if (currResource.getvalidateAudit() == true) {
+ // validate audit
+ // String baseVersion="0.1";
+ String baseVersion = "";
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(currResource.getActionStatus().name());
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
+ String auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
+ expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
+ expectedResourceAuditJavaObject.setResourceName(currResource.getNormativeName());
+ expectedResourceAuditJavaObject.setResourceType("Resource");
+ expectedResourceAuditJavaObject.setPrevVersion("");
+ expectedResourceAuditJavaObject.setCurrVersion(baseVersion);
+ expectedResourceAuditJavaObject.setPrevState("");
+ // expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
+ expectedResourceAuditJavaObject.setCurrState("");
+ expectedResourceAuditJavaObject.setComment(null);
+ expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
+ List<String> variables = (currResource.getErrorParams() != null ? currResource.getErrorParams()
+ : new ArrayList<String>());
+ String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
+ expectedResourceAuditJavaObject.setDesc(auditDesc);
+ AuditValidationUtils.validateAuditImport(expectedResourceAuditJavaObject, auditAction);
+ }
+ }
+ }
+
+ protected RestResponse importNewResource(UserRoleEnum userRoleEnum) throws Exception {
+
+ // init user
+ sdncModifierDetails.setUserId(userRoleEnum.getUserId());
+ // init resource details
+ resourceDetails = ElementFactory.getDefaultResource("importResource4test", NormativeTypesEnum.ROOT,
+ ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, "jh0003");
+ // clean ES DB
+ DbUtils.cleanAllAudits();
+ // import new resource (expected checkOut state)
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4test", userRoleEnum);
+ return importResponse;
+ }
+
+ @Test(enabled = false)
+ public void importUIResource() throws IOException {
+ String payload = "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n"
+ + " org.openecomp.resource.importResource4test:\r\n" + " derived_from: tosca.nodes.Root\r\n"
+ + " description: someDesc";
+
+ String encodedPayload = new String(Base64.encodeBase64(payload.getBytes()));
+
+ String json = "{\r\n" + " \"resourceName\": \"importResource4test\",\r\n"
+ + " \"payloadName\": \"importResource4test.yml\",\r\n"
+ + " \"categories\": [{\"name\": \"Application L4+\",\"normalizedName\": \"application l4+\",\"uniqueId\": \"resourceNewCategory.application l4+\",\"subcategories\": [{\"name\": \"Web Server\"}]}],\r\n"
+ + " \"description\": \"ResourceDescription\",\r\n" + " \"vendorName\": \"VendorName\",\r\n"
+ + " \"vendorRelease\": \"VendorRelease\",\r\n" + " \"contactId\": \"AT1234\",\r\n"
+ + " \"icon\": \"router\",\r\n" + " \"tags\": [\r\n" + " \"importResource4test\"\r\n" + " ],\r\n"
+ + " \"payloadData\": \"" + encodedPayload + "\"\r\n" + "}";
+
+ String md5 = GeneralUtility.calculateMD5Base64EncodedByString(json);
+
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put(Constants.MD5_HEADER, md5);
+ headers.put(Constants.USER_ID_HEADER, UserRoleEnum.ADMIN.getUserId());
+ headers.put(Constants.CONTENT_TYPE_HEADER, "application/json");
+
+ String url = String.format(Urls.CREATE_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort());
+
+ HttpRequest httpUtil = new HttpRequest();
+ RestResponse httpSendPost = httpUtil.httpSendPost(url, json, headers);
+ Integer errorCode = httpSendPost.getErrorCode();
+ assertTrue(errorCode == HttpStatus.SC_CREATED);
+
+ }
+
+ // TODO DE171337
+ @Test(enabled = false)
+ public void importNewResource_suc() throws Exception {
+
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+
+ // validate response
+
+ resourceVersion = "0.1";
+
+ // ResourceRespJavaObject resourceRespJavaObject =
+ // Convertor.constructFieldsForRespValidation(resourceDetails,
+ // resourceVersion);
+ // resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ // ResourceValidationUtils.validateResp(importResponse,
+ // resourceRespJavaObject);
+ //
+ // //validate get response
+ //
+ // RestResponse resourceGetResponse =
+ // ResourceRestUtils.getResource(sdncModifierDetails, resourceVersion);
+ // ResourceValidationUtils.validateResp(resourceGetResponse,
+ // resourceRespJavaObject);
+ Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertNotNull(resourceFromImport);
+
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
+ resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+
+ // validate get response
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceRespJavaObject.getUniqueId());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // validate
+ ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
+
+ // validate audit
+ resourceDetails.setVersion(resourceDetails.getVersion());
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
+
+ auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setPrevState("");
+ expectedResourceAuditJavaObject.setPrevVersion("");
+ expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setStatus("201");
+ expectedResourceAuditJavaObject.setDesc("OK");
+ expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+
+ }
+
+ @Test
+ public void importNewResource_byTester_failed() throws Exception {
+
+ RestResponse importResponse = importNewResource(UserRoleEnum.TESTER);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 409, importResponse.getErrorCode().intValue());
+
+ }
+
+ // TODO DE171337
+ @Test(enabled = false)
+ public void importNewResource_existInCheckout_updateVendorName_updateCategory() throws Exception {
+
+ // import new resource
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in other state
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4testUpdateVendorNameAndCategory",
+ UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue());
+
+ // validate response
+ Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertNotNull(resourceFromImport);
+
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
+ resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+
+ // validate get response
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceRespJavaObject.getUniqueId());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // validate
+ ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
+
+ // validate audit
+ resourceDetails.setVersion(resourceDetails.getVersion());
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails);
+
+ auditAction = "ResourceImport";
+ resourceVersion = "0.1";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
+ expectedResourceAuditJavaObject.setStatus("200");
+ expectedResourceAuditJavaObject.setDesc("OK");
+ expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+ }
+
+ @Test
+ public void importNewResource_perfromByAdmin_ownedBy_diffrentUser() throws Exception {
+
+ RestResponse importResponse = importNewResource(UserRoleEnum.DESIGNER);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+
+ Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+
+ ErrorInfo errorInfo = ErrorValidationUtils
+ .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name());
+ assertEquals("Check response code after adding artifact", errorInfo.getCode(), importResponse.getErrorCode());
+
+ String[] split = resourceFromImport.getLastUpdaterFullName().split(" ");
+ String firstName = split[0];
+ String lastName = split[1];
+ List<String> variables = Arrays.asList(resourceFromImport.getName(), "resource", firstName, lastName,
+ resourceFromImport.getLastUpdaterUserId());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name(), variables,
+ importResponse.getResponse());
+
+ }
+
+ @Test
+ public void importNewResource_perfromByDesigner_ownedBy_diffrentUser() throws Exception {
+
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ importResponse = importNewResource(UserRoleEnum.DESIGNER);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+
+ ErrorInfo errorInfo = ErrorValidationUtils
+ .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name());
+ assertEquals("Check response code after adding artifact", errorInfo.getCode(), importResponse.getErrorCode());
+
+ String[] split = resourceFromImport.getLastUpdaterFullName().split(" ");
+ String firstName = split[0];
+ String lastName = split[1];
+ List<String> variables = Arrays.asList(resourceFromImport.getName(), "resource", firstName, lastName,
+ resourceFromImport.getLastUpdaterUserId());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CHECKOUT_STATE.name(), variables,
+ importResponse.getResponse());
+
+ }
+
+ @Test(enabled = false)
+ public void importNewResource_nameSpace_vf() throws Exception {
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVF",
+ UserRoleEnum.DESIGNER);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ Resource resourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VF));
+
+ }
+
+ @Test
+ public void importNewResource_nameSpace_vfc() throws Exception {
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVFC",
+ UserRoleEnum.DESIGNER);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ Resource resourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VFC));
+ }
+
+ @Test
+ public void importNewResource_nameSpace_vl() throws Exception {
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testVL",
+ UserRoleEnum.DESIGNER);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ Resource resourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VL));
+
+ }
+
+ @Test
+ public void importNewResource_nameSpace_cp() throws Exception {
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testCP",
+ UserRoleEnum.DESIGNER);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+
+ Resource resourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.CP));
+ }
+
+ @Test
+ public void importNewResource_nameSpace_unknown() throws Exception {
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4test",
+ UserRoleEnum.DESIGNER);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ Resource resourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertTrue(resourceRespJavaObject.getResourceType().equals(ResourceTypeEnum.VFC));
+
+ }
+
+ @Test
+ public void importNewResource_MissingNameSpace() throws Exception {
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName("importResource4testMissingNameSpace",
+ UserRoleEnum.DESIGNER);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 400, importResponse.getErrorCode().intValue());
+
+ }
+
+ // TODO DE171337
+ @Test(enabled = false)
+ public void importNewResource_existInCheckOut() throws Exception {
+
+ // import new resource
+
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in CHECKOUT state
+
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue());
+
+ // validate response
+ Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertNotNull(resourceFromImport);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
+ resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+
+ // validate get response
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceRespJavaObject.getUniqueId());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // validate
+ ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
+
+ // validate audit
+ resourceDetails.setVersion(resourceDetails.getVersion());
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails);
+
+ auditAction = "ResourceImport";
+ resourceVersion = "0.1";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
+ expectedResourceAuditJavaObject.setStatus("200");
+ expectedResourceAuditJavaObject.setDesc("OK");
+ expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+ }
+
+ // TODO DE171337
+ @Test(enabled = false)
+ public void importNewResource_existIn_CheckIn_state() throws Exception {
+
+ // import new resource
+
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ // checkIn resource
+
+ resourceVersion = resourceDetails.getVersion();
+ String checkinComment = "good checkin";
+ String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
+ RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in CHECKIN state
+
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue());
+
+ // validate response
+ Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertNotNull(resourceFromImport);
+
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
+ resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+
+ // validate get response
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceRespJavaObject.getUniqueId());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // validate
+ ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
+
+ // validate audit
+ resourceDetails.setVersion(resourceDetails.getVersion());
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails);
+
+ resourceVersion = "0.2";
+ auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
+ expectedResourceAuditJavaObject.setStatus("200");
+ expectedResourceAuditJavaObject.setDesc("OK");
+ expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+ }
+
+ /* @Test
+ public void importNewResource_existIn_Ready4cert_state_performByTester() throws Exception {
+ // import new resource
+
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceVersion = resourceDetails.getVersion();
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ // add mandatory artifacts
+ // // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // resourceGetResponse);
+ resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // checkIn resource
+ resourceVersion = resourceDetails.getVersion();
+ String checkinComment = "good checkin";
+ String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
+ RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(checkInResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(checkInResponse.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // req4cert resource
+ RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertNotNull("check response object is not null after resource request for certification", request4cert);
+ assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in CHECKIN state
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.TESTER);
+
+ // validate response
+ resourceVersion = resourceDetails.getVersion();
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
+ assertNotNull("check response object is not null after create resouce", importResponse);
+ assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
+ assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
+ List<String> variables = Arrays.asList();
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
+ importResponse.getResponse());
+
+ // validate audit
+
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
+
+ String auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setResourceName("");
+ expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.TESTER.getUserId());
+ expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.TESTER.getUserName());
+ expectedResourceAuditJavaObject.setPrevState("");
+ expectedResourceAuditJavaObject.setCurrState("");
+ expectedResourceAuditJavaObject.setPrevVersion("");
+ expectedResourceAuditJavaObject.setCurrVersion("");
+ expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
+ String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
+ expectedResourceAuditJavaObject.setDesc(auditDesc);
+
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+ }*/
+
+ /* // TODO DE171337
+ @Test(enabled = false)
+ public void importNewResource_existIn_Ready4cert_state_performByDesigner() throws Exception {
+ // import new resource
+
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceVersion = resourceDetails.getVersion();
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ // add mandatory artifacts
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // resourceGetResponse);
+ resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // checkIn resource
+ resourceVersion = resourceDetails.getVersion();
+ String checkinComment = "good checkin";
+ String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
+ RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+
+ // req4cert resource
+ RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertNotNull("check response object is not null after resource request for certification", request4cert);
+ assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in other state
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.DESIGNER);
+
+ // validate response
+ ErrorInfo errorInfo = ErrorValidationUtils
+ .parseErrorConfigYaml(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION.name());
+ assertNotNull("check response object is not null after create resouce", importResponse);
+ assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
+ assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
+ String[] split = resourceFromGet.getLastUpdaterFullName().split(" ");
+ String firstName = split[0];
+ String lastName = split[1];
+ List<String> variables = Arrays.asList(resourceFromGet.getName(), "resource", firstName, lastName,
+ resourceFromGet.getLastUpdaterUserId());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION.name(), variables,
+ importResponse.getResponse());
+
+ // validate audit
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
+ String auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.DESIGNER.getUserId());
+ expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.DESIGNER.getUserName());
+ expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.READY_FOR_CERTIFICATION).toString());
+ // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setCurrState("");
+ expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
+ expectedResourceAuditJavaObject.setCurrVersion("");
+ expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
+ expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+ String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
+ expectedResourceAuditJavaObject.setDesc(auditDesc);
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+
+ }*/
+
+ /*// TODO DE171337
+ @Test(enabled = false)
+ public void importNewResource_existIn_Ready4cert_state_performByAdmin() throws Exception {
+
+ // import new resource
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceVersion = resourceDetails.getVersion();
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // add mandatory artifacts
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // resourceGetResponse);
+ resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // checkIn resource
+ resourceVersion = resourceDetails.getVersion();
+ String checkinComment = "good checkin";
+ String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
+ RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+
+ // req4cert resource
+ RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertNotNull("check response object is not null after resource request for certification", request4cert);
+ assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in other state
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 200, importResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+ resourceVersion = resourceDetails.getVersion();
+ // resourceVersion="0.2";
+
+ // validate response
+ Resource resourceFromImport = ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ assertNotNull(resourceFromImport);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ ResourceRespJavaObject resourceRespJavaObject = Convertor.constructFieldsForRespValidation(resourceDetails);
+ resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+
+ // validate get response
+ resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceRespJavaObject.getUniqueId());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // validate
+ ResourceValidationUtils.validateModelObjects(resourceFromImport, resourceFromGet);
+
+ // validate audit
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
+ auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
+ expectedResourceAuditJavaObject.setStatus("200");
+ expectedResourceAuditJavaObject.setDesc("OK");
+ expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+ }*/
+
+ /* @Test
+ public void importNewResource_existIn_CerInProgress_state_performByTester() throws Exception {
+
+ // import new resource
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceVersion = resourceDetails.getVersion();
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // add mandatory artifacts
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // resourceGetResponse);
+ resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // checkIn resource
+ resourceVersion = resourceDetails.getVersion();
+ String checkinComment = "good checkin";
+ String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
+ RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+
+ // req4cert resource
+ RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertNotNull("check response object is not null after resource request for certification", request4cert);
+ assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // startCert
+ RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertNotNull("check response object is not null after resource request start certification", startCert);
+ assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in other state
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.TESTER);
+
+ // validate response
+ resourceVersion = resourceDetails.getVersion();
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
+ assertNotNull("check response object is not null after create resouce", importResponse);
+ assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
+ assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
+ List<String> variables = Arrays.asList();
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
+ importResponse.getResponse());
+
+ // validate audit
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
+ String auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setResourceName("");
+ expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.TESTER.getUserId());
+ expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.TESTER.getUserName());
+ expectedResourceAuditJavaObject.setPrevState("");
+ expectedResourceAuditJavaObject.setCurrState("");
+ expectedResourceAuditJavaObject.setPrevVersion("");
+ expectedResourceAuditJavaObject.setCurrVersion("");
+ expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
+ String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
+ expectedResourceAuditJavaObject.setDesc(auditDesc);
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+ }*/
+
+ /*// TODO DE171337
+ @Test(enabled = false)
+ public void importNewResource_existIn_CerInProgress_state_performByDesigner() throws Exception {
+
+ User sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ // import new resource
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceVersion = resourceDetails.getVersion();
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // add mandatory artifacts
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // resourceGetResponse);
+ resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // checkIn resource
+ resourceVersion = resourceDetails.getVersion();
+ String checkinComment = "good checkin";
+ String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
+ RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+
+ // req4cert resource
+ RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertNotNull("check response object is not null after resource request for certification", request4cert);
+ assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // startCert
+ RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertNotNull("check response object is not null after resource request start certification", startCert);
+ assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+ resourceVersion = resourceDetails.getVersion();
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in other state
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.DESIGNER);
+ ErrorInfo errorInfo = ErrorValidationUtils
+ .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
+ assertNotNull("check response object is not null after create resouce", importResponse);
+ assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
+ assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
+ List<String> variables = Arrays.asList(resourceDetails.getName(), "resource", sdncAdminUser.getFirstName(),
+ sdncAdminUser.getLastName(), sdncAdminUser.getUserId());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name(),
+ variables, importResponse.getResponse());
+
+ // validate audit
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
+ String auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.DESIGNER.getUserId());
+ expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.DESIGNER.getUserName());
+ expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.CERTIFICATION_IN_PROGRESS).toString());
+ // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setCurrState("");
+ expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
+ expectedResourceAuditJavaObject.setCurrVersion("");
+ expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
+ expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+ String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
+ expectedResourceAuditJavaObject.setDesc(auditDesc);
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+
+ }*/
+
+ /* // TODO DE171337
+ @Test(enabled = false)
+ public void importNewResource_existIn_CerInProgress_state_performByAdmin() throws Exception {
+
+ User sdncAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+
+ // import new resource
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceVersion = resourceDetails.getVersion();
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+
+ // add mandatory artifacts
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // resourceGetResponse);
+ resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // checkIn resource
+ resourceVersion = resourceDetails.getVersion();
+ String checkinComment = "good checkin";
+ String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
+ RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+
+ // req4cert resource
+ RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertNotNull("check response object is not null after resource request for certification", request4cert);
+ assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ // startCert
+ RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertNotNull("check response object is not null after resource request start certification", startCert);
+ assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+ resourceVersion = resourceDetails.getVersion();
+
+ // clean audit
+ DbUtils.cleanAllAudits();
+
+ // import new resource while resource already exist in other state
+ importResponse = ImportRestUtils.importNewResourceByName("importResource4test", UserRoleEnum.ADMIN);
+
+ // validate response
+ ErrorInfo errorInfo = ErrorValidationUtils
+ .parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
+ assertNotNull("check response object is not null after create resouce", importResponse);
+ assertNotNull("check error code exists in response after create resource", importResponse.getErrorCode());
+ assertEquals("Check response code after create service", errorInfo.getCode(), importResponse.getErrorCode());
+ List<String> variables = Arrays.asList(resourceDetails.getName(), "resource", sdncAdminUser.getFirstName(),
+ sdncAdminUser.getLastName(), sdncAdminUser.getUserId());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name(),
+ variables, importResponse.getResponse());
+
+ // validate audit
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = Convertor
+ .constructFieldsForAuditValidation(resourceDetails, resourceVersion);
+ String auditAction = "ResourceImport";
+ expectedResourceAuditJavaObject.setAction(auditAction);
+ expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
+ expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
+ expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.CERTIFICATION_IN_PROGRESS).toString());
+ // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setCurrState("");
+ expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
+ expectedResourceAuditJavaObject.setCurrVersion("");
+ expectedResourceAuditJavaObject.setStatus(errorInfo.getCode().toString());
+ expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+ String auditDesc = AuditValidationUtils.buildAuditDescription(errorInfo, variables);
+ expectedResourceAuditJavaObject.setDesc(auditDesc);
+ AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject, auditAction, null, false);
+
+ }*/
+
+ // TODO DE171337
+ // @Test(enabled = false)
+ // public void
+ // importNewResource_existIn_Certified_state_chnage_reqAndCap_byDesigner()
+ // throws Exception{
+ //
+ // // Andrey - set default artifact details
+ // ArtifactDefinition artifactDefinition =
+ // artifactUtils.constructDefaultArtifactInfo();
+ //
+ // // import new resource
+ // RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+ // assertNotNull("check response object is not null after import resource",
+ // importResponse);
+ // assertNotNull("check error code exists in response after import
+ // resource", importResponse.getErrorCode());
+ // assertEquals("Check response code after import resource", 201,
+ // importResponse.getErrorCode().intValue());
+ // String resourceId =
+ // ResponseParser.getUniqueIdFromResponse(importResponse);
+ // resourceDetails =
+ // ResponseParser.parseToObject(importResponse.getResponse(),
+ // ResourceReqDetails.class);
+ // resourceVersion = resourceDetails.getVersion();
+ // RestResponse resourceGetResponse =
+ // ResourceRestUtils.getResource(sdncModifierDetails,
+ // resourceDetails.getUniqueId());
+ // assertEquals("Check response code after get resource", 200,
+ // resourceGetResponse.getErrorCode().intValue());
+ // Resource resourceFromGet =
+ // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ // assertNotNull(resourceFromGet);
+ //
+ // // add mandatory artifacts
+ // // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // resourceGetResponse);
+ // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ // resourceDetails.getUniqueId());
+ // assertEquals("Check response code after get resource", 200,
+ // resourceGetResponse.getErrorCode().intValue());
+ // resourceFromGet =
+ // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ // assertNotNull(resourceFromGet);
+ // resourceDetails =
+ // ResponseParser.parseToObject(importResponse.getResponse(),
+ // ResourceReqDetails.class);
+ // resourceDetails.setVersion(resourceFromGet.getVersion());
+ //
+ // // add artifact
+ // artifactDefinition.setArtifactName(artifactName1);
+ // ArtifactRestUtils.addInformationalArtifactToResource(resourceDetails,
+ // sdncModifierDetails, resourceVersion , artifactDefinition);
+ //
+ // // add artifact
+ // artifactDefinition.setArtifactName(artifactName2);
+ // resourceUtils.add_artifact(resourceDetails, sdncModifierDetails,
+ // resourceVersion , artifactDefinition);
+ //
+ // // add interface
+ // artifactDefinition.setArtifactName(interfaceArtifactName);
+ // ResourceRestUtils.add_interface(resourceDetails, sdncModifierDetails,
+ // resourceVersion , artifactDefinition);
+ //
+ // //construct fields for validation
+ // resourceVersion="1.0";
+ //
+ // ResourceRespJavaObject resourceRespJavaObject =
+ // Convertor.constructFieldsForRespValidation(resourceDetails,
+ // resourceVersion);
+ // ArrayList<String> artifacts = new ArrayList<String>();
+ //
+ // artifacts.add(resourceId+":"+artifactName1);
+ // artifacts.add(resourceId+":"+artifactName2);
+ // resourceRespJavaObject.setArtifacts(artifacts);
+ // ArrayList<String> interfaces = new ArrayList<String>();
+ //
+ // interfaces.add(interfaze);
+ // resourceRespJavaObject.setInterfaces(interfaces);
+ //
+ // // checkIn resource
+ // resourceVersion = resourceDetails.getVersion();
+ // String checkinComment = "good checkin";
+ // String checkinComentJson = "{\"userRemarks\": \""+checkinComment+"\"}";
+ // RestResponse checkInResponse =
+ // LifecycleRestUtils.changeResourceState(resourceDetails,
+ // sdncModifierDetails, resourceVersion, LifeCycleStatesEnum.CHECKIN,
+ // checkinComentJson);
+ // assertNotNull("check response object is not null after import resource",
+ // checkInResponse);
+ // assertEquals("Check response code after checkout resource", 200,
+ // checkInResponse.getErrorCode().intValue());
+ //
+ // // req4cert resource
+ // RestResponse request4cert =
+ // LifecycleRestUtils.changeResourceState(resourceDetails,
+ // sdncModifierDetails, resourceVersion,
+ // LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ // assertNotNull("check response object is not null after resource request
+ // for certification", request4cert);
+ // assertEquals("Check response code after checkout resource", 200,
+ // request4cert.getErrorCode().intValue());
+ // resourceFromGet =
+ // ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
+ // assertNotNull(resourceFromGet);
+ // resourceDetails =
+ // ResponseParser.parseToObject(request4cert.getResponse(),
+ // ResourceReqDetails.class);
+ // resourceDetails.setVersion(resourceFromGet.getVersion());
+ //
+ // // startCert
+ // RestResponse startCert =
+ // LifecycleRestUtils.changeResourceState(resourceDetails,
+ // sdncModifierDetails, resourceVersion,
+ // LifeCycleStatesEnum.STARTCERTIFICATION);
+ // assertNotNull("check response object is not null after resource request
+ // start certification", startCert);
+ // assertEquals("Check response code after checkout resource", 200,
+ // startCert.getErrorCode().intValue());
+ // resourceFromGet =
+ // ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
+ // assertNotNull(resourceFromGet);
+ // resourceDetails = ResponseParser.parseToObject(startCert.getResponse(),
+ // ResourceReqDetails.class);
+ // resourceDetails.setVersion(resourceFromGet.getVersion());
+ //
+ // // certify
+ // RestResponse certify =
+ // LifecycleRestUtils.changeResourceState(resourceDetails,
+ // sdncModifierDetails, resourceVersion, LifeCycleStatesEnum.CERTIFY);
+ // assertNotNull("check response object is not null after resource request
+ // certify", certify);
+ // assertEquals("Check response code after certify resource", 200,
+ // certify.getErrorCode().intValue());
+ // resourceFromGet =
+ // ResponseParser.convertResourceResponseToJavaObject(certify.getResponse());
+ // assertNotNull(resourceFromGet);
+ // resourceDetails = ResponseParser.parseToObject(certify.getResponse(),
+ // ResourceReqDetails.class);
+ // resourceDetails.setVersion(resourceFromGet.getVersion());
+ //
+ // // clean audit
+ // DbUtils.cleanAllAudits();
+ //
+ // // change resource details
+ //
+ // // import new resource while resource already exist in other state
+ // importResponse =
+ // ImportRestUtils.importNewResourceByName("importResource4testUpdateWithoutReqCap",
+ // UserRoleEnum.ADMIN);
+ // assertNotNull("check response object is not null after import resource",
+ // importResponse);
+ // assertNotNull("check error code exists in response after import
+ // resource", importResponse.getErrorCode());
+ // assertEquals("Check response code after import resource", 200,
+ // importResponse.getErrorCode().intValue());
+ // resourceDetails =
+ // ResponseParser.parseToObject(importResponse.getResponse(),
+ // ResourceReqDetails.class);
+ // resourceVersion = resourceDetails.getVersion();
+ // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ // resourceDetails.getUniqueId());
+ // assertEquals("Check response code after get resource", 200,
+ // resourceGetResponse.getErrorCode().intValue());
+ // resourceFromGet =
+ // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ // assertNotNull(resourceFromGet);
+ //
+ // // validate response
+ // Resource resourceFromImport =
+ // ResponseParser.convertResourceResponseToJavaObject(importResponse.getResponse());
+ // assertNotNull(resourceFromImport);
+ //
+ // resourceDetails =
+ // ResponseParser.parseToObject(importResponse.getResponse(),
+ // ResourceReqDetails.class);
+ // resourceRespJavaObject =
+ // Convertor.constructFieldsForRespValidation(resourceDetails);
+ // resourceRespJavaObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ //
+ // // validate get response
+ // resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ // resourceRespJavaObject.getUniqueId());
+ // resourceFromGet =
+ // ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ // assertNotNull(resourceFromGet);
+ //
+ // // validate
+ // ResourceValidationUtils.validateModelObjects(resourceFromImport,
+ // resourceFromGet);
+ //
+ // // validate audit
+ // ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject =
+ // Convertor.constructFieldsForAuditValidation(resourceDetails,
+ // resourceVersion);
+ // auditAction="ResourceImport";
+ // expectedResourceAuditJavaObject.setAction(auditAction);
+ // expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ // expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ // expectedResourceAuditJavaObject.setPrevVersion(resourceVersion);
+ // expectedResourceAuditJavaObject.setStatus("200");
+ // expectedResourceAuditJavaObject.setDesc("OK");
+ // expectedResourceAuditJavaObject.setToscaNodeType(resourceFromGet.getToscaResourceName());
+ // AuditValidationUtils.validateAudit(expectedResourceAuditJavaObject,
+ // auditAction, null, false);
+ // }
+
+ /*@Test
+ public void importNewResource_uuidTest() throws Exception {
+ RestResponse importResponse = importNewResource(UserRoleEnum.ADMIN);
+
+ assertNotNull("check response object is not null after import resource", importResponse);
+ assertNotNull("check error code exists in response after import resource", importResponse.getErrorCode());
+ assertEquals("Check response code after import resource", 201, importResponse.getErrorCode().intValue());
+ String oldUuid = ResponseParser.getValueFromJsonResponse(importResponse.getResponse(), "uuid");
+
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceVersion = resourceDetails.getVersion();
+ RestResponse resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ Resource resourceFromGet = ResponseParser
+ .convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ // add mandatory artifacts
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // resourceGetResponse);
+ resourceGetResponse = ResourceRestUtils.getResource(sdncModifierDetails, resourceDetails.getUniqueId());
+ assertEquals("Check response code after get resource", 200, resourceGetResponse.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(resourceGetResponse.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(importResponse.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ RestResponse checkInResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ "0.1", LifeCycleStatesEnum.CHECKIN);
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+
+ String newUuid = ResponseParser.getValueFromJsonResponse(checkInResponse.getResponse(), "uuid");
+ assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid));
+
+ // req4cert resource
+ RestResponse request4cert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertNotNull("check response object is not null after resource request for certification", request4cert);
+ assertEquals("Check response code after checkout resource", 200, request4cert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(request4cert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(request4cert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ String newUuid2 = ResponseParser.getValueFromJsonResponse(request4cert.getResponse(), "uuid");
+ assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid2));
+
+ // startCert
+ RestResponse startCert = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertNotNull("check response object is not null after resource request start certification", startCert);
+ assertEquals("Check response code after checkout resource", 200, startCert.getErrorCode().intValue());
+ resourceFromGet = ResponseParser.convertResourceResponseToJavaObject(startCert.getResponse());
+ assertNotNull(resourceFromGet);
+ resourceDetails = ResponseParser.parseToObject(startCert.getResponse(), ResourceReqDetails.class);
+ resourceDetails.setVersion(resourceFromGet.getVersion());
+
+ String newUuid3 = ResponseParser.getValueFromJsonResponse(startCert.getResponse(), "uuid");
+ assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid3));
+
+ RestResponse certify = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails, "0.1",
+ LifeCycleStatesEnum.CERTIFY);
+ assertNotNull("check response object is not null after import resource", certify);
+ assertEquals("Check response code after checkout resource", 200, certify.getErrorCode().intValue());
+
+ String newUuid4 = ResponseParser.getValueFromJsonResponse(certify.getResponse(), "uuid");
+ assertTrue(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid4));
+
+ RestResponse checkoutResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ "1.0", LifeCycleStatesEnum.CHECKOUT);
+ assertNotNull("check response object is not null after import resource", checkInResponse);
+ assertEquals("Check response code after checkout resource", 200, checkInResponse.getErrorCode().intValue());
+
+ String newUuid5 = ResponseParser.getValueFromJsonResponse(checkoutResponse.getResponse(), "uuid");
+ assertFalse(ResourceValidationUtils.validateUuidAfterChangingStatus(oldUuid, newUuid5));
+ }*/
+
+ @Test
+ public void importNewResource_propertiesMapInternalUrlCredential() throws Exception {
+ String folderName = "validateProporties_typeMap_valueUrlCredential";
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER);
+
+ Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class);
+
+ List<PropertyDefinition> properties = resource.getProperties();
+ assertEquals("check properties size", 3, properties.size());
+
+ PropertyDefinition propertyDefinition = properties.stream().filter(p -> p.getName().equals("validation_test"))
+ .findFirst().get();
+ String defaultValue = propertyDefinition.getDefaultValue();
+
+ Map mapValue = gson.fromJson(defaultValue, Map.class);
+ assertEquals("check Map value size", 2, mapValue.size());
+ checkMapValues(mapValue, "key", 1, null);
+ checkMapValues(mapValue, "key", 2, null);
+
+ System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode());
+
+ }
+
+ @Test
+ public void importNewResource_propertiesListInternalUrlCredential() throws Exception {
+ String folderName = "validateProporties_typeList_valueUrlCredential";
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER);
+
+ Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class);
+
+ List<PropertyDefinition> properties = resource.getProperties();
+ assertEquals("check properties size", 3, properties.size());
+
+ PropertyDefinition propertyDefinition = properties.stream().filter(p -> p.getName().equals("validation_test"))
+ .findFirst().get();
+ String defaultValue = propertyDefinition.getDefaultValue();
+
+ List listValue = gson.fromJson(defaultValue, List.class);
+ assertEquals("check List value size", 2, listValue.size());
+ checkListValues(listValue.get(0), 1, SPECIAL_CHARACTERS);
+ checkListValues(listValue.get(1), 2, SPECIAL_CHARACTERS);
+
+ // Verify attributes
+ List<PropertyDefinition> attributes = resource.getAttributes();
- assertEquals("check properties size", 2, attributes.size());
+ assertEquals("check properties size", 2, attributes.size());
- // Verify attribute from type map
- PropertyDefinition attributeMapDefinition = attributes.stream()
- .filter(p -> p.getName().equals("validation_test_map")).findFirst().get();
- String defaultMapValue = attributeMapDefinition.getDefaultValue();
- Map attributeMapValue = gson.fromJson(defaultMapValue, Map.class);
- assertEquals("check Map value size", 2, attributeMapValue.size());
- checkMapValues(attributeMapValue, "key", 1, SPECIAL_CHARACTERS);
- checkMapValues(attributeMapValue, "key", 2, SPECIAL_CHARACTERS);
+ // Verify attribute from type map
+ PropertyDefinition attributeMapDefinition = attributes.stream()
+ .filter(p -> p.getName().equals("validation_test_map")).findFirst().get();
+ String defaultMapValue = attributeMapDefinition.getDefaultValue();
+ Map attributeMapValue = gson.fromJson(defaultMapValue, Map.class);
+ assertEquals("check Map value size", 2, attributeMapValue.size());
+ checkMapValues(attributeMapValue, "key", 1, SPECIAL_CHARACTERS);
+ checkMapValues(attributeMapValue, "key", 2, SPECIAL_CHARACTERS);
- // Verify attribute from type list
- PropertyDefinition attributeListDefinition = attributes.stream()
- .filter(p -> p.getName().equals("validation_test_list")).findFirst().get();
- String defaultListValue = attributeListDefinition.getDefaultValue();
+ // Verify attribute from type list
+ PropertyDefinition attributeListDefinition = attributes.stream()
+ .filter(p -> p.getName().equals("validation_test_list")).findFirst().get();
+ String defaultListValue = attributeListDefinition.getDefaultValue();
- List attributeListValue = gson.fromJson(defaultListValue, List.class);
- assertEquals("check List value size", 2, attributeListValue.size());
- checkListValues(attributeListValue.get(0), 1, SPECIAL_CHARACTERS);
- checkListValues(attributeListValue.get(1), 2, SPECIAL_CHARACTERS);
+ List attributeListValue = gson.fromJson(defaultListValue, List.class);
+ assertEquals("check List value size", 2, attributeListValue.size());
+ checkListValues(attributeListValue.get(0), 1, SPECIAL_CHARACTERS);
+ checkListValues(attributeListValue.get(1), 2, SPECIAL_CHARACTERS);
- System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode());
+ System.err.println("import Resource " + "<" + folderName + ">" + "response: " + importResponse.getErrorCode());
- }
+ }
- private void checkListValues(Object object, int index, String suffix) {
+ private void checkListValues(Object object, int index, String suffix) {
- Map map = (Map) object;
- assertEquals("check Map protocol value", "protocol" + index + (suffix == null ? "" : suffix),
- map.get("protocol"));
- assertEquals("check Map token value", "token" + index, map.get("token"));
- }
+ Map map = (Map) object;
+ assertEquals("check Map protocol value", "protocol" + index + (suffix == null ? "" : suffix),
+ map.get("protocol"));
+ assertEquals("check Map token value", "token" + index, map.get("token"));
+ }
- // @Test
- public void importNewResource_validateProporties_typeTestDataType() throws Exception {
- String folderName = "validateProporties_typeTestDataType";
- RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER);
+ // @Test
+ public void importNewResource_validateProporties_typeTestDataType() throws Exception {
+ String folderName = "validateProporties_typeTestDataType";
+ RestResponse importResponse = ImportRestUtils.importNewResourceByName(folderName, UserRoleEnum.DESIGNER);
- Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class);
+ Resource resource = ResponseParser.parseToObjectUsingMapper(importResponse.getResponse(), Resource.class);
- }
+ }
- private void checkMapValues(Map mapValue, String key, int index, String suffix) {
+ private void checkMapValues(Map mapValue, String key, int index, String suffix) {
- Map map1 = (Map) mapValue.get(key + index);
- assertEquals("check Map protocol value", "protocol" + index + (suffix == null ? "" : suffix),
- map1.get("protocol"));
- assertEquals("check Map token value", "token" + index, map1.get("token"));
+ Map map1 = (Map) mapValue.get(key + index);
+ assertEquals("check Map protocol value", "protocol" + index + (suffix == null ? "" : suffix),
+ map1.get("protocol"));
+ assertEquals("check Map token value", "token" + index, map1.get("token"));
- }
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java
index 3d7c81abae..4338a1b151 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java
@@ -20,29 +20,14 @@
package org.openecomp.sdc.ci.tests.execute.imports;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
+import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
@@ -54,7 +39,17 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
/**
* US US730518 Story [BE] - TOSCA capabilities with properties - import "As a
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java
index 9899a8c996..7338645f57 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaResourceTest.java
@@ -20,24 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.imports;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import org.apache.http.client.ClientProtocolException;
import org.junit.Rule;
import org.junit.rules.TestName;
@@ -46,18 +28,7 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.CapReqDef;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.RelationshipImpl;
-import org.openecomp.sdc.be.model.RelationshipInfo;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
@@ -65,11 +36,7 @@ import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
@@ -78,13 +45,7 @@ import org.openecomp.sdc.ci.tests.utils.Decoder;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.general.ImportUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.common.api.ToscaNodeTypeInfo;
@@ -95,6 +56,13 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*;
+import static org.testng.AssertJUnit.*;
+
/**
*
* @author Andrey + Pavel + Shay
@@ -1269,12 +1237,12 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
assertEquals(requirements.keySet().size(), requirementsFromResponse.keySet().size());
importReqDetails.compareRequirementsOrCapabilities(requirements, requirementsFromResponse);
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue())*/;
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
@@ -1313,10 +1281,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
RestResponse createResourceResponse = ResourceRestUtils.createResource(vf, sdncUserDetails);
ResourceRestUtils.checkCreateResponse(createResourceResponse);
- LifecycleRestUtils.changeResourceState(importDetails, sdncUserDetails,
+//TODO Andrey should click on certify button
+ /*LifecycleRestUtils.changeResourceState(importDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
LifecycleRestUtils.changeResourceState(importReqDetails2, sdncUserDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);*/
+ LifecycleRestUtils.changeResourceState(importDetails, sdncUserDetails,
+ LifeCycleStatesEnum.CERTIFY);
+ LifecycleRestUtils.changeResourceState(importReqDetails2, sdncUserDetails,
+ LifeCycleStatesEnum.CERTIFY);
RestResponse response = ResourceRestUtils.createResourceInstance(importDetails, sdncUserDetails,
vf.getUniqueId());
@@ -1378,14 +1351,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
assertEquals(capabilities.keySet().size(), capabilitiesFromResponse.keySet().size());
importReqDetails.compareRequirementsOrCapabilities(capabilities, capabilitiesFromResponse);
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+ //TODO Andrey should click on certify button
+ /*RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String fileName2 = "CaseInsensitiveCapTest_2.yml";
@@ -1439,15 +1413,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
null);
assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+//TODO Andrey should click on certify button
+/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String derivedFromResourceName = importReqDetails.getName();
@@ -1524,15 +1498,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
null);
assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+//TODO Andrey should click on certify button
+ /*RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String derivedFromName = importReqDetails.getName();
@@ -1568,14 +1542,14 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
null);
assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+ /*RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String derivedFromName = importReqDetails.getName();
@@ -1611,15 +1585,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
null);
assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+//TODO Andrey should click on certify button
+/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue())*/;
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String fatherUniqueId = importReqDetails.getUniqueId();
@@ -1670,15 +1644,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
null);
assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+//TODO Andrey should click on certify button
+/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String derivedFromName = importReqDetails.getName();
@@ -1721,15 +1695,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
null);
assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+//TODO Andrey should click on certify button
+/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String derivedFromName = importReqDetails.getName();
@@ -1773,15 +1747,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
null);
assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+//TODO Andrey should click on certify button
+/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String fatherUniqueId = importReqDetails.getUniqueId();
@@ -1850,15 +1824,15 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, sdncUserDetails,
null);
assertEquals(STATUS_CODE_CREATED, importResourceResponse.getErrorCode().intValue());
-
- RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
+//TODO Andrey should click on certify button
+/* RestResponse changeResourceState1 = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState1.getErrorCode().intValue());
RestResponse changeResourceState2 = LifecycleRestUtils.changeResourceState(importReqDetails,
ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());
+ assertEquals(STATUS_CODE_SUCCESS, changeResourceState2.getErrorCode().intValue());*/
RestResponse changeResourceState3 = LifecycleRestUtils.changeResourceState(importReqDetails,
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY);
+ ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState3.getErrorCode().intValue());
String childFileName = "DifferentReqCapFromCompute1.yml";
@@ -1950,8 +1924,8 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
LifeCycleStatesEnum.CHECKIN);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
-
- // certification request
+//TODO Andrey should click on certify button
+ /*// certification request
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
@@ -1961,10 +1935,10 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
LifeCycleStatesEnum.STARTCERTIFICATION);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
+ assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/
// certify
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
+ changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFY);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
@@ -1982,19 +1956,19 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
assertEquals(STATUS_CODE_SUCCESS, updateResponse.getErrorCode().intValue());
assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, updateResponse));
- // certification request
+ /* // certification request
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
-
+*/
// checkout resource
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CHECKOUT);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
-
- // certification request
+//TODO Andrey should click on certify button
+/* // certification request
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
@@ -2004,16 +1978,16 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
LifeCycleStatesEnum.STARTCERTIFICATION);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
+ assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/
- // cancel certification
+ /*// cancel certification
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
LifeCycleStatesEnum.CANCELCERTIFICATION);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
+ assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/
- // start certification
- changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
+ /*// start certification
+ changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
LifeCycleStatesEnum.STARTCERTIFICATION);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
@@ -2022,7 +1996,7 @@ public class ImportToscaResourceTest extends ComponentBaseTest {
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, testerUser,
LifeCycleStatesEnum.FAILCERTIFICATION);
assertEquals(STATUS_CODE_SUCCESS, changeResourceState.getErrorCode().intValue());
- assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));
+ assertTrue(checkInvariantUuidEqual(invariantUUIDcreation, changeResourceState));*/
// upload artifact
changeResourceState = LifecycleRestUtils.changeResourceState(importReqDetails, sdncUserDetails,
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java
index 9e8b94e5a8..473e4f2e36 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java
@@ -20,14 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.imports;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.regex.Pattern;
-
+import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
@@ -48,7 +41,13 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.openecomp.sdc.common.api.Constants;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import static org.testng.AssertJUnit.assertTrue;
public class ImportUpdateResourseCsarTest extends ComponentBaseTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java
index 560e5389fe..91cf3b0c44 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java
@@ -20,28 +20,15 @@
package org.openecomp.sdc.ci.tests.execute.inputs;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import fj.data.Either;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstInputsMap;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstancePropInput;
-import org.openecomp.sdc.be.model.InputDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
@@ -49,18 +36,18 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.InputsRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertTrue;
/**
* CI-Tests for inputs
@@ -91,7 +78,7 @@ public class InputsApiTests extends ComponentBaseTest {
*/
@Test
public void testCreateResourceInstanceWithInputsFromCsar() throws Exception {
- Resource vf = AtomicOperationUtils.importResourceFromCSAR(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, inputCsar1);
+ Resource vf = AtomicOperationUtils.importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, inputCsar1);
assertTrue("Success creating VF from CSAR", !vf.getInputs().isEmpty());
}
@@ -181,7 +168,7 @@ public class InputsApiTests extends ComponentBaseTest {
Service service = createDefaultServiceEither.left().value();
// Create VF from CSAR file
- Resource vfWithInputs = AtomicOperationUtils.importResourceFromCSAR(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, inputCsar2);
+ Resource vfWithInputs = AtomicOperationUtils.importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, inputCsar2);
// Certify VF
Pair<Component, RestResponse> changeComponentState = AtomicOperationUtils.changeComponentState(vfWithInputs, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java
index e15652dddf..358e425cc5 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/lifecycle/LCSbaseTest.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.lifecycle;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-
import org.apache.log4j.lf5.util.ResourceUtils;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -37,153 +31,146 @@ import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.ArtifactUtils;
import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.annotations.BeforeMethod;
+import java.io.IOException;
+
+import static org.testng.AssertJUnit.*;
+
/**
- *
* @author al714h
- *
- * resourceDetails - create, Add Heat, certify resourceDetails1 - create
- * resource, LCS - CheckOut serviceDetails - create, add RI from
- * resourceDetails serviceDetails2 - create, add RI from resourceDetails
- * serviceDetailsEmpty - create, LCS - CheckOut serviceDetailsEmpty2 -
- * create, LCS - CheckOut
- *
+ * <p>
+ * resourceDetails - create, Add Heat, certify resourceDetails1 - create
+ * resource, LCS - CheckOut serviceDetails - create, add RI from
+ * resourceDetails serviceDetails2 - create, add RI from resourceDetails
+ * serviceDetailsEmpty - create, LCS - CheckOut serviceDetailsEmpty2 -
+ * create, LCS - CheckOut
*/
public abstract class LCSbaseTest extends ComponentBaseTest {
- protected ResourceReqDetails resourceDetails;
- protected ResourceReqDetails resourceDetails1;
- protected ServiceReqDetails serviceDetails;
- protected ServiceReqDetails serviceDetails2;
- protected ServiceReqDetails serviceDetailsEmpty;
- protected ServiceReqDetails serviceDetailsEmpty2;
- protected ComponentInstanceReqDetails componentInstanceReqDetails;
- protected ComponentInstanceReqDetails resourceInstanceReqDetails2;
- protected User sdncDesignerDetails1;
- protected User sdncDesignerDetails2;
- protected static User sdncTesterDeatails1;
- protected User sdncAdminDetails1;
- protected ArtifactReqDetails heatArtifactDetails;
- protected ArtifactReqDetails heatVolArtifactDetails;
- protected ArtifactReqDetails heatNetArtifactDetails;
-
- protected ArtifactReqDetails defaultArtifactDetails;
- protected ResourceUtils resourceUtils;
- protected ArtifactUtils artifactUtils;
-
- // protected static ServiceUtils serviceUtils = new ServiceUtils();
- public LCSbaseTest(TestName testName, String className) {
- super(testName, className);
- }
-
- @BeforeMethod
- public void before() throws Exception {
-
- initializeMembers();
-
- createComponents();
-
- }
-
- public void initializeMembers() throws IOException, Exception {
- resourceDetails = ElementFactory.getDefaultResource();
- // resourceDetails =
- // ElementFactory.getDefaultResource("myNewResource1234567890",
- // NormativeTypesEnum.ROOT, ResourceServiceCategoriesEnum.ROUTERS,
- // UserRoleEnum.DESIGNER.getUserId());
- resourceDetails1 = ElementFactory.getDefaultResource("secondResource", NormativeTypesEnum.ROOT);
- serviceDetails = ElementFactory.getDefaultService();
- serviceDetails2 = ElementFactory.getDefaultService("newTestService2", ServiceCategoriesEnum.MOBILITY, "al1976");
- serviceDetailsEmpty = ElementFactory.getDefaultService("newEmptyService", ServiceCategoriesEnum.MOBILITY,
- "al1976");
- serviceDetailsEmpty2 = ElementFactory.getDefaultService("newEmptyService2", ServiceCategoriesEnum.MOBILITY,
- "al1976");
- sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- sdncDesignerDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2);
- sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- sdncAdminDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- heatNetArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
- heatVolArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType());
- componentInstanceReqDetails = ElementFactory.getDefaultComponentInstance();
- resourceInstanceReqDetails2 = ElementFactory.getDefaultComponentInstance();
-
- }
-
- protected void createComponents() throws Exception {
-
- RestResponse response = ResourceRestUtils.createResource(resourceDetails1, sdncDesignerDetails1);
- assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
- assertNotNull("resource uniqueId is null:", resourceDetails1.getUniqueId());
-
- response = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails1);
- assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
- assertNotNull("resource uniqueId is null:", resourceDetails.getUniqueId());
-
- response = ServiceRestUtils.createService(serviceDetails, sdncDesignerDetails1);
- assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
- assertNotNull("service uniqueId is null:", serviceDetails.getUniqueId());
-
- ArtifactReqDetails heatArtifactDetails = ElementFactory
- .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1,
- resourceDetails.getUniqueId());
- assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(),
- response.getErrorCode() == 200);
-
- // certified resource
- response = LCSbaseTest.certifyResource(resourceDetails, sdncDesignerDetails1);
- assertTrue("certify resource request returned status:" + response.getErrorCode(),
- response.getErrorCode() == 200);
-
- // add resource instance with HEAT deployment artifact to the service
- componentInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId());
- response = ComponentInstanceRestUtils.createComponentInstance(componentInstanceReqDetails, sdncDesignerDetails1,
- serviceDetails.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201);
-
- response = ServiceRestUtils.createService(serviceDetails2, sdncDesignerDetails1);
- assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
- assertNotNull("service uniqueId is null:", serviceDetails2.getUniqueId());
-
- componentInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId());
- response = ComponentInstanceRestUtils.createComponentInstance(componentInstanceReqDetails, sdncDesignerDetails1,
- serviceDetails2.getUniqueId(), ComponentTypeEnum.SERVICE);
- assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201);
-
- response = ServiceRestUtils.createService(serviceDetailsEmpty, sdncDesignerDetails1);
- assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
- assertNotNull("service uniqueId is null:", serviceDetailsEmpty.getUniqueId());
-
- response = ServiceRestUtils.createService(serviceDetailsEmpty2, sdncDesignerDetails1);
- assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
- assertNotNull("service uniqueId is null:", serviceDetailsEmpty2.getUniqueId());
-
- DbUtils.cleanAllAudits();
-
- }
-
- public static RestResponse certifyResource(ResourceReqDetails resourceDetails, User user) throws Exception {
- RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(),
- LifeCycleStatesEnum.CHECKIN);
+ protected ResourceReqDetails resourceDetails;
+ protected ResourceReqDetails resourceDetails1;
+ protected ServiceReqDetails serviceDetails;
+ protected ServiceReqDetails serviceDetails2;
+ protected ServiceReqDetails serviceDetailsEmpty;
+ protected ServiceReqDetails serviceDetailsEmpty2;
+ protected ComponentInstanceReqDetails componentInstanceReqDetails;
+ protected ComponentInstanceReqDetails resourceInstanceReqDetails2;
+ protected User sdncDesignerDetails1;
+ protected User sdncDesignerDetails2;
+ protected static User sdncTesterDeatails1;
+ protected User sdncAdminDetails1;
+ protected ArtifactReqDetails heatArtifactDetails;
+ protected ArtifactReqDetails heatVolArtifactDetails;
+ protected ArtifactReqDetails heatNetArtifactDetails;
+
+ protected ArtifactReqDetails defaultArtifactDetails;
+ protected ResourceUtils resourceUtils;
+ protected ArtifactUtils artifactUtils;
+
+ // protected static ServiceUtils serviceUtils = new ServiceUtils();
+ public LCSbaseTest(TestName testName, String className) {
+ super(testName, className);
+ }
+
+ @BeforeMethod
+ public void before() throws Exception {
+
+ initializeMembers();
+
+ createComponents();
+
+ }
+
+ public void initializeMembers() throws IOException, Exception {
+ resourceDetails = ElementFactory.getDefaultResource();
+ // resourceDetails =
+ // ElementFactory.getDefaultResource("myNewResource1234567890",
+ // NormativeTypesEnum.ROOT, ResourceServiceCategoriesEnum.ROUTERS,
+ // UserRoleEnum.DESIGNER.getUserId());
+ resourceDetails1 = ElementFactory.getDefaultResource("secondResource", NormativeTypesEnum.ROOT);
+ serviceDetails = ElementFactory.getDefaultService();
+ serviceDetails2 = ElementFactory.getDefaultService("newTestService2", ServiceCategoriesEnum.MOBILITY, "al1976", ServiceInstantiationType.A_LA_CARTE.getValue());
+ serviceDetailsEmpty = ElementFactory.getDefaultService("newEmptyService", ServiceCategoriesEnum.MOBILITY,
+ "al1976", ServiceInstantiationType.A_LA_CARTE.getValue());
+ serviceDetailsEmpty2 = ElementFactory.getDefaultService("newEmptyService2", ServiceCategoriesEnum.MOBILITY,
+ "al1976", ServiceInstantiationType.A_LA_CARTE.getValue());
+ sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ sdncDesignerDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2);
+ sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
+ sdncAdminDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
+ heatNetArtifactDetails = ElementFactory
+ .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_NET.getType());
+ heatVolArtifactDetails = ElementFactory
+ .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT_VOL.getType());
+ componentInstanceReqDetails = ElementFactory.getDefaultComponentInstance();
+ resourceInstanceReqDetails2 = ElementFactory.getDefaultComponentInstance();
+
+ }
+
+ protected void createComponents() throws Exception {
+
+ RestResponse response = ResourceRestUtils.createResource(resourceDetails1, sdncDesignerDetails1);
+ assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
+ assertNotNull("resource uniqueId is null:", resourceDetails1.getUniqueId());
+
+ response = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails1);
+ assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
+ assertNotNull("resource uniqueId is null:", resourceDetails.getUniqueId());
+
+ response = ServiceRestUtils.createService(serviceDetails, sdncDesignerDetails1);
+ assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
+ assertNotNull("service uniqueId is null:", serviceDetails.getUniqueId());
+
+ ArtifactReqDetails heatArtifactDetails = ElementFactory
+ .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
+ response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1,
+ resourceDetails.getUniqueId());
+ assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(),
+ response.getErrorCode() == 200);
+
+ // certified resource
+ response = LCSbaseTest.certifyResource(resourceDetails, sdncDesignerDetails1);
+ assertTrue("certify resource request returned status:" + response.getErrorCode(),
+ response.getErrorCode() == 200);
+
+ // add resource instance with HEAT deployment artifact to the service
+ componentInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId());
+ response = ComponentInstanceRestUtils.createComponentInstance(componentInstanceReqDetails, sdncDesignerDetails1,
+ serviceDetails.getUniqueId(), ComponentTypeEnum.SERVICE);
+ assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201);
+
+ response = ServiceRestUtils.createService(serviceDetails2, sdncDesignerDetails1);
+ assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
+ assertNotNull("service uniqueId is null:", serviceDetails2.getUniqueId());
+
+ componentInstanceReqDetails.setComponentUid(resourceDetails.getUniqueId());
+ response = ComponentInstanceRestUtils.createComponentInstance(componentInstanceReqDetails, sdncDesignerDetails1,
+ serviceDetails2.getUniqueId(), ComponentTypeEnum.SERVICE);
+ assertTrue("response code is not 201, returned: " + response.getErrorCode(), response.getErrorCode() == 201);
+
+ response = ServiceRestUtils.createService(serviceDetailsEmpty, sdncDesignerDetails1);
+ assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
+ assertNotNull("service uniqueId is null:", serviceDetailsEmpty.getUniqueId());
+
+ response = ServiceRestUtils.createService(serviceDetailsEmpty2, sdncDesignerDetails1);
+ assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
+ assertNotNull("service uniqueId is null:", serviceDetailsEmpty2.getUniqueId());
+
+ DbUtils.cleanAllAudits();
+
+ }
+
+ public static RestResponse certifyResource(ResourceReqDetails resourceDetails, User user) throws Exception {
+/* RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(),
+ LifeCycleStatesEnum.CHECKIN);
// if (restResponseResource.getErrorCode() == 200){
restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(),
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
@@ -199,76 +186,78 @@ public abstract class LCSbaseTest extends ComponentBaseTest {
restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails,
sdncTesterDeatails1.getUserId(), LifeCycleStatesEnum.CERTIFY);
}
- return restResponseResource;
- }
-
- public static RestResponse certifyService(ServiceReqDetails serviceDetails, User user) throws Exception {
- RestResponse restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, user,
- LifeCycleStatesEnum.CHECKIN);
- // if (restResponseService.getErrorCode() == 200){
- restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, user,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- // }else
- // return restResponseService;
-
- sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- if (restResponseService.getErrorCode() == 200) {
- restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDeatails1,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- } else
- return restResponseService;
- if (restResponseService.getErrorCode() == 200) {
- restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDeatails1,
- LifeCycleStatesEnum.CERTIFY);
- }
- return restResponseService;
- }
-
- protected static RestResponse raiseResourceToTargetVersion(ResourceReqDetails resourceDetails, String targetVersion,
- User user) throws Exception {
- return raiseResourceToTargetVersion(resourceDetails, targetVersion, null, user);
- }
-
- protected static RestResponse raiseResourceToTargetVersion(ResourceReqDetails resourceDetails, String targetVersion,
- RestResponse prevResponse, User user) throws Exception {
-
- String[] splitParts = targetVersion.split("\\.");
-
- int version = Integer.parseInt(splitParts[1]);
- String checkinComment = "good checkin";
- String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
-
- if (prevResponse != null) {
- Resource resourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(prevResponse.getResponse());
- if (resourceRespJavaObject.getLifecycleState().equals(LifecycleStateEnum.CERTIFIED)) {
- RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails,
- user.getUserId(), LifeCycleStatesEnum.CHECKOUT);
- }
- }
-
- RestResponse restResponseResource = null;
- for (int i = 0; i < (version - 1); i++) {
-
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, null,
- LifeCycleStatesEnum.CHECKIN, checkinComentJson);
- if (restResponseResource.getErrorCode() == 200) {
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(),
- LifeCycleStatesEnum.CHECKOUT);
- if (restResponseResource.getErrorCode() == 200) {
-
- } else
- break;
-
- } else
- break;
-
- }
-
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, null,
- LifeCycleStatesEnum.CHECKIN, checkinComentJson);
- assertEquals("Check response code ", 200, restResponseResource.getErrorCode().intValue());
- return restResponseResource;
- }
+ return restResponseResource;*/
+ return LifecycleRestUtils.changeResourceState(resourceDetails,
+ sdncTesterDeatails1.getUserId(), LifeCycleStatesEnum.CERTIFY);
+ }
+
+ public static RestResponse certifyService(ServiceReqDetails serviceDetails, User user) throws Exception {
+ RestResponse restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, user,
+ LifeCycleStatesEnum.CHECKIN);
+ // if (restResponseService.getErrorCode() == 200){
+ restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, user,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ // }else
+ // return restResponseService;
+
+ sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
+ if (restResponseService.getErrorCode() == 200) {
+ restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDeatails1,
+ LifeCycleStatesEnum.STARTCERTIFICATION);
+ } else
+ return restResponseService;
+ if (restResponseService.getErrorCode() == 200) {
+ restResponseService = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDeatails1,
+ LifeCycleStatesEnum.CERTIFY);
+ }
+ return restResponseService;
+ }
+
+ protected static RestResponse raiseResourceToTargetVersion(ResourceReqDetails resourceDetails, String targetVersion,
+ User user) throws Exception {
+ return raiseResourceToTargetVersion(resourceDetails, targetVersion, null, user);
+ }
+
+ protected static RestResponse raiseResourceToTargetVersion(ResourceReqDetails resourceDetails, String targetVersion,
+ RestResponse prevResponse, User user) throws Exception {
+
+ String[] splitParts = targetVersion.split("\\.");
+
+ int version = Integer.parseInt(splitParts[1]);
+ String checkinComment = "good checkin";
+ String checkinComentJson = "{\"userRemarks\": \"" + checkinComment + "\"}";
+
+ if (prevResponse != null) {
+ Resource resourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(prevResponse.getResponse());
+ if (resourceRespJavaObject.getLifecycleState().equals(LifecycleStateEnum.CERTIFIED)) {
+ RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails,
+ user.getUserId(), LifeCycleStatesEnum.CHECKOUT);
+ }
+ }
+
+ RestResponse restResponseResource = null;
+ for (int i = 0; i < (version - 1); i++) {
+
+ restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, null,
+ LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+ if (restResponseResource.getErrorCode() == 200) {
+ restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user.getUserId(),
+ LifeCycleStatesEnum.CHECKOUT);
+ if (restResponseResource.getErrorCode() == 200) {
+
+ } else
+ break;
+
+ } else
+ break;
+
+ }
+
+ restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, null,
+ LifeCycleStatesEnum.CHECKIN, checkinComentJson);
+ assertEquals("Check response code ", 200, restResponseResource.getErrorCode().intValue());
+ return restResponseResource;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java
index 6a4fa3ba55..99caea6863 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ChangeServiceInstanceVersionTest.java
@@ -20,26 +20,11 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_NOT_FOUND;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS_DELETE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_UNSUPPORTED_ERROR;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
@@ -48,1431 +33,1432 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
public class ChangeServiceInstanceVersionTest extends ComponentInstanceBaseTest {
- protected ArtifactReqDetails heatArtifactDetails;
- public String firstVfInstanceUniqueId;
- public String firstVfInstanceName;
- public String secondVfInstanceUniqueId;
- public String secoundVfInstanceName;
- public String serviceInstanceToReplaceUniqueId;
- public String expectedServiceName;
- public String expectedPosX;
- public String expectedPosY;
- public String actualServiceInstanceName;
- public String actualPosX;
- public String actualPosY;
+ protected ArtifactReqDetails heatArtifactDetails;
+ public String firstVfInstanceUniqueId;
+ public String firstVfInstanceName;
+ public String secondVfInstanceUniqueId;
+ public String secoundVfInstanceName;
+ public String serviceInstanceToReplaceUniqueId;
+ public String expectedServiceName;
+ public String expectedPosX;
+ public String expectedPosY;
+ public String actualServiceInstanceName;
+ public String actualPosX;
+ public String actualPosY;
- @Rule
- public static TestName name = new TestName();
+ @Rule
+ public static TestName name = new TestName();
- public ChangeServiceInstanceVersionTest() {
- super(name, ChangeServiceInstanceVersionTest.class.getName());
- }
+ public ChangeServiceInstanceVersionTest() {
+ super(name, ChangeServiceInstanceVersionTest.class.getName());
+ }
- @BeforeMethod
- public void before() throws Exception {
- firstVfInstanceName = null;
- secoundVfInstanceName = null;
- firstVfInstanceUniqueId = null;
- secondVfInstanceUniqueId = null;
- serviceInstanceToReplaceUniqueId = null;
- expectedServiceName = null;
- expectedPosX = null;
- expectedPosY = null;
- actualServiceInstanceName = null;
- actualPosX = null;
- actualPosY = null;
- init();
- createComponents();
- }
+ @BeforeMethod
+ public void before() throws Exception {
+ firstVfInstanceName = null;
+ secoundVfInstanceName = null;
+ firstVfInstanceUniqueId = null;
+ secondVfInstanceUniqueId = null;
+ serviceInstanceToReplaceUniqueId = null;
+ expectedServiceName = null;
+ expectedPosX = null;
+ expectedPosY = null;
+ actualServiceInstanceName = null;
+ actualPosX = null;
+ actualPosY = null;
+ init();
+ createComponents();
+ }
- private void createComponents() throws Exception {
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- createAtomicResource(resourceDetailsVFC_01);
- changeResourceStateToCertified(resourceDetailsVFC_01);
- createAtomicResource(resourceDetailsCP_01);
- changeResourceStateToCertified(resourceDetailsCP_01);
- createAtomicResource(resourceDetailsVL_01);
- changeResourceStateToCertified(resourceDetailsVL_01);
- createAtomicResource(resourceDetailsVFC_02);
- changeResourceStateToCertified(resourceDetailsVFC_02);
- createAtomicResource(resourceDetailsCP_02);
- changeResourceStateToCertified(resourceDetailsCP_02);
- createAtomicResource(resourceDetailsVL_02);
- changeResourceStateToCertified(resourceDetailsVL_02);
- createVF(resourceDetailsVF_02);
- createVF(resourceDetailsVF_01);
- // create check-In services
- createService(serviceDetails_01);
- createService(serviceDetails_02);
- createService(serviceDetails_03);
- createProduct(productDetails_01);
- createProduct(productDetails_02);
+ private void createComponents() throws Exception {
+ heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
+ createAtomicResource(resourceDetailsVFC_01);
+ changeResourceStateToCertified(resourceDetailsVFC_01);
+ createAtomicResource(resourceDetailsCP_01);
+ changeResourceStateToCertified(resourceDetailsCP_01);
+ createAtomicResource(resourceDetailsVL_01);
+ changeResourceStateToCertified(resourceDetailsVL_01);
+ createAtomicResource(resourceDetailsVFC_02);
+ changeResourceStateToCertified(resourceDetailsVFC_02);
+ createAtomicResource(resourceDetailsCP_02);
+ changeResourceStateToCertified(resourceDetailsCP_02);
+ createAtomicResource(resourceDetailsVL_02);
+ changeResourceStateToCertified(resourceDetailsVL_02);
+ createVF(resourceDetailsVF_02);
+ createVF(resourceDetailsVF_01);
+ // create check-In services
+ createService(serviceDetails_01);
+ createService(serviceDetails_02);
+ createService(serviceDetails_03);
+ createProduct(productDetails_01);
+ createProduct(productDetails_02);
- // add resourceDetailsCP_01 ,resourceDetailsVFC_01 and
- // resourceDetailsCP_01 to resourceDetailsVF_01 and certify
- // resourceDetailsVF_01
- certifyVf(resourceDetailsVF_01, resourceDetailsVFC_02, resourceDetailsCP_01);
- // add resourceDetailsCP_02 ,resourceDetailsVFC_02 and
- // resourceDetailsVL_02 to resourceDetailsVF_02 and certify
- // resourceDetailsVF_02
- certifyVf(resourceDetailsVF_02, resourceDetailsVFC_02, resourceDetailsCP_02);
- RestResponse createVFInstanceResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01,
- sdncDesignerDetails); // serviceDetails_01 has certified
- // resourceDetailsVF_01
- firstVfInstanceName = ResponseParser.getNameFromResponse(createVFInstanceResponse);
- createVFInstanceResponse = createVFInstanceDuringSetup(serviceDetails_02, resourceDetailsVF_02,
- sdncDesignerDetails); // serviceDetails_01 has certified
- // resourceDetailsVF_02
- secoundVfInstanceName = ResponseParser.getUniqueIdFromResponse(createVFInstanceResponse);
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- }
+ // add resourceDetailsCP_01 ,resourceDetailsVFC_01 and
+ // resourceDetailsCP_01 to resourceDetailsVF_01 and certify
+ // resourceDetailsVF_01
+ certifyVf(resourceDetailsVF_01, resourceDetailsVFC_02, resourceDetailsCP_01);
+ // add resourceDetailsCP_02 ,resourceDetailsVFC_02 and
+ // resourceDetailsVL_02 to resourceDetailsVF_02 and certify
+ // resourceDetailsVF_02
+ certifyVf(resourceDetailsVF_02, resourceDetailsVFC_02, resourceDetailsCP_02);
+ RestResponse createVFInstanceResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01,
+ sdncDesignerDetails); // serviceDetails_01 has certified
+ // resourceDetailsVF_01
+ firstVfInstanceName = ResponseParser.getNameFromResponse(createVFInstanceResponse);
+ createVFInstanceResponse = createVFInstanceDuringSetup(serviceDetails_02, resourceDetailsVF_02,
+ sdncDesignerDetails); // serviceDetails_01 has certified
+ // resourceDetailsVF_02
+ secoundVfInstanceName = ResponseParser.getUniqueIdFromResponse(createVFInstanceResponse);
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ }
- @Test
- public void changeServiceInstanceVersionByPm() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
+ @Test
+ public void changeServiceInstanceVersionByPm() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // get the new VF instance uniqueId after checkout service
+ RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
+ List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
+ for (ComponentInstance component : serviceComponentInstances) {
+ if (component.getName().equals(firstVfInstanceName)) {
+ firstVfInstanceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(firstVfInstanceUniqueId != null);
+ // delete resource instance (resourceDetailsVF_01) from Service
+ RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
+ serviceDetails_01, sdncDesignerDetails);
+ assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ // Add different VF instance (resourceDetailsVF_02) to Service
+ RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(restResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ expectedServiceName = component.getName();
+ expectedPosX = component.getPosX();
+ expectedPosY = component.getPosY();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
+ ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
+ actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
+ actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posX");
+ actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posY");
+ ComponentInstance componentInstance = ResponseParser
+ .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // Verify that Service instance name and position didn't change after
+ // changing service instance version
+ assertTrue(actualServiceInstanceName.equals(expectedServiceName));
+ assertTrue(actualPosX.equals(expectedPosX));
+ assertTrue(actualPosY.equals(expectedPosY));
+ }
- @Test
- public void changeServiceInstanceVersionByAdmin() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // service [0.2] state to CERTIFICATIONREQUEST
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncAdminDetails, ComponentTypeEnum.PRODUCT,
- true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
+ @Test
+ public void changeServiceInstanceVersionByAdmin() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // get the new VF instance uniqueId after checkout service
+ RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
+ List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
+ for (ComponentInstance component : serviceComponentInstances) {
+ if (component.getName().equals(firstVfInstanceName)) {
+ firstVfInstanceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(firstVfInstanceUniqueId != null);
+ // delete resource instance (resourceDetailsVF_01) from Service
+ RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
+ serviceDetails_01, sdncDesignerDetails);
+ assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ // Add different VF instance (resourceDetailsVF_02) to Service
+ RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(restResponse);
+ // service [0.2] state to CERTIFICATIONREQUEST
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
+ LifeCycleStatesEnum.STARTCERTIFICATION);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ expectedServiceName = component.getName();
+ expectedPosX = component.getPosX();
+ expectedPosY = component.getPosY();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncAdminDetails, ComponentTypeEnum.PRODUCT,
+ true);
+ ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
+ actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
+ actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posX");
+ actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posY");
+ ComponentInstance componentInstance = ResponseParser
+ .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // Verify that Service instance name and position didn't change after
+ // changing service instance version
+ assertTrue(actualServiceInstanceName.equals(expectedServiceName));
+ assertTrue(actualPosX.equals(expectedPosX));
+ assertTrue(actualPosY.equals(expectedPosY));
+ }
- @Test
- public void changeServiceInstanceToOlderVersion() throws Exception {
- // Get VF Instance UniquId [Service version 0.1]
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- ComponentInstance actualComponentInstance = service.getComponentInstances().get(0);
- firstVfInstanceUniqueId = actualComponentInstance.getUniqueId();
- String serviceOlderVersionUniquId = ResponseParser.getUniqueIdFromResponse(getServiceResponse);
+ @Test
+ public void changeServiceInstanceToOlderVersion() throws Exception {
+ // Get VF Instance UniquId [Service version 0.1]
+ RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
+ ComponentInstance actualComponentInstance = service.getComponentInstances().get(0);
+ firstVfInstanceUniqueId = actualComponentInstance.getUniqueId();
+ String serviceOlderVersionUniquId = ResponseParser.getUniqueIdFromResponse(getServiceResponse);
- // Checkout service [0.2]
- RestResponse changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01,
- sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // Adding service instance (serviceDetails_01 V0.2) to product without
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to Older version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceOlderVersionUniquId, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
- true);
- // RestResponse changeServiceInstanceVersionResponse =
- // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
- // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
- // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
+ // Checkout service [0.2]
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01,
+ sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // get the new VF instance uniqueId after checkout service
+ getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
+ List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
+ for (ComponentInstance component : serviceComponentInstances) {
+ if (component.getName().equals(firstVfInstanceName)) {
+ firstVfInstanceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(firstVfInstanceUniqueId != null);
+ // delete resource instance (resourceDetailsVF_01) from Service
+ RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
+ serviceDetails_01, sdncDesignerDetails);
+ assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ // Add different VF instance (resourceDetailsVF_02) to Service
+ RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(restResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // Adding service instance (serviceDetails_01 V0.2) to product without
+ // saving Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ expectedServiceName = component.getName();
+ expectedPosX = component.getPosX();
+ expectedPosY = component.getPosY();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to Older version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceOlderVersionUniquId, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
+ true);
+ // RestResponse changeServiceInstanceVersionResponse =
+ // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
+ // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
+ // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
+ ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
+ actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
+ actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posX");
+ actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posY");
+ ComponentInstance componentInstance = ResponseParser
+ .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // Verify that Service instance name and position didn't change after
+ // changing service instance version
+ assertTrue(actualServiceInstanceName.equals(expectedServiceName));
+ assertTrue(actualPosX.equals(expectedPosX));
+ assertTrue(actualPosY.equals(expectedPosY));
+ }
- // DE190201
- @Test
- public void changeServiceInstanceVersionToCertifiedVersion() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- /*
+ // DE190201
+ @Test
+ public void changeServiceInstanceVersionToCertifiedVersion() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ /*
* String serviceNewUniqueUid =
* ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
* serviceDetails_01.setUniqueId(serviceNewUniqueUid);
*/
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.CERTIFY);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- // RestResponse changeServiceInstanceVersionResponse =
- // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
- // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
- // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
+ // get the new VF instance uniqueId after checkout service
+ RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
+ List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
+ for (ComponentInstance component : serviceComponentInstances) {
+ if (component.getName().equals(firstVfInstanceName)) {
+ firstVfInstanceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(firstVfInstanceUniqueId != null);
+ // delete resource instance (resourceDetailsVF_01) from Service
+ RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
+ serviceDetails_01, sdncDesignerDetails);
+ assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ // Add different VF instance (resourceDetailsVF_02) to Service
+ RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(restResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
+ LifeCycleStatesEnum.STARTCERTIFICATION);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
+ LifeCycleStatesEnum.CERTIFY);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ expectedServiceName = component.getName();
+ expectedPosX = component.getPosX();
+ expectedPosY = component.getPosY();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
+ // RestResponse changeServiceInstanceVersionResponse =
+ // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
+ // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
+ // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
+ ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
+ actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
+ actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posX");
+ actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posY");
+ ComponentInstance componentInstance = ResponseParser
+ .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // Verify that Service instance name and position didn't change after
+ // changing service instance version
+ assertTrue(actualServiceInstanceName.equals(expectedServiceName));
+ assertTrue(actualPosX.equals(expectedPosX));
+ assertTrue(actualPosY.equals(expectedPosY));
+ }
- // DE191927
- @Test(enabled = false)
- public void changeServiceInstanceVersionThenReCheckInProduct() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- /////////////////////
- productOldUniqueId = productDetails_01.getUniqueId();
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- /////////////////////////////////////////////
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
+ // DE191927
+ @Test(enabled = false)
+ public void changeServiceInstanceVersionThenReCheckInProduct() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // get the new VF instance uniqueId after checkout service
+ RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
+ List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
+ for (ComponentInstance component : serviceComponentInstances) {
+ if (component.getName().equals(firstVfInstanceName)) {
+ firstVfInstanceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(firstVfInstanceUniqueId != null);
+ // delete resource instance (resourceDetailsVF_01) from Service
+ RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
+ serviceDetails_01, sdncDesignerDetails);
+ assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ // Add different VF instance (resourceDetailsVF_02) to Service
+ RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(restResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ expectedServiceName = component.getName();
+ expectedPosX = component.getPosX();
+ expectedPosY = component.getPosY();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
+ ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
+ actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
+ actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posX");
+ actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posY");
+ ComponentInstance componentInstance = ResponseParser
+ .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ /////////////////////
+ productOldUniqueId = productDetails_01.getUniqueId();
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ /////////////////////////////////////////////
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // Verify that Service instance name and position didn't change after
+ // changing service instance version
+ assertTrue(actualServiceInstanceName.equals(expectedServiceName));
+ assertTrue(actualPosX.equals(expectedPosX));
+ assertTrue(actualPosY.equals(expectedPosY));
+ }
- @Test
- public void changeServiceInstanceToHisVersion() throws Exception {
- // Get VF Instance UniquId [Service version 0.1]
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- String serviceOlderVersionUniquId = ResponseParser.getUniqueIdFromResponse(getServiceResponse);
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceOlderVersionUniquId, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
- true);
- // RestResponse changeServiceInstanceVersionResponse =
- // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
- // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
- // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
+ @Test
+ public void changeServiceInstanceToHisVersion() throws Exception {
+ // Get VF Instance UniquId [Service version 0.1]
+ RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ String serviceOlderVersionUniquId = ResponseParser.getUniqueIdFromResponse(getServiceResponse);
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // get the new VF instance uniqueId after checkout service
+ getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
+ List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
+ for (ComponentInstance component : serviceComponentInstances) {
+ if (component.getName().equals(firstVfInstanceName)) {
+ firstVfInstanceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(firstVfInstanceUniqueId != null);
+ // delete resource instance (resourceDetailsVF_01) from Service
+ RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
+ serviceDetails_01, sdncDesignerDetails);
+ assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ // Add different VF instance (resourceDetailsVF_02) to Service
+ RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(restResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ expectedServiceName = component.getName();
+ expectedPosX = component.getPosX();
+ expectedPosY = component.getPosY();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceOlderVersionUniquId, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
+ true);
+ // RestResponse changeServiceInstanceVersionResponse =
+ // changeServiceInstanceVersion(productDetails_01.getUniqueId(),
+ // serviceInstanceToReplaceUniqueId , serviceNewUniqueUid,
+ // sdncPmDetails1, ComponentTypeEnum.PRODUCT , true);
+ ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
+ actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
+ actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posX");
+ actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posY");
+ ComponentInstance componentInstance = ResponseParser
+ .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // Verify that Service instance name and position didn't change after
+ // changing service instance version
+ assertTrue(actualServiceInstanceName.equals(expectedServiceName));
+ assertTrue(actualPosX.equals(expectedPosX));
+ assertTrue(actualPosY.equals(expectedPosY));
+ }
- @Test
- public void changeServiceInstanceVersionByAdminNotByProductOwner() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ @Test
+ public void changeServiceInstanceVersionByAdminNotByProductOwner() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncAdminDetails, ComponentTypeEnum.PRODUCT,
- true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncAdminDetails, ComponentTypeEnum.PRODUCT,
+ true);
+ assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
+ changeServiceInstanceVersionResponse.getResponse());
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ }
- @Test
- public void changeServiceInstanceVersionByPmNotByProductOwner() throws Exception {
- // Adding service instance (serviceDetails_01) to product AND --->
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // change uniqueId after product check-out in expected Req&Cap
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- updateNewComponentInstanceId(createServiceInstanceResp, productNewUniqueId);
- // CHANGE Service Instance VERSION BY NON PRODUCT OWNER (sdncPmDetails1
- // instead sdncPmDetails1)
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
- productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails2,
- ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceVersionByPmNotByProductOwner() throws Exception {
+ // Adding service instance (serviceDetails_01) to product AND --->
+ // saving Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // change uniqueId after product check-out in expected Req&Cap
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ updateNewComponentInstanceId(createServiceInstanceResp, productNewUniqueId);
+ // CHANGE Service Instance VERSION BY NON PRODUCT OWNER (sdncPmDetails1
+ // instead sdncPmDetails1)
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
+ productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails2,
+ ComponentTypeEnum.PRODUCT, true);
+ assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
+ changeServiceInstanceVersionResponse.getResponse());
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- @Test
- public void changeServiceInstanceVersionByTester() throws Exception {
- // Adding service instance (serviceDetails_01) to product AND --->
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // change uniqueId after product check-out in expected Req&Cap
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // CHANGE Service Instance VERSION BY NON PRODUCT OWNER (sdncPmDetails1
- // instead sdncPmDetails1)
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
- productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid,
- sdncTesterDetails, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceVersionByTester() throws Exception {
+ // Adding service instance (serviceDetails_01) to product AND --->
+ // saving Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // change uniqueId after product check-out in expected Req&Cap
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // CHANGE Service Instance VERSION BY NON PRODUCT OWNER (sdncPmDetails1
+ // instead sdncPmDetails1)
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
+ productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid,
+ sdncTesterDetails, ComponentTypeEnum.PRODUCT, true);
+ assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
+ changeServiceInstanceVersionResponse.getResponse());
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- @Test
- public void changeServiceInstanceVersionProductIsNotCheckOut() throws Exception {
- // Adding service instance (serviceDetails_01) to product AND --->
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // CHANGE Service Instance VERSION for Non checkedOut product
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productOldUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceVersionProductIsNotCheckOut() throws Exception {
+ // Adding service instance (serviceDetails_01) to product AND --->
+ // saving Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // CHANGE Service Instance VERSION for Non checkedOut product
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productOldUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
+ assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
+ changeServiceInstanceVersionResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- // DE191727
- @Test(enabled = false)
- public void changeServiceInstanceVersionServiceIsInCheckOutState() throws Exception {
- // Adding service instance (serviceDetails_01) to product AND --->
- // saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // change uniqueId after product check-out in expected Req&Cap
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // CHANGE Service Instance VERSION to service in checkOut state
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
- productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1,
- ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(serviceNewUniqueUid);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // DE191727
+ @Test(enabled = false)
+ public void changeServiceInstanceVersionServiceIsInCheckOutState() throws Exception {
+ // Adding service instance (serviceDetails_01) to product AND --->
+ // saving Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceToReplaceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // change uniqueId after product check-out in expected Req&Cap
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // CHANGE Service Instance VERSION to service in checkOut state
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(
+ productDetails_01.getUniqueId(), serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1,
+ ComponentTypeEnum.PRODUCT, true);
+ assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add(serviceNewUniqueUid);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales,
+ changeServiceInstanceVersionResponse.getResponse());
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
- }
+ }
- @Test
- public void changeServiceInstanceVersionServiceInstanceDoesNotExist() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // change service instance to newer version
- String serviceUniqueUidNotExist = "1234567890";
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceUniqueUidNotExist, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(serviceUniqueUidNotExist);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceVersionServiceInstanceDoesNotExist() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // change service instance to newer version
+ String serviceUniqueUidNotExist = "1234567890";
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceUniqueUidNotExist, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
+ assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add(serviceUniqueUidNotExist);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name(), varibales,
+ changeServiceInstanceVersionResponse.getResponse());
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- // DE189392
- @Test(enabled = false)
- public void changeServiceInstanceNonExistingProduct() throws Exception {
- // Adding service instance (serviceDetails_01) to product saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // change service instance to newer version - Non existing Product
- String productNewUniqueIdNotExist = "1234567890";
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueIdNotExist,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(productNewUniqueIdNotExist);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ // DE189392
+ @Test(enabled = false)
+ public void changeServiceInstanceNonExistingProduct() throws Exception {
+ // Adding service instance (serviceDetails_01) to product saving Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // change service instance to newer version - Non existing Product
+ String productNewUniqueIdNotExist = "1234567890";
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueIdNotExist,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
+ assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add(productNewUniqueIdNotExist);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name(), varibales,
+ changeServiceInstanceVersionResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- @Test
- public void changeServiceInstanceVersionToNonExisitingServiceVersion() throws Exception {
- // Adding service instance (serviceDetails_01) to product saving Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- updateNewComponentInstanceId(createServiceInstanceResp, productNewUniqueId);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // change service instance to Non-existing version
- String serviceUniqueUidNotExist = "1234567890";
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceUniqueUidNotExist, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
- true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(serviceUniqueUidNotExist);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceVersionToNonExisitingServiceVersion() throws Exception {
+ // Adding service instance (serviceDetails_01) to product saving Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ updateNewComponentInstanceId(createServiceInstanceResp, productNewUniqueId);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // change service instance to Non-existing version
+ String serviceUniqueUidNotExist = "1234567890";
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceUniqueUidNotExist, sdncPmDetails1, ComponentTypeEnum.PRODUCT,
+ true);
+ assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add(serviceUniqueUidNotExist);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), varibales,
+ changeServiceInstanceVersionResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- @Test
- public void changeServiceInstanceComponentTypeIsNotProduct() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version for NON-Component Type =
- // Product (e.g. service)
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.SERVICE, true);
- assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceComponentTypeIsNotProduct() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to newer version for NON-Component Type =
+ // Product (e.g. service)
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.SERVICE, true);
+ assertEquals("Check response code ", STATUS_CODE_NOT_FOUND,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales,
+ changeServiceInstanceVersionResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- @Test
- public void changeServiceInstanceComponentTypeNotSupported() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version for NON-Component Type =
- // Product (e.g. service)
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1,
- ComponentTypeEnum.SERVICE_INSTANCE, true);
- assertEquals("Check response code ", STATUS_CODE_UNSUPPORTED_ERROR,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("null");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales,
- changeServiceInstanceVersionResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceComponentTypeNotSupported() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to newer version for NON-Component Type =
+ // Product (e.g. service)
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1,
+ ComponentTypeEnum.SERVICE_INSTANCE, true);
+ assertEquals("Check response code ", STATUS_CODE_UNSUPPORTED_ERROR,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("null");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales,
+ changeServiceInstanceVersionResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- @Test
- public void SeveralServiceInstanceFromSameServiceVersionChangeVersionOnlyForOneServiceInstance() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- serviceDetails_01.setUniqueId(serviceNewUniqueUid);
- // get the new VF instance uniqueId after checkout service
- RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
- Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
- List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
- for (ComponentInstance component : serviceComponentInstances) {
- if (component.getName().equals(firstVfInstanceName)) {
- firstVfInstanceUniqueId = component.getUniqueId();
- }
- }
- assertTrue(firstVfInstanceUniqueId != null);
- // delete resource instance (resourceDetailsVF_01) from Service
- RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
- serviceDetails_01, sdncDesignerDetails);
- assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Add different VF instance (resourceDetailsVF_02) to Service
- RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(restResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get service instance new uniqueId , name and position after checkout
- // product
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
- ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
- actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
- actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posX");
- actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
- "posY");
- ComponentInstance componentInstance = ResponseParser
- .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Verify that Service instance name and position didn't change after
- // changing service instance version
- assertTrue(actualServiceInstanceName.equals(expectedServiceName));
- assertTrue(actualPosX.equals(expectedPosX));
- assertTrue(actualPosY.equals(expectedPosY));
- }
+ @Test
+ public void SeveralServiceInstanceFromSameServiceVersionChangeVersionOnlyForOneServiceInstance() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstanceDuringSetup(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ serviceDetails_01.setUniqueId(serviceNewUniqueUid);
+ // get the new VF instance uniqueId after checkout service
+ RestResponse getServiceResponse = ServiceRestUtils.getService(serviceDetails_01.getUniqueId(), sdncPmDetails1);
+ Service service = ResponseParser.parseToObjectUsingMapper(getServiceResponse.getResponse(), Service.class);
+ List<ComponentInstance> serviceComponentInstances = service.getComponentInstances();
+ for (ComponentInstance component : serviceComponentInstances) {
+ if (component.getName().equals(firstVfInstanceName)) {
+ firstVfInstanceUniqueId = component.getUniqueId();
+ }
+ }
+ assertTrue(firstVfInstanceUniqueId != null);
+ // delete resource instance (resourceDetailsVF_01) from Service
+ RestResponse deleteVfFromServiceResponse = deleteVFInstanceDuringSetup(firstVfInstanceUniqueId,
+ serviceDetails_01, sdncDesignerDetails);
+ assertTrue(deleteVfFromServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ // Add different VF instance (resourceDetailsVF_02) to Service
+ RestResponse restResponse = createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_02,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(restResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get service instance new uniqueId , name and position after checkout
+ // product
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ expectedServiceName = component.getName();
+ expectedPosX = component.getPosX();
+ expectedPosY = component.getPosY();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, sdncPmDetails1, ComponentTypeEnum.PRODUCT, true);
+ ProductRestUtils.checkSuccess(changeServiceInstanceVersionResponse);
+ actualServiceInstanceName = ResponseParser.getNameFromResponse(changeServiceInstanceVersionResponse);
+ actualPosX = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posX");
+ actualPosY = ResponseParser.getValueFromJsonResponse(changeServiceInstanceVersionResponse.getResponse(),
+ "posY");
+ ComponentInstance componentInstance = ResponseParser
+ .parseToObjectUsingMapper(changeServiceInstanceVersionResponse.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // Verify that Service instance name and position didn't change after
+ // changing service instance version
+ assertTrue(actualServiceInstanceName.equals(expectedServiceName));
+ assertTrue(actualPosX.equals(expectedPosX));
+ assertTrue(actualPosY.equals(expectedPosY));
+ }
- @Test
- public void changeServiceInstanceVersionByNonAsdcUser() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- nonAsdcUser.setUserId("bt760h");
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, nonAsdcUser, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceVersionByNonAsdcUser() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ nonAsdcUser.setUserId("bt760h");
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, nonAsdcUser, ComponentTypeEnum.PRODUCT, true);
+ assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
+ changeServiceInstanceVersionResponse.getResponse());
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- @Test
- public void changeServiceInstanceVersionEmptyUserId() throws Exception {
- // Adding service instance (serviceDetails_01) to product without saving
- // Req&Cap
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
- sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Adding service instance (serviceDetails_02) to product AND ---> Save
- // Req&Cap
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // check-in product
- RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Checkout service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- // Check-In service [0.2]
- changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(changeStatusResponse);
- // check-out product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKOUT);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- nonAsdcUser.setUserId("");
- // change service instance to newer version
- RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
- serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, nonAsdcUser, ComponentTypeEnum.PRODUCT, true);
- assertEquals("Check response code ", STATUS_CODE_MISSING_INFORMATION,
- changeServiceInstanceVersionResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
- changeServiceInstanceVersionResponse.getResponse());
- // Check-in product
- changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
- LifeCycleStatesEnum.CHECKIN);
- ProductRestUtils.checkSuccess(changeStatusResponse);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
+ @Test
+ public void changeServiceInstanceVersionEmptyUserId() throws Exception {
+ // Adding service instance (serviceDetails_01) to product without saving
+ // Req&Cap
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01,
+ sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // Adding service instance (serviceDetails_02) to product AND ---> Save
+ // Req&Cap
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // check-in product
+ RestResponse changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productOldUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Checkout service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ String serviceNewUniqueUid = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ // Check-In service [0.2]
+ changeStatusResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(changeStatusResponse);
+ // check-out product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKOUT);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(changeStatusResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ nonAsdcUser.setUserId("");
+ // change service instance to newer version
+ RestResponse changeServiceInstanceVersionResponse = changeServiceInstanceVersion(productNewUniqueId,
+ serviceInstanceToReplaceUniqueId, serviceNewUniqueUid, nonAsdcUser, ComponentTypeEnum.PRODUCT, true);
+ assertEquals("Check response code ", STATUS_CODE_MISSING_INFORMATION,
+ changeServiceInstanceVersionResponse.getErrorCode().intValue());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
+ changeServiceInstanceVersionResponse.getResponse());
+ // Check-in product
+ changeStatusResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1,
+ LifeCycleStatesEnum.CHECKIN);
+ ProductRestUtils.checkSuccess(changeStatusResponse);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
- ////////////////////////////////////
- private void updateNewComponentInstanceId(RestResponse createServiceInstanceResp, String productNewUniqueId)
- throws Exception {
- String firstServiceInstanceNormalizedName = ResponseParser
- .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
- Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
- List<ComponentInstance> componentInstances = product.getComponentInstances();
- for (ComponentInstance component : componentInstances) {
- if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
- serviceInstanceToReplaceUniqueId = component.getUniqueId();
- expectedServiceName = component.getName();
- expectedPosX = component.getPosX();
- expectedPosY = component.getPosY();
- }
- }
- assertTrue(serviceInstanceToReplaceUniqueId != null);
- }
+ ////////////////////////////////////
+ private void updateNewComponentInstanceId(RestResponse createServiceInstanceResp, String productNewUniqueId)
+ throws Exception {
+ String firstServiceInstanceNormalizedName = ResponseParser
+ .getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ RestResponse getProductResponse = ProductRestUtils.getProduct(productNewUniqueId, sdncPmDetails1.getUserId());
+ Product product = ResponseParser.parseToObjectUsingMapper(getProductResponse.getResponse(), Product.class);
+ List<ComponentInstance> componentInstances = product.getComponentInstances();
+ for (ComponentInstance component : componentInstances) {
+ if (component.getNormalizedName().equals(firstServiceInstanceNormalizedName)) {
+ serviceInstanceToReplaceUniqueId = component.getUniqueId();
+ expectedServiceName = component.getName();
+ expectedPosX = component.getPosX();
+ expectedPosY = component.getPosY();
+ }
+ }
+ assertTrue(serviceInstanceToReplaceUniqueId != null);
+ }
- private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
+ private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ /*restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
if (restResponse.getErrorCode() == 200) {
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails,
LifeCycleStatesEnum.STARTCERTIFICATION);
} else
return restResponse;
- if (restResponse.getErrorCode() == 200) {
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails,
- LifeCycleStatesEnum.CERTIFY);
- if (restResponse.getErrorCode() == 200) {
- String newVersion = ResponseParser.getVersionFromResponse(restResponse);
- resourceDetails.setVersion(newVersion);
- resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- resourceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
- resourceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
- String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(),
- "uniqueId");
- resourceDetails.setUniqueId(uniqueIdFromRresponse);
- }
- }
- return restResponse;
- }
+ if (restResponse.getErrorCode() == 200) {*/
+ restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFY);
+ if (restResponse.getErrorCode() == 200) {
+ String newVersion = ResponseParser.getVersionFromResponse(restResponse);
+ resourceDetails.setVersion(newVersion);
+ resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
+ resourceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
+ resourceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
+ String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(),
+ "uniqueId");
+ resourceDetails.setUniqueId(uniqueIdFromRresponse);
+ }
+ return restResponse;
+ }
- private void certifyVf(ResourceReqDetails resource, ResourceReqDetails computeResource,
- ResourceReqDetails cpResource) throws Exception {
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, cpResource,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
+ private void certifyVf(ResourceReqDetails resource, ResourceReqDetails computeResource,
+ ResourceReqDetails cpResource) throws Exception {
+ RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, cpResource,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ String fromCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, computeResource,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String toCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
+ createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, computeResource,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ String toCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails,
- sdncDesignerDetails, resource.getUniqueId());
- ResourceRestUtils.checkSuccess(response);
+ RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails,
+ sdncDesignerDetails, resource.getUniqueId());
+ ResourceRestUtils.checkSuccess(response);
- String capOwnerId = toCompInstId;
- User user = sdncDesignerDetails;
- ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE;
+ String capOwnerId = toCompInstId;
+ User user = sdncDesignerDetails;
+ ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE;
- fulfillCpRequirement(resource, fromCompInstId, toCompInstId, capOwnerId, user, containerCompType);
+ fulfillCpRequirement(resource, fromCompInstId, toCompInstId, capOwnerId, user, containerCompType);
- RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource);
- ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
- }
+ RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource);
+ ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java
index 623b29b8e6..1e1a197e40 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductBaseTest.java
@@ -20,12 +20,8 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
@@ -40,8 +36,11 @@ import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.testng.annotations.BeforeMethod;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE;
public abstract class ProductBaseTest extends ComponentBaseTest {
User productStrategistUser1;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java
index 1820315841..94027bd6eb 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckinTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.testng.AssertJUnit.assertEquals;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -42,6 +40,8 @@ import org.openecomp.sdc.common.api.Constants;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.assertEquals;
+
public class ProductCheckinTest extends ProductLifecycleTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java
index ec1f7ad38d..36458d09f9 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCheckoutTest.java
@@ -20,10 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.io.FileNotFoundException;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -43,6 +39,10 @@ import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import java.io.FileNotFoundException;
+
+import static org.testng.AssertJUnit.assertEquals;
+
public class ProductCheckoutTest extends ProductLifecycleTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java
index 596825875d..f9ce315ebf 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductComponentInstanceCRUDTest.java
@@ -20,20 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_NOT_FOUND;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS_DELETE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_UNSUPPORTED_ERROR;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -52,1124 +38,1124 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
public class ProductComponentInstanceCRUDTest extends ComponentInstanceBaseTest {
- protected ArtifactReqDetails heatArtifactDetails;
- @Rule
- public static TestName name = new TestName();
-
- public ProductComponentInstanceCRUDTest() {
- super(name, ProductComponentInstanceCRUDTest.class.getName());
- }
-
- @BeforeMethod
- public void before() throws Exception {
- init();
- createComponents();
- }
-
- private void createComponents() throws Exception {
-
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- createAtomicResource(resourceDetailsVFC_01);
- changeResourceStateToCertified(resourceDetailsVFC_01);
- createAtomicResource(resourceDetailsCP_01);
- changeResourceStateToCertified(resourceDetailsCP_01);
- createAtomicResource(resourceDetailsVL_01);
- changeResourceStateToCertified(resourceDetailsVL_01);
- createAtomicResource(resourceDetailsVFC_02);
- changeResourceStateToCertified(resourceDetailsVFC_02);
- createAtomicResource(resourceDetailsCP_02);
- changeResourceStateToCertified(resourceDetailsCP_02);
- createAtomicResource(resourceDetailsVL_02);
- changeResourceStateToCertified(resourceDetailsVL_02);
- createVF(resourceDetailsVF_02);
- createVF(resourceDetailsVF_01);
- // create check-In services
- createService(serviceDetails_01);
- createService(serviceDetails_02);
- createService(serviceDetails_03);
- createProduct(productDetails_01);
- createProduct(productDetails_02);
-
- // addresourceDetailsCP_02 ,resourceDetailsVFC_02 and
- // resourceDetailsVL_02 to resourceDetailsVF_02 check-in VF
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsVFC_02, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsCP_02, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsVL_02, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- resourceDetailsVF_02.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- // addresourceDetailsCP_01 ,resourceDetailsVFC_01 and
- // resourceDetailsVL_01 to resourceDetailsVF_01 and certify
- // resourceDetailsVF_01
- certifyVf(resourceDetailsVF_01);
- createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // serviceDetails_01
- // has
- // certified
- // VF
- createVFInstanceDuringSetup(serviceDetails_02, resourceDetailsVF_02, sdncDesignerDetails); // serviceDetails_02
- // has
- // check-in
- // VF
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- }
-
- // pass
- @Test
- public void createServiceInstanceTest() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- // DE189427
- @Test(enabled = false)
- public void createServiceInstanceFromCheckedOutState() throws Exception {
- // can't create instance of checked-out component
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstanceInToAnotherServiceInstance() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String uniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, uniqueIdFromResponse, ComponentTypeEnum.PRODUCT);
- assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_NOT_FOUND);
- }
-
- @Test
- public void createSeveralServiceInstanceFromSameServices() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void createSeveralServiceInstanceFromDifferentServices() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void createCertifiedServiceInstance() throws Exception {
- changeServiceStateToCertified(serviceDetails_01);
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstanceByPm() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstanceWithoutVf() throws Exception {
- LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncAdminDetails, "0.1", LifeCycleStatesEnum.CHECKIN);
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_02, serviceDetails_03, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_02, 1, 0);
- }
-
- @Test
- public void createServiceInstanceByNonProductOwner() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails2);
- assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstanceByNonAsdcUser() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- User nonExistingSdncUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
- ;
- nonExistingSdncUser.setUserId("bt1234");
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, nonExistingSdncUser);
- assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstanceToNotCheckOutProduct() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- // pass
- @Test
- public void createServiceInstanceNameIsEmpty() throws Exception {
- String expectedServiceInstanceName = serviceDetails_01.getName() + " 1";
- String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "1";
- serviceDetails_01.setName("");
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", (expectedServiceInstancenormalizedName).toLowerCase(), instanceNormalizedName);
- assertEquals("check Resource Instance Name ", expectedServiceInstanceName, instanceName);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(expectedServiceInstanceName, actualComponentInstance.getName());
- assertEquals((expectedServiceInstancenormalizedName).toLowerCase(), actualComponentInstance.getNormalizedName());
- }
-
- // pass
- @Test
- public void createServiceInstanceNameIsNull() throws Exception {
- serviceDetails_01.setName(null);
- String expectedServiceInstanceName = (serviceDetails_01.getName() != null ? serviceDetails_01.getName() : "resourceInstanceName") + " 1";
- String expectedServiceInstancenormalizedName = (serviceDetails_01.getName() != null ? serviceDetails_01.getName() : "resourceInstanceName") + "1";
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", (expectedServiceInstancenormalizedName).toLowerCase(), instanceNormalizedName);
- assertEquals("check Resource Instance Name ", expectedServiceInstanceName, instanceName);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(expectedServiceInstanceName, actualComponentInstance.getName());
- assertEquals((expectedServiceInstancenormalizedName).toLowerCase(), actualComponentInstance.getNormalizedName());
- }
-
- @Test(enabled = false)
- public void createServiceInstanceToNonExistingProduct() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, "blabla", ComponentTypeEnum.PRODUCT);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, createServiceInstanceResp.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("blabla");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, createServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstanceToNonSupportedComponentType() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE);
- assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_UNSUPPORTED_ERROR);
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("null");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales, createServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- // pass
- @Test
- public void createServiceInstancePositionIsEmpty() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- serviceInstanceReqDetails.setPosX("");
- serviceInstanceReqDetails.setPosY("");
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- ComponentInstance componentInstance = ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstancePositionIsNull() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- serviceInstanceReqDetails.setPosX(null);
- serviceInstanceReqDetails.setPosY(null);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- ComponentInstance componentInstance = ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), ComponentInstance.class);
- addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstanceByDesigner() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncDesignerDetails);
- assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void createServiceInstanceUserIdIsEmpty() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- User nonSdncDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- nonSdncDetails.setUserId("");
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, nonSdncDetails);
- assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_MISSING_INFORMATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- //// Update Service instance
-
- @Test
- public void updateServiceInstanceNameByPm() throws Exception {
- // Check-in Product by PM and Check-out by PM
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- // Create service instance by PM
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "abcD";
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", (newName).toLowerCase(), instanceNormalizedName);
- assertEquals("check Resource Instance Name ", newName, instanceName);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(newName, actualComponentInstance.getName());
- assertEquals((newName).toLowerCase(), actualComponentInstance.getNormalizedName());
- }
-
- @Test
- public void updateServiceInstanceNewNameAndLocation() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "updaatedName100";
- serviceInstanceReqDetails.setPosX("100");
- serviceInstanceReqDetails.setPosY("100");
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
- assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
- assertEquals(newName, actualComponentInstance.getName());
- assertEquals(newName.toLowerCase(), actualComponentInstance.getNormalizedName());
- }
-
- @Test(enabled = false)
- public void updateServiceInstanceNameRemoveSpacesFromBiginningAndEnd() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = " Abcd ";
- String expectedNewName = " Abcd ";
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", (expectedNewName).toLowerCase(), instanceNormalizedName);
- assertEquals("check Resource Instance Name ", expectedNewName, instanceName);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(expectedNewName, actualComponentInstance.getName());
- assertEquals((expectedNewName).toLowerCase(), actualComponentInstance.getNormalizedName());
- }
-
- // pass
- @Test
- public void updateServiceInstanceNameAllowedCharacters() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "cier-TYUIOP_asd_0987654321.Abcd";
- String ExpectedNormalizName = "ciertyuiop_asd_0987654321abcd";
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", ExpectedNormalizName, instanceNormalizedName);
- assertEquals("check Resource Instance Name ", newName, instanceName);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(newName, actualComponentInstance.getName());
- assertEquals(ExpectedNormalizName, actualComponentInstance.getNormalizedName());
-
- }
-
- @Test
- public void updateInstanceNameInvalidCharacters() throws Exception {
- char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', '|', '\\', ',' };
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "Abcd1";
- String updateName;
- for (int i = 0; i < invalidChars.length; i++) {
- updateName = newName + invalidChars[i];
- serviceInstanceReqDetails.setName(updateName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- assertEquals("Check response code ", STATUS_CODE_INVALID_CONTENT, updateServiceInstanceResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("Service Instance");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), varibales, updateServiceInstanceResponse.getResponse());
- }
- }
-
- // pass
- @Test
- public void updateInstanceNameMaxLength() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "Qwertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl12345";
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", (newName).toLowerCase(), instanceNormalizedName);
- assertEquals("check Resource Instance Name ", newName, instanceName);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(newName, actualComponentInstance.getName());
- assertEquals((newName).toLowerCase(), actualComponentInstance.getNormalizedName());
- }
-
- @Test
- public void updateInstanceNameExceedMaxLength() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String expectedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
- String expectedNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
- String newName = "Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456";
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- assertEquals("Check response code ", STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT, updateServiceInstanceResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("Service Instance");
- varibales.add("1024");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), varibales, updateServiceInstanceResponse.getResponse());
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(expectedName, actualComponentInstance.getName());
- assertEquals(expectedNormalizedName, actualComponentInstance.getNormalizedName());
- }
-
- @Test
- public void updateServiceInstanceNameEmpty() throws Exception {
- // see US534663 In case a PS/PM removes the current service instance
- // name then BE has to generate again the "default" service instance
- // name
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "";
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + "2").toLowerCase(), instanceNormalizedName);
- assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 2"), instanceName);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(instanceName, actualComponentInstance.getName());
- assertEquals(instanceNormalizedName, actualComponentInstance.getNormalizedName());
- }
-
- // pass
- @Test
- public void updateServiceInstanceNameNull() throws Exception {
- // see US534663 In case a PS/PM removes the current service instance
- // name then BE has to generate again the "default" service instance
- // name
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = null;
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + "1").toLowerCase(), instanceNormalizedName);
- assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 1"), instanceName);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(instanceName, actualComponentInstance.getName());
- assertEquals(instanceNormalizedName, actualComponentInstance.getNormalizedName());
- }
-
- @Test
- public void updateServiceInstanceCheckedByOtherUser() throws Exception {
- // see US534663 In case a PS/PM removes the current service instance
- // name then BE has to generate again the "default" service instance
- // name
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "blabla";
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails2, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, updateServiceInstanceResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateServiceInstanceResponse.getResponse());
- }
-
- @Test
- public void updateServiceInstance_UserIdIsNonAsdcUser() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "blabla";
- serviceInstanceReqDetails.setName(newName);
- User nonSdncUserDetails = new User();
- nonSdncUserDetails.setUserId("bt4567");
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, nonSdncUserDetails, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, updateServiceInstanceResponse.getErrorCode().intValue());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateServiceInstanceResponse.getResponse());
- }
-
- @Test
- public void updateServiceInstanceNameToAlreadyExisting() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String ServiceName1 = ResponseParser.getNameFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // Update service instance2 name to service instance1
- serviceInstanceReqDetails.setName(ServiceName1);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- assertEquals("Check response code ", STATUS_CODE_ALREADY_EXISTS, updateServiceInstanceResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("Service Instance");
- varibales.add(ServiceName1);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name(), varibales, updateServiceInstanceResponse.getResponse());
- }
-
- @Test
- public void updateServiceInstanceForNonExistingProduct() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "blabla";
- serviceInstanceReqDetails.setName(newName);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, "blablabla", ComponentTypeEnum.PRODUCT);
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, updateServiceInstanceResponse.getErrorCode().intValue());
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, updateServiceInstanceResponse.getResponse());
-
- }
-
- @Test
- public void updateNonExistingServiceInstance() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String newName = "blabla";
- serviceInstanceReqDetails.setName(newName);
- serviceInstanceReqDetails.setUniqueId("11111111");
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add(newName);
- varibales.add("service instance");
- AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, updateServiceInstanceResponse.getErrorCode().intValue());
- // need to change ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name() to
- // ActionStatus.SERVICE_INSTANCE_NOT_FOUND.name()
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND.name(), varibales, updateServiceInstanceResponse.getResponse());
- }
-
- @Test
- public void updateServiceInstanceLocation() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- serviceInstanceReqDetails.setPosX("50");
- serviceInstanceReqDetails.setPosY("100");
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
- assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
- }
-
- @Test
- public void updateServiceInstanceToNonExistingLocation() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- String nameFromResponse = ResponseParser.getNameFromResponse(createServiceInstanceResp);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- serviceInstanceReqDetails.setPosX("-50");
- serviceInstanceReqDetails.setPosY("-100");
- serviceInstanceReqDetails.setName(nameFromResponse);
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
- assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
- assertEquals(nameFromResponse, actualComponentInstance.getName());
- }
-
- @Test (enabled = false)
- public void updateServiceInstanceLocationNameIsEmpty() throws Exception {
- String expectedServiceInstanceName = serviceDetails_01.getName() + " 2";
- String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "2";
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- serviceInstanceReqDetails.setPosX("100");
- serviceInstanceReqDetails.setPosY("200");
- serviceInstanceReqDetails.setName("");
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- String nameFromResponse = ResponseParser.getNameFromResponse(updateServiceInstanceResponse);
- String postX = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "posX");
- String postY = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "posY");
- assertEquals(nameFromResponse, expectedServiceInstanceName);
- assertEquals(postX, "100");
- assertEquals(postY, "200");
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
- assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
- assertEquals(nameFromResponse, actualComponentInstance.getName());
- assertEquals(expectedServiceInstancenormalizedName.toLowerCase(), actualComponentInstance.getNormalizedName());
- }
-
- // pass
- @Test
- public void updateServiceInstanceNameToProductName() throws Exception {
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
- RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // ComponentInstance componentInstance =
- // ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(),
- // ComponentInstance.class);
- // addCompInstReqCapToExpected(componentInstance,
- // ComponentTypeEnum.PRODUCT);
- serviceInstanceReqDetails.setName(productDetails_01.getName());
- RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
- String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
- String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
- assertEquals("check Resource Instance normalizedName ", (serviceInstanceReqDetails.getName()).toLowerCase(), instanceNormalizedName);
- assertEquals("check Resource Instance Name ", serviceInstanceReqDetails.getName(), instanceName);
- // get product and verify that service instanceName is correct
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- assertEquals(serviceInstanceReqDetails.getName(), actualComponentInstance.getName());
- assertEquals((serviceInstanceReqDetails.getName()).toLowerCase(), actualComponentInstance.getNormalizedName());
- }
-
- //// Delete Service Instance
-
- @Test
- public void deleteAllServiceInstanceFromProduct() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- getComponentAndValidateRIs(productDetails_01, 0, 0);
- }
-
- @Test
- public void deleteServiceWhileServiceInstanceExistInProduct() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- // Delete service while service instance of it exist in product
- RestResponse deleteServiceResponse = ServiceRestUtils.deleteServiceById(serviceDetails_01.getUniqueId(), sdncDesignerDetails.getUserId());
- assertTrue(deleteServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- // Get product and verify that service instance still exists
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- // ComponentInstance actualComponentInstance =
- // actualProduct.getComponentInstances().get(0);
- // assertTrue(serviceInstanceUniqueIdFromResponse ==
- // actualComponentInstance.getUniqueId());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- // pass
- @Test
- public void deleteServiceInstanceByPm() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void deleteServiceInstanceByPmCreatedByPm() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- productDetails_01.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void deleteServiceInstanceByPmWhichIsCheckedOutByAnotherPm() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails2);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- // DE190189
- @Test
- public void deleteServiceInstanceByPmCreatedByPs() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- String productOldUniqueId = productDetails_01.getUniqueId();
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(restResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get product and get service instance new uniquId
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- String serviceInstanceUniqueId = actualComponentInstance.getUniqueId();
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- getComponentAndValidateRIs(productDetails_01, 0, 0);
- }
-
- // DE190189
- @Test
- public void deleteServiceInstanceByAdminCreatedByPs() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- String productOldUniqueId = productDetails_01.getUniqueId();
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(restResponse);
- updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
- // get product and get service instance new uniquId
- RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncAdminDetails.getUserId());
- Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
- ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
- String serviceInstanceUniqueId = actualComponentInstance.getUniqueId();
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncAdminDetails);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- getComponentAndValidateRIs(productDetails_01, 0, 0);
- }
-
- @Test
- public void createAndDeleteServiceInstanceByAdmin() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails, LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- // productDetails_01.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncAdminDetails);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncAdminDetails);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncAdminDetails);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void deleteServiceInstanceFromNonCheckOutProduct() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void deleteServiceInstanceByDesigner() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncDesignerDetails);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void deleteServiceInstanceByTester() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncTesterDetails);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void deleteServiceInstanceByPsWhichIsCheckedOutByAnotherPs() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPsDetails2);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- // pass
- @Test
- public void deleteServiceInstanceByNonAsdcUser() throws Exception {
- User nonExistingSdncUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
- ;
- nonExistingSdncUser.setUserId("bt1234");
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, nonExistingSdncUser);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void deleteServiceInstanceFromNonExistingProduct() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, "1234567890", serviceInstanceUniqueId, ComponentTypeEnum.PRODUCT);
- assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void deleteNonExistingServiceInstanceFromProduct() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- // String serviceInstanceUniqueId =
- // ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), "1234567890123456unExistingServiceInstance", ComponentTypeEnum.PRODUCT);
- assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("1234567890123456unExistingServiceInstance");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void deleteServiceInstanceFromNonSupportedComponentType() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), serviceInstanceUniqueId, ComponentTypeEnum.RESOURCE_INSTANCE);
- assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_UNSUPPORTED_ERROR);
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("null");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales, deleteResourceInstanceResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void deleteServiceInstanceComponentTypeIsNotProduct() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), serviceInstanceUniqueId, ComponentTypeEnum.SERVICE);
- assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
- ArrayList<String> varibales = new ArrayList<String>();
- varibales.add("");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse());
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- }
-
- @Test
- public void deleteServiceInstanceUserIdIsEmpty() throws Exception {
- User nonSdncDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- nonSdncDetails.setUserId("");
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, nonSdncDetails);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_MISSING_INFORMATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- @Test
- public void deleteCertifiedServiceInstance() throws Exception {
- changeServiceStateToCertified(serviceDetails_01);
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
- assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- }
-
- ////////////////////////////////////
-
- private void certifyVf(ResourceReqDetails resource) throws Exception {
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String cpCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_02, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String computeCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01, sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String vlCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- // Fixing Vl/Cp req/cap
- ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE;
- User user = sdncDesignerDetails;
- fulfillCpRequirement(resource, cpCompInstId, computeCompInstId, computeCompInstId, user, containerCompType);
- consumeVlCapability(resource, cpCompInstId, vlCompInstId, cpCompInstId, user, containerCompType);
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails, resource.getUniqueId());
- ResourceRestUtils.checkSuccess(response);
- RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource);
- ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
- }
-
- private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
+ protected ArtifactReqDetails heatArtifactDetails;
+ @Rule
+ public static TestName name = new TestName();
+
+ public ProductComponentInstanceCRUDTest() {
+ super(name, ProductComponentInstanceCRUDTest.class.getName());
+ }
+
+ @BeforeMethod
+ public void before() throws Exception {
+ init();
+ createComponents();
+ }
+
+ private void createComponents() throws Exception {
+
+ heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
+ createAtomicResource(resourceDetailsVFC_01);
+ changeResourceStateToCertified(resourceDetailsVFC_01);
+ createAtomicResource(resourceDetailsCP_01);
+ changeResourceStateToCertified(resourceDetailsCP_01);
+ createAtomicResource(resourceDetailsVL_01);
+ changeResourceStateToCertified(resourceDetailsVL_01);
+ createAtomicResource(resourceDetailsVFC_02);
+ changeResourceStateToCertified(resourceDetailsVFC_02);
+ createAtomicResource(resourceDetailsCP_02);
+ changeResourceStateToCertified(resourceDetailsCP_02);
+ createAtomicResource(resourceDetailsVL_02);
+ changeResourceStateToCertified(resourceDetailsVL_02);
+ createVF(resourceDetailsVF_02);
+ createVF(resourceDetailsVF_01);
+ // create check-In services
+ createService(serviceDetails_01);
+ createService(serviceDetails_02);
+ createService(serviceDetails_03);
+ createProduct(productDetails_01);
+ createProduct(productDetails_02);
+
+ // addresourceDetailsCP_02 ,resourceDetailsVFC_02 and
+ // resourceDetailsVL_02 to resourceDetailsVF_02 check-in VF
+ RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsVFC_02, sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsCP_02, sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resourceDetailsVF_02, resourceDetailsVL_02, sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
+ resourceDetailsVF_02.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ // addresourceDetailsCP_01 ,resourceDetailsVFC_01 and
+ // resourceDetailsVL_01 to resourceDetailsVF_01 and certify
+ // resourceDetailsVF_01
+ certifyVf(resourceDetailsVF_01);
+ createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // serviceDetails_01
+ // has
+ // certified
+ // VF
+ createVFInstanceDuringSetup(serviceDetails_02, resourceDetailsVF_02, sdncDesignerDetails); // serviceDetails_02
+ // has
+ // check-in
+ // VF
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ }
+
+ // pass
+ @Test
+ public void createServiceInstanceTest() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ // DE189427
+ @Test(enabled = false)
+ public void createServiceInstanceFromCheckedOutState() throws Exception {
+ // can't create instance of checked-out component
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceInToAnotherServiceInstance() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String uniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, uniqueIdFromResponse, ComponentTypeEnum.PRODUCT);
+ assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_NOT_FOUND);
+ }
+
+ @Test
+ public void createSeveralServiceInstanceFromSameServices() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void createSeveralServiceInstanceFromDifferentServices() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void createCertifiedServiceInstance() throws Exception {
+ changeServiceStateToCertified(serviceDetails_01);
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceByPm() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceWithoutVf() throws Exception {
+ LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncAdminDetails, "0.1", LifeCycleStatesEnum.CHECKIN);
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_02, serviceDetails_03, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_02, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceByNonProductOwner() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails2);
+ assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceByNonAsdcUser() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ User nonExistingSdncUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
+ ;
+ nonExistingSdncUser.setUserId("bt1234");
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, nonExistingSdncUser);
+ assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceToNotCheckOutProduct() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ // pass
+ @Test
+ public void createServiceInstanceNameIsEmpty() throws Exception {
+ String expectedServiceInstanceName = serviceDetails_01.getName() + " 1";
+ String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "1";
+ serviceDetails_01.setName("");
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", (expectedServiceInstancenormalizedName).toLowerCase(), instanceNormalizedName);
+ assertEquals("check Resource Instance Name ", expectedServiceInstanceName, instanceName);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(expectedServiceInstanceName, actualComponentInstance.getName());
+ assertEquals((expectedServiceInstancenormalizedName).toLowerCase(), actualComponentInstance.getNormalizedName());
+ }
+
+ // pass
+ @Test
+ public void createServiceInstanceNameIsNull() throws Exception {
+ serviceDetails_01.setName(null);
+ String expectedServiceInstanceName = (serviceDetails_01.getName() != null ? serviceDetails_01.getName() : "resourceInstanceName") + " 1";
+ String expectedServiceInstancenormalizedName = (serviceDetails_01.getName() != null ? serviceDetails_01.getName() : "resourceInstanceName") + "1";
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", (expectedServiceInstancenormalizedName).toLowerCase(), instanceNormalizedName);
+ assertEquals("check Resource Instance Name ", expectedServiceInstanceName, instanceName);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(expectedServiceInstanceName, actualComponentInstance.getName());
+ assertEquals((expectedServiceInstancenormalizedName).toLowerCase(), actualComponentInstance.getNormalizedName());
+ }
+
+ @Test(enabled = false)
+ public void createServiceInstanceToNonExistingProduct() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, "blabla", ComponentTypeEnum.PRODUCT);
+ AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, createServiceInstanceResp.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("blabla");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, createServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceToNonSupportedComponentType() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE);
+ assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_UNSUPPORTED_ERROR);
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("null");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales, createServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ // pass
+ @Test
+ public void createServiceInstancePositionIsEmpty() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ serviceInstanceReqDetails.setPosX("");
+ serviceInstanceReqDetails.setPosY("");
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ ComponentInstance componentInstance = ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstancePositionIsNull() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ serviceInstanceReqDetails.setPosX(null);
+ serviceInstanceReqDetails.setPosY(null);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ ComponentInstance componentInstance = ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(), ComponentInstance.class);
+ addCompInstReqCapToExpected(componentInstance, ComponentTypeEnum.PRODUCT);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceByDesigner() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncDesignerDetails);
+ assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void createServiceInstanceUserIdIsEmpty() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ User nonSdncDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
+ nonSdncDetails.setUserId("");
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, nonSdncDetails);
+ assertTrue(createServiceInstanceResp.getErrorCode() == STATUS_CODE_MISSING_INFORMATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), createServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ //// Update Service instance
+
+ @Test
+ public void updateServiceInstanceNameByPm() throws Exception {
+ // Check-in Product by PM and Check-out by PM
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ // Create service instance by PM
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "abcD";
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", (newName).toLowerCase(), instanceNormalizedName);
+ assertEquals("check Resource Instance Name ", newName, instanceName);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(newName, actualComponentInstance.getName());
+ assertEquals((newName).toLowerCase(), actualComponentInstance.getNormalizedName());
+ }
+
+ @Test
+ public void updateServiceInstanceNewNameAndLocation() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "updaatedName100";
+ serviceInstanceReqDetails.setPosX("100");
+ serviceInstanceReqDetails.setPosY("100");
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
+ assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
+ assertEquals(newName, actualComponentInstance.getName());
+ assertEquals(newName.toLowerCase(), actualComponentInstance.getNormalizedName());
+ }
+
+ @Test(enabled = false)
+ public void updateServiceInstanceNameRemoveSpacesFromBiginningAndEnd() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = " Abcd ";
+ String expectedNewName = " Abcd ";
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", (expectedNewName).toLowerCase(), instanceNormalizedName);
+ assertEquals("check Resource Instance Name ", expectedNewName, instanceName);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(expectedNewName, actualComponentInstance.getName());
+ assertEquals((expectedNewName).toLowerCase(), actualComponentInstance.getNormalizedName());
+ }
+
+ // pass
+ @Test
+ public void updateServiceInstanceNameAllowedCharacters() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "cier-TYUIOP_asd_0987654321.Abcd";
+ String ExpectedNormalizName = "ciertyuiop_asd_0987654321abcd";
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", ExpectedNormalizName, instanceNormalizedName);
+ assertEquals("check Resource Instance Name ", newName, instanceName);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(newName, actualComponentInstance.getName());
+ assertEquals(ExpectedNormalizName, actualComponentInstance.getNormalizedName());
+
+ }
+
+ @Test
+ public void updateInstanceNameInvalidCharacters() throws Exception {
+ char invalidChars[] = {'~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/', '|', '\\', ','};
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "Abcd1";
+ String updateName;
+ for (int i = 0; i < invalidChars.length; i++) {
+ updateName = newName + invalidChars[i];
+ serviceInstanceReqDetails.setName(updateName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ assertEquals("Check response code ", STATUS_CODE_INVALID_CONTENT, updateServiceInstanceResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("Service Instance");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), varibales, updateServiceInstanceResponse.getResponse());
+ }
+ }
+
+ // pass
+ @Test
+ public void updateInstanceNameMaxLength() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "Qwertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl12345";
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", (newName).toLowerCase(), instanceNormalizedName);
+ assertEquals("check Resource Instance Name ", newName, instanceName);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(newName, actualComponentInstance.getName());
+ assertEquals((newName).toLowerCase(), actualComponentInstance.getNormalizedName());
+ }
+
+ @Test
+ public void updateInstanceNameExceedMaxLength() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String expectedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "name");
+ String expectedNormalizedName = ResponseParser.getValueFromJsonResponse(createServiceInstanceResp.getResponse(), "normalizedName");
+ String newName = "Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ciertyuiop1234567890asdfAhjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456Ahjklzxcvbnmasdfghjkl123456";
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ assertEquals("Check response code ", STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT, updateServiceInstanceResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("Service Instance");
+ varibales.add("1024");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), varibales, updateServiceInstanceResponse.getResponse());
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(expectedName, actualComponentInstance.getName());
+ assertEquals(expectedNormalizedName, actualComponentInstance.getNormalizedName());
+ }
+
+ @Test
+ public void updateServiceInstanceNameEmpty() throws Exception {
+ // see US534663 In case a PS/PM removes the current service instance
+ // name then BE has to generate again the "default" service instance
+ // name
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "";
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + "2").toLowerCase(), instanceNormalizedName);
+ assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 2"), instanceName);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(instanceName, actualComponentInstance.getName());
+ assertEquals(instanceNormalizedName, actualComponentInstance.getNormalizedName());
+ }
+
+ // pass
+ @Test
+ public void updateServiceInstanceNameNull() throws Exception {
+ // see US534663 In case a PS/PM removes the current service instance
+ // name then BE has to generate again the "default" service instance
+ // name
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = null;
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + "1").toLowerCase(), instanceNormalizedName);
+ assertEquals("check Resource Instance normalizedName ", (serviceDetails_01.getName() + " 1"), instanceName);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(instanceName, actualComponentInstance.getName());
+ assertEquals(instanceNormalizedName, actualComponentInstance.getNormalizedName());
+ }
+
+ @Test
+ public void updateServiceInstanceCheckedByOtherUser() throws Exception {
+ // see US534663 In case a PS/PM removes the current service instance
+ // name then BE has to generate again the "default" service instance
+ // name
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "blabla";
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails2, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, updateServiceInstanceResponse.getErrorCode().intValue());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateServiceInstanceResponse.getResponse());
+ }
+
+ @Test
+ public void updateServiceInstance_UserIdIsNonAsdcUser() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "blabla";
+ serviceInstanceReqDetails.setName(newName);
+ User nonSdncUserDetails = new User();
+ nonSdncUserDetails.setUserId("bt4567");
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, nonSdncUserDetails, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ assertEquals("Check response code ", STATUS_CODE_RESTRICTED_OPERATION, updateServiceInstanceResponse.getErrorCode().intValue());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), updateServiceInstanceResponse.getResponse());
+ }
+
+ @Test
+ public void updateServiceInstanceNameToAlreadyExisting() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String ServiceName1 = ResponseParser.getNameFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // Update service instance2 name to service instance1
+ serviceInstanceReqDetails.setName(ServiceName1);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ assertEquals("Check response code ", STATUS_CODE_ALREADY_EXISTS, updateServiceInstanceResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("Service Instance");
+ varibales.add(ServiceName1);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name(), varibales, updateServiceInstanceResponse.getResponse());
+ }
+
+ @Test
+ public void updateServiceInstanceForNonExistingProduct() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "blabla";
+ serviceInstanceReqDetails.setName(newName);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, "blablabla", ComponentTypeEnum.PRODUCT);
+ AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, updateServiceInstanceResponse.getErrorCode().intValue());
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, updateServiceInstanceResponse.getResponse());
+
+ }
+
+ @Test
+ public void updateNonExistingServiceInstance() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String newName = "blabla";
+ serviceInstanceReqDetails.setName(newName);
+ serviceInstanceReqDetails.setUniqueId("11111111");
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add(newName);
+ varibales.add("service instance");
+ AssertJUnit.assertEquals("Check response code ", STATUS_CODE_NOT_FOUND, updateServiceInstanceResponse.getErrorCode().intValue());
+ // need to change ActionStatus.RESOURCE_INSTANCE_NOT_FOUND.name() to
+ // ActionStatus.SERVICE_INSTANCE_NOT_FOUND.name()
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND.name(), varibales, updateServiceInstanceResponse.getResponse());
+ }
+
+ @Test
+ public void updateServiceInstanceLocation() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ serviceInstanceReqDetails.setPosX("50");
+ serviceInstanceReqDetails.setPosY("100");
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
+ assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
+ }
+
+ @Test
+ public void updateServiceInstanceToNonExistingLocation() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ String nameFromResponse = ResponseParser.getNameFromResponse(createServiceInstanceResp);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ serviceInstanceReqDetails.setPosX("-50");
+ serviceInstanceReqDetails.setPosY("-100");
+ serviceInstanceReqDetails.setName(nameFromResponse);
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
+ assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
+ assertEquals(nameFromResponse, actualComponentInstance.getName());
+ }
+
+ @Test(enabled = false)
+ public void updateServiceInstanceLocationNameIsEmpty() throws Exception {
+ String expectedServiceInstanceName = serviceDetails_01.getName() + " 2";
+ String expectedServiceInstancenormalizedName = serviceDetails_01.getName() + "2";
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ serviceInstanceReqDetails.setPosX("100");
+ serviceInstanceReqDetails.setPosY("200");
+ serviceInstanceReqDetails.setName("");
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ String nameFromResponse = ResponseParser.getNameFromResponse(updateServiceInstanceResponse);
+ String postX = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "posX");
+ String postY = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "posY");
+ assertEquals(nameFromResponse, expectedServiceInstanceName);
+ assertEquals(postX, "100");
+ assertEquals(postY, "200");
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(serviceInstanceReqDetails.getPosX(), actualComponentInstance.getPosX());
+ assertEquals(serviceInstanceReqDetails.getPosY(), actualComponentInstance.getPosY());
+ assertEquals(nameFromResponse, actualComponentInstance.getName());
+ assertEquals(expectedServiceInstancenormalizedName.toLowerCase(), actualComponentInstance.getNormalizedName());
+ }
+
+ // pass
+ @Test
+ public void updateServiceInstanceNameToProductName() throws Exception {
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_01);
+ RestResponse createServiceInstanceResp = ComponentInstanceRestUtils.createComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // ComponentInstance componentInstance =
+ // ResponseParser.parseToObjectUsingMapper(createServiceInstanceResp.getResponse(),
+ // ComponentInstance.class);
+ // addCompInstReqCapToExpected(componentInstance,
+ // ComponentTypeEnum.PRODUCT);
+ serviceInstanceReqDetails.setName(productDetails_01.getName());
+ RestResponse updateServiceInstanceResponse = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ResourceRestUtils.checkSuccess(updateServiceInstanceResponse);
+ String instanceNormalizedName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "normalizedName");
+ String instanceName = ResponseParser.getValueFromJsonResponse(updateServiceInstanceResponse.getResponse(), "name");
+ assertEquals("check Resource Instance normalizedName ", (serviceInstanceReqDetails.getName()).toLowerCase(), instanceNormalizedName);
+ assertEquals("check Resource Instance Name ", serviceInstanceReqDetails.getName(), instanceName);
+ // get product and verify that service instanceName is correct
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ assertEquals(serviceInstanceReqDetails.getName(), actualComponentInstance.getName());
+ assertEquals((serviceInstanceReqDetails.getName()).toLowerCase(), actualComponentInstance.getNormalizedName());
+ }
+
+ //// Delete Service Instance
+
+ @Test
+ public void deleteAllServiceInstanceFromProduct() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ getComponentAndValidateRIs(productDetails_01, 0, 0);
+ }
+
+ @Test
+ public void deleteServiceWhileServiceInstanceExistInProduct() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ // Delete service while service instance of it exist in product
+ RestResponse deleteServiceResponse = ServiceRestUtils.deleteServiceById(serviceDetails_01.getUniqueId(), sdncDesignerDetails.getUserId());
+ assertTrue(deleteServiceResponse.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ // Get product and verify that service instance still exists
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ // ComponentInstance actualComponentInstance =
+ // actualProduct.getComponentInstances().get(0);
+ // assertTrue(serviceInstanceUniqueIdFromResponse ==
+ // actualComponentInstance.getUniqueId());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ // pass
+ @Test
+ public void deleteServiceInstanceByPm() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceByPmCreatedByPm() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ productDetails_01.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceByPmWhichIsCheckedOutByAnotherPm() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails2);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ // DE190189
+ @Test
+ public void deleteServiceInstanceByPmCreatedByPs() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ String productOldUniqueId = productDetails_01.getUniqueId();
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(restResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get product and get service instance new uniquId
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPmDetails1.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ String serviceInstanceUniqueId = actualComponentInstance.getUniqueId();
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ getComponentAndValidateRIs(productDetails_01, 0, 0);
+ }
+
+ // DE190189
+ @Test
+ public void deleteServiceInstanceByAdminCreatedByPs() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ String productOldUniqueId = productDetails_01.getUniqueId();
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ String productNewUniqueId = ResponseParser.getUniqueIdFromResponse(restResponse);
+ updateExpectedReqCapAfterChangeLifecycleState(productOldUniqueId, productNewUniqueId);
+ // get product and get service instance new uniquId
+ RestResponse getActualProductResponse = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncAdminDetails.getUserId());
+ Product actualProduct = ResponseParser.parseToObjectUsingMapper(getActualProductResponse.getResponse(), Product.class);
+ ComponentInstance actualComponentInstance = actualProduct.getComponentInstances().get(0);
+ String serviceInstanceUniqueId = actualComponentInstance.getUniqueId();
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncAdminDetails);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ getComponentAndValidateRIs(productDetails_01, 0, 0);
+ }
+
+ @Test
+ public void createAndDeleteServiceInstanceByAdmin() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncAdminDetails, LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ // productDetails_01.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncAdminDetails);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncAdminDetails);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncAdminDetails);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceFromNonCheckOutProduct() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ RestResponse restResponse = LifecycleRestUtils.changeProductState(productDetails_01, sdncPmDetails1, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceByDesigner() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncDesignerDetails);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceByTester() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncTesterDetails);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceByPsWhichIsCheckedOutByAnotherPs() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPsDetails2);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ // pass
+ @Test
+ public void deleteServiceInstanceByNonAsdcUser() throws Exception {
+ User nonExistingSdncUser = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
+ ;
+ nonExistingSdncUser.setUserId("bt1234");
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, nonExistingSdncUser);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceFromNonExistingProduct() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, "1234567890", serviceInstanceUniqueId, ComponentTypeEnum.PRODUCT);
+ assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void deleteNonExistingServiceInstanceFromProduct() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ // String serviceInstanceUniqueId =
+ // ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), "1234567890123456unExistingServiceInstance", ComponentTypeEnum.PRODUCT);
+ assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("1234567890123456unExistingServiceInstance");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.PRODUCT_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceFromNonSupportedComponentType() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), serviceInstanceUniqueId, ComponentTypeEnum.RESOURCE_INSTANCE);
+ assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_UNSUPPORTED_ERROR);
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("null");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(), varibales, deleteResourceInstanceResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceComponentTypeIsNotProduct() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(sdncPmDetails1, productDetails_01.getUniqueId(), serviceInstanceUniqueId, ComponentTypeEnum.SERVICE);
+ assertTrue(deleteResourceInstanceResponse.getErrorCode() == STATUS_CODE_NOT_FOUND);
+ ArrayList<String> varibales = new ArrayList<String>();
+ varibales.add("");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), varibales, deleteResourceInstanceResponse.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ }
+
+ @Test
+ public void deleteServiceInstanceUserIdIsEmpty() throws Exception {
+ User nonSdncDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
+ nonSdncDetails.setUserId("");
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, nonSdncDetails);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_MISSING_INFORMATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(), deleteServiceInstanceResp.getResponse());
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ @Test
+ public void deleteCertifiedServiceInstance() throws Exception {
+ changeServiceStateToCertified(serviceDetails_01);
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceInstanceUniqueId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(serviceInstanceUniqueId, productDetails_01, sdncPmDetails1);
+ assertTrue(deleteServiceInstanceResp.getErrorCode() == STATUS_CODE_SUCCESS_DELETE);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ }
+
+ ////////////////////////////////////
+
+ private void certifyVf(ResourceReqDetails resource) throws Exception {
+ RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01, sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ String cpCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
+
+ createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_02, sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ String computeCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
+
+ createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01, sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ String vlCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
+
+ // Fixing Vl/Cp req/cap
+ ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE;
+ User user = sdncDesignerDetails;
+ fulfillCpRequirement(resource, cpCompInstId, computeCompInstId, computeCompInstId, user, containerCompType);
+ consumeVlCapability(resource, cpCompInstId, vlCompInstId, cpCompInstId, user, containerCompType);
+
+ RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails, resource.getUniqueId());
+ ResourceRestUtils.checkSuccess(response);
+ RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource);
+ ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
+ }
+
+ private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception {
+/* RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
if (restResponse.getErrorCode() == 200) {
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails, LifeCycleStatesEnum.STARTCERTIFICATION);
} else
return restResponse;
- if (restResponse.getErrorCode() == 200) {
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails, LifeCycleStatesEnum.CERTIFY);
- if (restResponse.getErrorCode() == 200) {
- String newVersion = ResponseParser.getVersionFromResponse(restResponse);
- resourceDetails.setVersion(newVersion);
- resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- resourceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
- resourceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
- String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), "uniqueId");
- resourceDetails.setUniqueId(uniqueIdFromRresponse);
- }
- }
+ if (restResponse.getErrorCode() == 200) {*/
+ RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFY);
+ if (restResponse.getErrorCode() == 200) {
+ String newVersion = ResponseParser.getVersionFromResponse(restResponse);
+ resourceDetails.setVersion(newVersion);
+ resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
+ resourceDetails.setLastUpdaterUserId(sdncDesignerDetails.getUserId());
+ resourceDetails.setLastUpdaterFullName(sdncDesignerDetails.getFullName());
+ String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), "uniqueId");
+ resourceDetails.setUniqueId(uniqueIdFromRresponse);
+ }
return restResponse;
- }
+}
- private RestResponse changeServiceStateToCertified(ServiceReqDetails serviceDetails) throws Exception {
+ private RestResponse changeServiceStateToCertified(ServiceReqDetails serviceDetails) throws Exception {
/*
* RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CHECKIN); ResourceRestUtils.checkSuccess(restResponse);
*/
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- if (restResponse.getErrorCode() == 200) {
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, LifeCycleStatesEnum.STARTCERTIFICATION);
- } else
- return restResponse;
- if (restResponse.getErrorCode() == 200) {
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, LifeCycleStatesEnum.CERTIFY);
- if (restResponse.getErrorCode() == 200) {
- serviceDetails.setVersion("1.0");
- serviceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- serviceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
- serviceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
- String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), "uniqueId");
- serviceDetails.setUniqueId(uniqueIdFromRresponse);
- }
- }
- return restResponse;
- }
-
- @Test
- public void deleteServiceInstanceTest() throws Exception {
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
- String compInstId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
-
- createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 2, 0);
- String compInstId2 = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
-
- RestResponse deleteServiceInstanceResp = deleteServiceInstance(compInstId, productDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 1, 0);
-
- deleteServiceInstanceResp = deleteServiceInstance(compInstId2, productDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp);
- getComponentAndValidateRIs(productDetails_01, 0, 0);
- }
-
- @Test
- public void returnedServiceInstanceTypeAttributeTest() throws Exception {
- String expectedServiceType = ComponentTypeEnum.SERVICE.getValue().toUpperCase();
-
- RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
- ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
- String serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
- ComponentInstanceRestUtils.checkComponentInstanceType(createServiceInstanceResp, expectedServiceType);
-
- RestResponse getProductResp = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPsDetails1.getUserId());
- ProductRestUtils.checkSuccess(getProductResp);
- Product productObject = ResponseParser.parseToObjectUsingMapper(getProductResp.getResponse(), Product.class);
- List<ComponentInstance> productComponentInstances = productObject.getComponentInstances();
- for (ComponentInstance comp : productComponentInstances) {
- String actualOriginType = comp.getOriginType().getValue().toUpperCase();
- assertTrue(expectedServiceType.equals(actualOriginType));
- }
-
- ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_02);
- serviceInstanceReqDetails.setUniqueId(serviceUniqueIdFromResponse);
- serviceInstanceReqDetails.setComponentUid(serviceDetails_01.getUniqueId());
- RestResponse updateResourceInstance = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
- ComponentInstanceRestUtils.checkSuccess(updateResourceInstance);
- ComponentInstanceRestUtils.checkComponentInstanceType(updateResourceInstance, expectedServiceType);
-
- }
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ if (restResponse.getErrorCode() == 200) {
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, LifeCycleStatesEnum.STARTCERTIFICATION);
+ } else
+ return restResponse;
+ if (restResponse.getErrorCode() == 200) {
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails, LifeCycleStatesEnum.CERTIFY);
+ if (restResponse.getErrorCode() == 200) {
+ serviceDetails.setVersion("1.0");
+ serviceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
+ serviceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
+ serviceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
+ String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(), "uniqueId");
+ serviceDetails.setUniqueId(uniqueIdFromRresponse);
+ }
+ }
+ return restResponse;
+ }
+
+ @Test
+ public void deleteServiceInstanceTest() throws Exception {
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+ String compInstId = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+
+ createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_02, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 2, 0);
+ String compInstId2 = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+
+ RestResponse deleteServiceInstanceResp = deleteServiceInstance(compInstId, productDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 1, 0);
+
+ deleteServiceInstanceResp = deleteServiceInstance(compInstId2, productDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkDeleteResponse(deleteServiceInstanceResp);
+ getComponentAndValidateRIs(productDetails_01, 0, 0);
+ }
+
+ @Test
+ public void returnedServiceInstanceTypeAttributeTest() throws Exception {
+ String expectedServiceType = ComponentTypeEnum.SERVICE.getValue().toUpperCase();
+
+ RestResponse createServiceInstanceResp = createServiceInstance(productDetails_01, serviceDetails_01, sdncPmDetails1);
+ ResourceRestUtils.checkCreateResponse(createServiceInstanceResp);
+ String serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(createServiceInstanceResp);
+ ComponentInstanceRestUtils.checkComponentInstanceType(createServiceInstanceResp, expectedServiceType);
+
+ RestResponse getProductResp = ProductRestUtils.getProduct(productDetails_01.getUniqueId(), sdncPsDetails1.getUserId());
+ ProductRestUtils.checkSuccess(getProductResp);
+ Product productObject = ResponseParser.parseToObjectUsingMapper(getProductResp.getResponse(), Product.class);
+ List<ComponentInstance> productComponentInstances = productObject.getComponentInstances();
+ for (ComponentInstance comp : productComponentInstances) {
+ String actualOriginType = comp.getOriginType().getValue().toUpperCase();
+ assertTrue(expectedServiceType.equals(actualOriginType));
+ }
+
+ ComponentInstanceReqDetails serviceInstanceReqDetails = ElementFactory.getComponentResourceInstance(serviceDetails_02);
+ serviceInstanceReqDetails.setUniqueId(serviceUniqueIdFromResponse);
+ serviceInstanceReqDetails.setComponentUid(serviceDetails_01.getUniqueId());
+ RestResponse updateResourceInstance = ComponentInstanceRestUtils.updateComponentInstance(serviceInstanceReqDetails, sdncPmDetails1, productDetails_01.getUniqueId(), ComponentTypeEnum.PRODUCT);
+ ComponentInstanceRestUtils.checkSuccess(updateResourceInstance);
+ ComponentInstanceRestUtils.checkComponentInstanceType(updateResourceInstance, expectedServiceType);
+
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java
index 2796fa8403..a0a961dd8e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCreateWithValidationsTest.java
@@ -20,11 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.Arrays;
-
import org.json.JSONArray;
import org.json.JSONException;
import org.junit.Rule;
@@ -48,6 +43,11 @@ import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils;
import org.openecomp.sdc.common.api.Constants;
import org.testng.annotations.Test;
+import java.util.Arrays;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
public class ProductCreateWithValidationsTest extends ProductBaseTest {
@Rule
public static TestName name = new TestName();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java
index 88c0f4d3bb..e22318eda7 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductCrudTest.java
@@ -20,15 +20,10 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -45,11 +40,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.Convertor;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ProductValidationUtils;
@@ -58,10 +49,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
public class ProductCrudTest extends ProductBaseTest {
private static Logger log = LoggerFactory.getLogger(ProductCrudTest.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java
index 26bb3e29e9..7404e8e8a6 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductLifecycleTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.testng.AssertJUnit.assertEquals;
-
import org.junit.rules.TestName;
import org.openecomp.sdc.be.model.Product;
import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
@@ -32,6 +30,8 @@ import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.testng.annotations.BeforeMethod;
+import static org.testng.AssertJUnit.assertEquals;
+
public abstract class ProductLifecycleTest extends ProductBaseTest {
protected static final String CHECKIN_ACTION = "Checkin";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java
index 479dbb9436..fd59f8ed33 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductTestBase.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
import org.apache.log4j.lf5.util.ResourceUtils;
import org.junit.Before;
import org.junit.rules.TestName;
@@ -34,25 +28,18 @@ import org.openecomp.sdc.be.model.Product;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.*;
import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.ArtifactUtils;
import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
+
+import java.io.IOException;
+
+import static org.junit.Assert.*;
public class ProductTestBase extends ProductBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java
index 412e6fd92d..0c74f255fd 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductToscaYamlGenerationTest.java
@@ -20,10 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
+import com.google.gson.Gson;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
@@ -31,7 +28,9 @@ import org.openecomp.sdc.ci.tests.utils.Decoder;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
public class ProductToscaYamlGenerationTest extends ProductTestBase {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java
index d4bfb62377..4bd1dffeff 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/product/ProductUndoCheckoutTest.java
@@ -20,11 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.product;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.io.FileNotFoundException;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -44,6 +39,11 @@ import org.openecomp.sdc.common.api.Constants;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import java.io.FileNotFoundException;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+
public class ProductUndoCheckoutTest extends ProductLifecycleTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java
index 1cf16978e4..ff9d3e6d42 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/AdditionalInformationServletTest.java
@@ -20,18 +20,9 @@
package org.openecomp.sdc.ci.tests.execute.property;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
import org.json.simple.parser.JSONParser;
import org.junit.Rule;
import org.junit.rules.TestName;
@@ -49,29 +40,25 @@ import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.execute.resource.ResourceApiTest;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.*;
public class AdditionalInformationServletTest extends ComponentBaseTest {
@@ -534,8 +521,9 @@ public class AdditionalInformationServletTest extends ComponentBaseTest {
String vendorRelease = "0.1";
String contactId = "al1976";
String icon = "myIcon";
+ String instantiationType = ServiceInstantiationType.A_LA_CARTE.getValue();
- return new ServiceReqDetails(serviceName, category, tags, description, contactId, icon);
+ return new ServiceReqDetails(serviceName, category, tags, description, contactId, icon, instantiationType);
}
// TODO Tal: Since Cashing change partial resource returned that causes null
@@ -549,14 +537,14 @@ public class AdditionalInformationServletTest extends ComponentBaseTest {
AssertJUnit.assertEquals("Check response code after create user", 200, checkInResponse.getErrorCode().intValue());
Resource resourceAfterOperation = gson.fromJson(checkInResponse.getResponse(), Resource.class);
- // TODO Tal: Since Cashing change partial resource returned that causes
+ /*// TODO Tal: Since Cashing change partial resource returned that causes
// null pointer exception
- /*
+ *//*
* AssertJUnit.assertEquals("check size of additional information", 1, resourceAfterOperation.getAdditionalInformation().size());
- */
- /*
+ *//*
+ *//*
* AssertJUnit.assertEquals("check size of additional information", numberOfAI, resourceAfterOperation.getAdditionalInformation().get(0). getParameters().size());
- */
+ *//*
RestResponse req4certResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
@@ -566,12 +554,12 @@ public class AdditionalInformationServletTest extends ComponentBaseTest {
resourceAfterOperation = gson.fromJson(req4certResponse.getResponse(), Resource.class);
// TODO Tal: Since Cashing change partial resource returned that causes
// null pointer exception
- /*
+ *//*
* AssertJUnit.assertEquals("check size of additional information", 1, resourceAfterOperation.getAdditionalInformation().size());
- */
- /*
+ *//*
+ *//*
* AssertJUnit.assertEquals("check size of additional information", numberOfAI, resourceAfterOperation.getAdditionalInformation().get(0). getParameters().size());
- */
+ *//*
// change modifier
user.setUserId(UserRoleEnum.TESTER.getUserId());
@@ -584,10 +572,10 @@ public class AdditionalInformationServletTest extends ComponentBaseTest {
resourceAfterOperation = gson.fromJson(startCertResourceResponse3.getResponse(), Resource.class);
// TODO Tal: Since Cashing change partial resource returned that causes
// null pointer exception
- /*
+ *//*
* AssertJUnit.assertEquals("check size of additional information", 1, resourceAfterOperation.getAdditionalInformation().size());
- */
- /*
+ *//*
+ *//*
* AssertJUnit.assertEquals("check size of additional information", numberOfAI, resourceAfterOperation.getAdditionalInformation().get(0). getParameters().size());
*/
@@ -1253,9 +1241,9 @@ public class AdditionalInformationServletTest extends ComponentBaseTest {
assertNotNull("check error code exists in response after create property", checkInResponse.getErrorCode());
assertEquals("Check response code after create property", 200, checkInResponse.getErrorCode().intValue());
- RestResponse changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST, null);
- changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION, null);
- changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFY, null);
+ /*RestResponse changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST, null);
+ changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.STARTCERTIFICATION, null);*/
+ RestResponse changeStateResponse = LifecycleRestUtils.changeResourceState(resource, user, resourceVersion, LifeCycleStatesEnum.CERTIFY, null);
assertNotNull("check response object is not null after create property", checkInResponse);
assertNotNull("check error code exists in response after create property", checkInResponse.getErrorCode());
@@ -1960,11 +1948,11 @@ public class AdditionalInformationServletTest extends ComponentBaseTest {
// response = LCSbaseTest.certifyResource(resourceDetails);
RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, LifeCycleStatesEnum.CHECKIN);
assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200);
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ /*restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200);
restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterUser, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200);
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterUser, LifeCycleStatesEnum.CERTIFY);
+ assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200);*/
+ restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, user, LifeCycleStatesEnum.CERTIFY);
assertTrue("certify resource request returned status:" + restResponseResource.getErrorCode(), response.getErrorCode() == 200);
// add resource instance with HEAT deployment artifact to the service
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java
index 6ba1b2ccca..5385eb94f6 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentInstancePropertyTest.java
@@ -20,11 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.property;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
+import fj.data.Either;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
@@ -35,11 +31,7 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
@@ -49,7 +41,10 @@ import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import fj.data.Either;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.AssertJUnit.assertTrue;
// open bug for this class: DE199108 - closed, DE199741
public class ComponentInstancePropertyTest extends ComponentBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java
index 7ecdcf457f..8bb637e8dc 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/ComponentProperty.java
@@ -20,14 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.property;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -37,11 +29,7 @@ import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
@@ -53,6 +41,14 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
public class ComponentProperty extends ComponentBaseTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java
index f6f6f23214..21e188649d 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/property/PropertyApisTest.java
@@ -20,14 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.property;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.junit.Rule;
@@ -55,6 +47,10 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.*;
+
+import static org.testng.AssertJUnit.assertTrue;
+
public class PropertyApisTest extends SimpleOneRsrcOneServiceTest {
protected static final String RESOURCE_CATEGORY = "Generic/Databases";
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java
index 85dfe4e13a..6bae08b2bd 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CheckGetResource.java
@@ -20,14 +20,13 @@
package org.openecomp.sdc.ci.tests.execute.resource;
+import fj.data.Either;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.openecomp.sdc.common.util.SerializationUtils;
-import fj.data.Either;
-
public class CheckGetResource {
public void checkGetVmmsc6() throws Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java
index 675a5883bb..4e2a521b3c 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ComponentRelationshipInVfTest.java
@@ -20,33 +20,12 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
import org.apache.http.client.ClientProtocolException;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.CapReqDef;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.RelationshipImpl;
-import org.openecomp.sdc.be.model.RelationshipInfo;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
@@ -55,15 +34,20 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
+import static org.testng.AssertJUnit.*;
+
public class ComponentRelationshipInVfTest extends ComponentBaseTest {
public ComponentRelationshipInVfTest() {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java
index efa8393548..0549eaa042 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/CreateResourceApiTest.java
@@ -20,16 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -41,17 +32,8 @@ import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.*;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
@@ -60,13 +42,7 @@ import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.Convertor;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
@@ -74,7 +50,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.util.*;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
/**
* @author yshlosberg
@@ -2021,7 +2001,7 @@ public class CreateResourceApiTest extends ComponentBaseTest {
assertEquals(invariantUUIDcreation, invariantUUIDcheckout);
assertEquals(version, "0.2");
- // do certification request
+ /*// do certification request
RestResponse restResponseCertificationRequest = LifecycleRestUtils.changeResourceState(resourceDetails,
sdncUserDetails, resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
BaseRestUtils.checkSuccess(restResponseCertificationRequest);
@@ -2041,7 +2021,7 @@ public class CreateResourceApiTest extends ComponentBaseTest {
String invariantUUIDStartCertification = startCertificationRequestResource.getInvariantUUID();
version = startCertificationRequestResource.getVersion();
assertEquals(invariantUUIDcreation, invariantUUIDStartCertification);
- assertEquals(version, "0.2");
+ assertEquals(version, "0.2");*/
// certify
RestResponse restResponseCertify = LifecycleRestUtils.changeResourceState(resourceDetails, sdncUserDetails,
@@ -2075,7 +2055,8 @@ public class CreateResourceApiTest extends ComponentBaseTest {
ResourceReqDetails resourceDetails = ElementFactory.getDefaultResourceByType("VF200", NormativeTypesEnum.ROOT,
ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, designerUser.getUserId(), ResourceTypeEnum.VF.toString());
ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("newtestservice1",
- ServiceCategoriesEnum.MOBILITY, designerUser.getUserId());
+ ServiceCategoriesEnum.MOBILITY, designerUser.getUserId(),
+ ServiceInstantiationType.A_LA_CARTE.getValue());
// ResourceReqDetails resourceDetails =
// ElementFactory.getDefaultResource();
@@ -2115,7 +2096,7 @@ public class CreateResourceApiTest extends ComponentBaseTest {
assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
getResourceValidateInvariantUuid(resource.getUniqueId(), invariantUUIDcreation);
- // certification request
+ /*// certification request
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
@@ -2126,9 +2107,9 @@ public class CreateResourceApiTest extends ComponentBaseTest {
LifeCycleStatesEnum.STARTCERTIFICATION);
assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
- getResourceValidateInvariantUuid(resource.getUniqueId(), invariantUUIDcreation);
+ getResourceValidateInvariantUuid(resource.getUniqueId(), invariantUUIDcreation);*/
// certify
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUser, LifeCycleStatesEnum.CERTIFY);
+ restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser, LifeCycleStatesEnum.CERTIFY);
assertEquals("Check response code ", BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
assertEquals(invariantUUIDcreation, ResponseParser.getInvariantUuid(restResponse));
getResourceValidateInvariantUuid(resource.getUniqueId(), invariantUUIDcreation);
@@ -2143,11 +2124,11 @@ public class CreateResourceApiTest extends ComponentBaseTest {
assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, updateResponse.getErrorCode().intValue());
getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation);
- // certification request
+ /*// certification request
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation);
+ getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation);*/
// checkout resource
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser,
@@ -2155,7 +2136,7 @@ public class CreateResourceApiTest extends ComponentBaseTest {
assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation);
- // certification request
+ /*// certification request
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals(BaseRestUtils.STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
@@ -2182,7 +2163,7 @@ public class CreateResourceApiTest extends ComponentBaseTest {
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, testerUser,
LifeCycleStatesEnum.FAILCERTIFICATION);
assertEquals(STATUS_CODE_SUCCESS, restResponse.getErrorCode().intValue());
- getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation);
+ getResourceValidateInvariantUuid(resourceDetails.getUniqueId(), invariantUUIDcreation);*/
// upload artifact
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, designerUser,
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java
index a3372098a0..1b58c4e235 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetAllResourceVersions.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
import org.junit.rules.TestName;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
@@ -48,6 +41,13 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
public class GetAllResourceVersions extends ComponentBaseTest {
private static Logger logger = LoggerFactory.getLogger(GetAllResourceVersions.class.getName());
@@ -151,14 +151,14 @@ public class GetAllResourceVersions extends ComponentBaseTest {
resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN);
AssertJUnit.assertEquals("Check response code after checkout resource", 200,
checkoutResource.getErrorCode().intValue());
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ /*checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
AssertJUnit.assertEquals("Check response code after checkout resource", 200,
checkoutResource.getErrorCode().intValue());
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION);
AssertJUnit.assertEquals("Check response code after checkout resource", 200,
- checkoutResource.getErrorCode().intValue());
+ checkoutResource.getErrorCode().intValue());*/
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY);
AssertJUnit.assertEquals("Check response code after checkout resource", 200,
@@ -292,12 +292,12 @@ public class GetAllResourceVersions extends ComponentBaseTest {
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
@@ -317,12 +317,12 @@ public class GetAllResourceVersions extends ComponentBaseTest {
}
// resource version 2.0
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
@@ -384,9 +384,9 @@ public class GetAllResourceVersions extends ComponentBaseTest {
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ /*checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
// validate get response
RestResponse resourceGetResponse = ResourceRestUtils.getResource(designerDetails,
@@ -399,7 +399,7 @@ public class GetAllResourceVersions extends ComponentBaseTest {
@Test
public void getResourceAllVersions_CertifactionInProgress_version05() throws Exception {
- Map<String, String> origVersionsMap = new HashMap<String, String>();
+ Map<String, String> origVersionsMap = new HashMap<>();
// create resource
RestResponse restResponse = createResource(designerDetails, resourceDetails);
assertTrue("create request returned status:" + restResponse.getErrorCode(), restResponse.getErrorCode() == 201);
@@ -430,12 +430,12 @@ public class GetAllResourceVersions extends ComponentBaseTest {
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
// validate get response
RestResponse resourceGetResponse = ResourceRestUtils.getResource(designerDetails,
@@ -476,12 +476,12 @@ public class GetAllResourceVersions extends ComponentBaseTest {
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
@@ -525,12 +525,12 @@ public class GetAllResourceVersions extends ComponentBaseTest {
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, designerDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
@@ -549,12 +549,12 @@ public class GetAllResourceVersions extends ComponentBaseTest {
}
// get to version 1.0
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+/* checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
resourceDetails.getVersion(), LifeCycleStatesEnum.CERTIFY);
assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java
index ccf6142538..126aabdd03 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/GetResourceNotAbstractApiTest.java
@@ -20,16 +20,10 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.model.User;
@@ -50,10 +44,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import java.util.*;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
public class GetResourceNotAbstractApiTest extends ComponentBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java
index df8ff58ba8..1b50e7f1c2 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ResourceApiTest.java
@@ -20,14 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -58,7 +51,11 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.*;
public class ResourceApiTest extends ComponentBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java
index f4a4fa108a..8b8c6533cb 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SampleDataProvider.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import java.io.IOException;
-
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.testng.ITestContext;
import org.testng.annotations.DataProvider;
+import java.io.IOException;
+
public class SampleDataProvider {
@DataProvider
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java
index 3002523ccb..df72d355be 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/SimultaneousApiTest.java
@@ -20,10 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
@@ -35,6 +31,10 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.testng.annotations.Test;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
public class SimultaneousApiTest extends ComponentBaseTest {
protected static ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java
index 2b84af9f1d..bfd64c34f7 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/UpdateResourceMetadataTest.java
@@ -20,18 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.rules.TestName;
@@ -44,12 +33,7 @@ import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
@@ -70,54 +54,57 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.io.FileNotFoundException;
+import java.util.*;
+
+import static org.testng.AssertJUnit.*;
public class UpdateResourceMetadataTest extends ComponentBaseTest {
- private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName());
- protected List<String> Empty_List = new ArrayList<String>();
- protected String extendedChars;
+ private static Logger logger = LoggerFactory.getLogger(UpdateResourceMetadataTest.class.getName());
+ protected List<String> Empty_List = new ArrayList<String>();
+ protected String extendedChars;
- protected final String contentTypeHeaderData = "application/json";
- protected final String acceptHeaderDate = "application/json";
- protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1";
+ protected final String contentTypeHeaderData = "application/json";
+ protected final String acceptHeaderDate = "application/json";
+ protected final String CHARSET_ISO_8859 = "charset=ISO-8859-1";
- public static TestName name = new TestName();
- protected User sdncModifierDetails;
- protected ResourceReqDetails resourceDetails;
+ public static TestName name = new TestName();
+ protected User sdncModifierDetails;
+ protected ResourceReqDetails resourceDetails;
- public UpdateResourceMetadataTest() {
- super(name, UpdateResourceMetadataTest.class.getName());
+ public UpdateResourceMetadataTest() {
+ super(name, UpdateResourceMetadataTest.class.getName());
- }
+ }
- public String extendedCharsStringBuilder() throws Exception {
- char[] extendedCharsArray = new char[128];
- char ch = 128;
- for (int i = 0; i < extendedCharsArray.length - 1; i++) {
- extendedCharsArray[i] = ch;
- ch++;
- }
- extendedChars = new String(extendedCharsArray);
- return extendedChars;
+ public String extendedCharsStringBuilder() throws Exception {
+ char[] extendedCharsArray = new char[128];
+ char ch = 128;
+ for (int i = 0; i < extendedCharsArray.length - 1; i++) {
+ extendedCharsArray[i] = ch;
+ ch++;
+ }
+ extendedChars = new String(extendedCharsArray);
+ return extendedChars;
- }
+ }
- @BeforeMethod
- public void setup() throws Exception {
- sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- resourceDetails = defineResourse();
+ @BeforeMethod
+ public void setup() throws Exception {
+ sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ resourceDetails = defineResourse();
- }
+ }
- // Keep
- @Test
- public void UpdateDerivedFromSuccess() throws Exception {
+ // Keep
+ @Test
+ public void UpdateDerivedFromSuccess() throws Exception {
- String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
- String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
+ String oldDerivedFromName = NormativeTypesEnum.ROOT.getNormativeName();
+ String newDerivedFromName = NormativeTypesEnum.SOFTWARE_COMPONENT.getNormativeName();
- // Getting both derived from resources for validation
- /*
+ // Getting both derived from resources for validation
+ /*
* RestResponse resourceByNameAndVersion =
* resourceUtils.getResourceByNameAndVersion(sdncModifierDetails,
* oldDerivedFromName, "1.0");
@@ -135,1181 +122,1181 @@ public class UpdateResourceMetadataTest extends ComponentBaseTest {
* resourceUtils.parseResourceResp(resourceByNameAndVersion);
*/
- // Derived from set to Database
- List<String> derivedFrom = new ArrayList<>();
- derivedFrom.add(oldDerivedFromName);
- resourceDetails.setDerivedFrom(derivedFrom);
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- AssertJUnit.assertEquals("Check response code after create resource", 201,
- restResponse.getErrorCode().intValue());
- Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
-
- derivedFrom.clear();
- derivedFrom.add(newDerivedFromName);
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, currentResource.getUniqueId(), "");
- AssertJUnit.assertEquals("Check response code after create resource", 200,
- updatedRestResponse.getErrorCode().intValue());
-
- }
-
- protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
-
- updatedResourceDetails.setVersion("mumu");
- updatedResourceDetails.setIsAbstract(true);
- updatedResourceDetails.setIsHighestVersion(true);
- updatedResourceDetails.setCreatorUserId("df4444");
- updatedResourceDetails.setCreatorFullName("John Doe");
- updatedResourceDetails.setLastUpdaterUserId("gf5646");
- updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
- updatedResourceDetails.setCreationDate(new Long(4444));
- updatedResourceDetails.setLastUpdateDate(new Long("534535"));
- updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
- updatedResourceDetails.setCost("6.1");
- updatedResourceDetails.setLicenseType("Installation");
- updatedResourceDetails.setUUID("dfsfsdf");
- return updatedResourceDetails;
- }
-
- public void UpdateResourceNotFoundTest() throws Exception {
- // init ADMIN user
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- String resourceName = "cisco4";
- // update resource
- String description = "updatedDescription";
- ArrayList<String> resourceTags = new ArrayList<String>();
- resourceTags.add("tag2");
- String category = ServiceCategoriesEnum.MOBILITY.getValue();
- ArrayList<String> derivedFrom = new ArrayList<String>();
- derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
- String vendorName = "newOracle";
- String vendorRelease = "2.5";
- String contactId = "jh0003";
- String icon = "myICON";
-
- ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags,
- category, derivedFrom, vendorName, vendorRelease, contactId, icon);
- updatedResourceDetails.setUniqueId("dummyId");
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, "0.1");
-
- // validate response
- AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
- AssertJUnit.assertNotNull("check error code exists in response after update resource",
- updatedRestResponse.getErrorCode());
- AssertJUnit.assertEquals("Check response code after update resource", 404,
- updatedRestResponse.getErrorCode().intValue());
- // String resourceId =
- // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
- updatedRestResponse.getResponse());
-
- resourceName = "";
- // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
- // "0.1");
- updatedResourceDetails = defineUpdatedResourse(resourceName);
- updatedResourceDetails.setUniqueId("dummyId");
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
- "0.1");
- AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
- AssertJUnit.assertNotNull("check error code exists in response after update resource",
- updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
- updatedRestResponse.getResponse());
-
- }
-
- public char[] getInValidChars() throws Exception {
-
- char[] extendedCharsArray = new char[59];
- char ch = 1;
- for (int i = 0; i < 44; i++) {
- extendedCharsArray[i] = ch;
- ch++;
- }
- ch = 58;
- for (int i = 44; i < 51; i++) {
- extendedCharsArray[i] = ch;
- ch++;
- }
- ch = 91;
- for (int i = 51; i < 55; i++) {
- extendedCharsArray[i] = ch;
- ch++;
- }
- ch = 123;
- for (int i = 55; i < 59; i++) {
- extendedCharsArray[i] = ch;
- ch++;
- }
- return extendedCharsArray;
- }
-
- public char[] getTagInValidFormatChars() throws Exception {
- // Tag format is the same as defined for "Resource Name" :
- // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
- // ('_'), dash ('-'), dot ('.')
- char[] notValidCharsArray = new char[30];
- char ch = 33;
- for (int i = 0; i < 12; i++) {
- notValidCharsArray[i] = ch;
- ch++;
- }
- notValidCharsArray[13] = 47;
- ch = 58;
- for (int i = 14; i < 21; i++) {
- notValidCharsArray[i] = ch;
- ch++;
- }
- ch = 91;
- for (int i = 21; i < 24; i++) {
- notValidCharsArray[i] = ch;
- ch++;
- }
- notValidCharsArray[24] = 96;
- ch = 123;
- for (int i = 25; i < 30; i++) {
- notValidCharsArray[i] = ch;
- ch++;
- }
- return notValidCharsArray;
- }
-
- public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
- // init ADMIN user
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // define and create resource
- ResourceReqDetails resourceDetails = defineResourse();
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceId = resourceDetails.getUniqueId();
- resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
-
- // build Json Object
- JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
-
- List<String> resource = new ArrayList<>();
- resource.add("Resource");
-
- // remove Description
- UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description",
- ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
- // remove Tags
- UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags",
- ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
- // remove Category
- UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category",
- ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
- // remove VendorName
- UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName",
- ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
- // remove VendorRelease
- UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease",
- ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
- // remove AT&T Contact
- UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId",
- ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
- // validate response
- AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
- AssertJUnit.assertNotNull("check error code exists in response after get resource",
- getRestResponse.getErrorCode());
- AssertJUnit.assertEquals("Check response code after update resource", 200,
- getRestResponse.getErrorCode().intValue());
-
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
- }
-
- // End of validation tests
- // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
- String description = "updatedDescription";
- ArrayList<String> resourceTags = new ArrayList<String>();
- // Duplicate tags are allowed and should be de-duplicated by server side
- resourceTags.add(resourceName);
- resourceTags.add("tag1");
- resourceTags.add("tag1");
- resourceTags.add("tag2");
- resourceTags.add("tag2");
- String category = ServiceCategoriesEnum.VOIP.getValue();
- ArrayList<String> derivedFrom = new ArrayList<String>();
- derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
- String vendorName = "updatedOracle";
- String vendorRelease = "3.5";
- String contactId = "jh0001";
- String icon = "myUpdatedICON";
-
- ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category,
- derivedFrom, vendorName, vendorRelease, contactId, icon);
- resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
-
- return resourceDetails;
- }
-
- protected ResourceReqDetails defineResourse() {
- String resourceName = "cisco4";
- String description = "description";
- ArrayList<String> resourceTags = new ArrayList<String>();
- resourceTags.add(resourceName);
- ArrayList<String> derivedFrom = new ArrayList<String>();
- derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
- String vendorName = "Oracle";
- String vendorRelease = "1.5";
- String contactId = "jh0003";
- String icon = "objectStorage";
-
- ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null,
- derivedFrom, vendorName, vendorRelease, contactId, icon);
- resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
-
- return resourceDetails;
- }
-
- protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails)
- throws Exception {
- // clean ES DB
- DbUtils.cleanAllAudits();
-
- // create resource
- RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
-
- // validate response
- AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
- AssertJUnit.assertNotNull("check error code exists in response after create resource",
- restResponse.getErrorCode());
- AssertJUnit.assertEquals("Check response code after create resource", 201,
- restResponse.getErrorCode().intValue());
-
- return restResponse;
- }
-
- protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails,
- String uri) throws Exception {
- // delete resource
- Config config;
- RestResponse ResourceResponse;
- try {
- config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
- headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
- HttpRequest http = new HttpRequest();
- String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(),
- config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
-
- if (uri == "GET") {
- ResourceResponse = http.httpSendGet(url, headersMap);
- } else if (uri == "POST") {
- Gson gson = new Gson();
- String userBodyJson = gson.toJson(updatedResourceDetails);
- ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
- } else if (uri == "DELETE") {
- ResourceResponse = http.httpSendDelete(url, headersMap);
- } else
- return null;
-
- return ResourceResponse;
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
-
- return null;
-
- }
-
- protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
- // json object: resourceName and icon are must
- JSONObject jObject = new JSONObject();
-
- List<String> tagsList = Arrays.asList(resourceDetails.getName());
- List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
-
- jObject.put("name", resourceDetails.getName());
- jObject.put("description", "updatedDescription");
- jObject.put("tags", tagsList);
- jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
- jObject.put("derivedFrom", derivedFromList);
- jObject.put("vendorName", "newOracle");
- jObject.put("vendorRelease", "1.5");
- jObject.put("contactId", "jh0003");
- jObject.put("icon", resourceDetails.getIcon());
-
- return jObject;
- }
-
- protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
- jObject.remove(removedPropery);
-
- return jObject;
- }
-
- // purpose: function for controlling json body fields and validating
- // response
- protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject,
- String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
-
- JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
- // remove description from jsonObject
- jObject = RemoveFromJsonObject(jObject, removedField);
- // update with incomplete body.
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(),
- sdncModifierDetails, resourceId);
- // validate response
- AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
- AssertJUnit.assertNotNull("check error code exists in response after update resource",
- updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
-
- }
-
- // purpose: function for validating error response
- protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails,
- String recievedMessage, List<String> variables) throws Exception {
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, "0.1");
- // validate response
- AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
- AssertJUnit.assertNotNull("check error code exists in response after update resource",
- updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
-
- }
-
- protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse)
- throws Exception {
- // parse response to javaObject
- Resource updatedResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(restResponse.getResponse());
- AssertJUnit.assertTrue(
- !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
- AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
- AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
- AssertJUnit.assertTrue(
- !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
- AssertJUnit.assertTrue(
- !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
- AssertJUnit.assertTrue(
- !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
- AssertJUnit
- .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
- AssertJUnit.assertTrue(
- !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
- AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName()
- .equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
- AssertJUnit.assertTrue(
- !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
- AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
- AssertJUnit
- .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
- AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
-
- }
-
- protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse)
- throws Exception {
- // parse response to javaObject
- Resource updatedResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(restResponse.getResponse());
- // validate request vs response
- ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
- }
-
- public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails,
- String resourceVersion) {
-
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
-
- expectedResourceAuditJavaObject.setAction("Checkout");
- expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
- expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
- expectedResourceAuditJavaObject.setStatus("200.0");
- expectedResourceAuditJavaObject.setDesc("OK");
- expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
- expectedResourceAuditJavaObject.setResourceType("Resource");
- expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
- expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
- expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
- expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
-
- return expectedResourceAuditJavaObject;
-
- }
-
- public enum FieldToValidate {
- contactId, Tags, VendorName, VendorRelease, Description
- }
-
- @Test
- public void UpdateBy_postTest() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // update resource - without changing resourceName
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
-
- RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
-
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertNotNull("check response object is not null after update resource", getRestResponse);
- parseResponseAndValidate(resourceDetails, getRestResponse);
-
- }
-
- @Test
- public void UpdateBy_getTest() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // update resource - without changing resourceName
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
- RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
-
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertNotNull("check response object is not null after update resource", getRestResponse);
- parseResponseAndValidate(resourceDetails, getRestResponse);
-
- }
-
- @Test
- public void UpdateBy_deleteTest() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // update resource - without changing resourceName
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
- RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails,
- "DELETE");
-
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId(), "");
- assertNotNull("check response object is not null after update resource", getRestResponse);
- parseResponseAndValidate(resourceDetails, getRestResponse);
-
- }
-
- // TODO DE
- // @Ignore("")
- @Test
- public void UpdateWithInvaldJsonBodyTest() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
- String resourceId = resourceDetails.getUniqueId();
-
- // update Descirption value
- String description = "updatedDescription";
-
- // send update with incompleted json, only description string
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails,
- resourceId);
-
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
-
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertNotNull("check response object is not null after update resource", getRestResponse);
- parseResponseAndValidate(resourceDetails, getRestResponse);
-
- }
-
- // @Test
- // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
- //
- //
- // RestResponse restResponse = createResource(sdncModifierDetails,
- // resourceDetails);
- // String resourceName = resourceDetails.getName();
- //
- // // new user parameters
- // String userFirstName = "Kot";
- // String userLastName = "Matroskin";
- // String role = "ADMIN";
- // User sdncUserDetails = new User(userFirstName, userLastName,
- // httpCspUserId, email, role,null);
- // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
- // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
- //
- // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
- // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
- //
- // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
- // httpCspUserId, email,role,null);
- // ResourceReqDetails updatedResourceDetails =
- // defineUpdatedResourse(resourceName);
- // RestResponse updatedRestResponse =
- // ResourceRestUtils.updateResource(updatedResourceDetails,
- // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
- //
- // // validate response
- // assertNotNull("check response object is not null after update resource",
- // updatedRestResponse);
- // assertNotNull("check error code exists in response after update
- // resource", updatedRestResponse.getErrorCode());
- // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
- // Empty_List, updatedRestResponse.getResponse());
- //
- // RestResponse getRestResponse =
- // ResourceRestUtils.getResource(sdncModifierDetails,
- // resourceDetails.getUniqueId());
- // assertNotNull("check response object is not null after update resource",
- // getRestResponse);
- // parseResponseAndValidate(resourceDetails, getRestResponse);
- //
- //
- // }
-
- @Test
- public void UpdateResourceNameSensitiveTest() throws Exception {
- User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
- String resourceName = "Ab";
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
- // Delete resources
- RestResponse response = null;
- response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
- updatedResourceDetails.getName(), "0.1");
- BaseRestUtils.checkDeleteResponse(response);
- response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
- updatedResourceDetails.getName(), "0.2");
- BaseRestUtils.checkDeleteResponse(response);
-
- RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
- assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
-
- // check-in Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails,
- sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- // String resourceCertifyVersion = "0.1";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- updatedResourceDetails.setName("ABC_-bt.aT");
- ArrayList<String> resourceTag = new ArrayList<String>();
- resourceTag.add(0, "ABC_-bt.aT");
- updatedResourceDetails.setTags(resourceTag);
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
-
- // Delete resources
- response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
- updatedResourceDetails.getName(), "0.1");
- BaseRestUtils.checkDeleteResponse(response);
- response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
- updatedResourceDetails.getName(), "0.2");
- BaseRestUtils.checkDeleteResponse(response);
-
- }
-
- @Test
- public void UpdateIcon_InegativeFlow() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- List<String> resourceList = new ArrayList<String>();
- resourceList.add(0, "Resource");
- // check InValid Characters
- char[] notValidCharsArray = new char[59];
- notValidCharsArray = getInValidChars();
- // update metadata details
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
- RestResponse updatedRestResponse;
-
- for (int i = 0; i < notValidCharsArray.length; i++) {
- // change icon of metadata
- updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
- // PUT request
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId(), "");
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource",
- updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList,
- updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource icon", 400,
- updatedRestResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating resource icon", "Bad Request",
- updatedRestResponse.getResponseMessage().toString());
-
- }
-
- // empty icon
- String updateIcon = "";
- updatedResourceDetails.setIcon(updateIcon);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId(), "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList,
- updatedRestResponse.getResponse());
-
- // Icon length more then 25 characters
- resourceList.add(1, "25");
- updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId(), "");
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList,
- updatedRestResponse.getResponse());
- assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating resource icon", "Bad Request",
- updatedRestResponse.getResponseMessage().toString());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
-
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- }
-
- @Test
- public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
-
- User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- ResourceReqDetails updatedResourceDetails = defineResourse();
- updatedResourceDetails.setName("updatedResourceName");
- List<String> tags = updatedResourceDetails.getTags();
-
- for (Iterator<String> iter = tags.listIterator(); iter.hasNext();) {
- String a = iter.next();
- if (a.equals("updatedResourceName")) {
- iter.remove();
- }
- }
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- List<String> resourceList = new ArrayList<String>();
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(),
- resourceList, updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource icon", 400,
- updatedRestResponse.getErrorCode().intValue());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- }
-
- @Test
- public void UpdateResourceName_negativeFlow() throws Exception {
- // The validation are done in Tag's validation
- User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- RestResponse updatedRestResponse;
- RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
- assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
- String uniqueId = resourceDetails.getUniqueId();
- String resourceName = resourceDetails.getName();
- // check InValid Characters
- char[] notValidCharsArray = new char[59];
- notValidCharsArray = getInValidChars();
- ArrayList<String> resource_Name = new ArrayList<String>();
- List<String> resourceList = new ArrayList<String>();
-
- ArrayList<String> resourceTags = new ArrayList<String>();
- resourceList.add(0, "Resource");
-
- // update metadata details
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
- for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
- if (i != 1 && i != 46
- && /*
+ // Derived from set to Database
+ List<String> derivedFrom = new ArrayList<>();
+ derivedFrom.add(oldDerivedFromName);
+ resourceDetails.setDerivedFrom(derivedFrom);
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ AssertJUnit.assertEquals("Check response code after create resource", 201,
+ restResponse.getErrorCode().intValue());
+ Resource currentResource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+
+ derivedFrom.clear();
+ derivedFrom.add(newDerivedFromName);
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, currentResource.getUniqueId(), "");
+ AssertJUnit.assertEquals("Check response code after create resource", 200,
+ updatedRestResponse.getErrorCode().intValue());
+
+ }
+
+ protected ResourceReqDetails defineUpdateResourceWithNonUpdatableFields(Resource resourceBeforeUpdate) {
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceBeforeUpdate.getName());
+
+ updatedResourceDetails.setVersion("mumu");
+ updatedResourceDetails.setIsAbstract(true);
+ updatedResourceDetails.setIsHighestVersion(true);
+ updatedResourceDetails.setCreatorUserId("df4444");
+ updatedResourceDetails.setCreatorFullName("John Doe");
+ updatedResourceDetails.setLastUpdaterUserId("gf5646");
+ updatedResourceDetails.setLastUpdaterFullName("Viktor Tzoy");
+ updatedResourceDetails.setCreationDate(new Long(4444));
+ updatedResourceDetails.setLastUpdateDate(new Long("534535"));
+ updatedResourceDetails.setLifecycleState(LifecycleStateEnum.READY_FOR_CERTIFICATION);
+ updatedResourceDetails.setCost("6.1");
+ updatedResourceDetails.setLicenseType("Installation");
+ updatedResourceDetails.setUUID("dfsfsdf");
+ return updatedResourceDetails;
+ }
+
+ public void UpdateResourceNotFoundTest() throws Exception {
+ // init ADMIN user
+ User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+
+ String resourceName = "cisco4";
+ // update resource
+ String description = "updatedDescription";
+ ArrayList<String> resourceTags = new ArrayList<String>();
+ resourceTags.add("tag2");
+ String category = ServiceCategoriesEnum.MOBILITY.getValue();
+ ArrayList<String> derivedFrom = new ArrayList<String>();
+ derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
+ String vendorName = "newOracle";
+ String vendorRelease = "2.5";
+ String contactId = "jh0003";
+ String icon = "myICON";
+
+ ResourceReqDetails updatedResourceDetails = new ResourceReqDetails(resourceName, description, resourceTags,
+ category, derivedFrom, vendorName, vendorRelease, contactId, icon);
+ updatedResourceDetails.setUniqueId("dummyId");
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, "0.1");
+
+ // validate response
+ AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ AssertJUnit.assertNotNull("check error code exists in response after update resource",
+ updatedRestResponse.getErrorCode());
+ AssertJUnit.assertEquals("Check response code after update resource", 404,
+ updatedRestResponse.getErrorCode().intValue());
+ // String resourceId =
+ // UniqueIdBuilder.buildResourceUniqueId(resourceName, "0.1");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
+ updatedRestResponse.getResponse());
+
+ resourceName = "";
+ // resourceId = UniqueIdBuilder.buildResourceUniqueId(resourceName,
+ // "0.1");
+ updatedResourceDetails = defineUpdatedResourse(resourceName);
+ updatedResourceDetails.setUniqueId("dummyId");
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
+ "0.1");
+ AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ AssertJUnit.assertNotNull("check error code exists in response after update resource",
+ updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NOT_FOUND.name(), Arrays.asList("dummyId"),
+ updatedRestResponse.getResponse());
+
+ }
+
+ public char[] getInValidChars() throws Exception {
+
+ char[] extendedCharsArray = new char[59];
+ char ch = 1;
+ for (int i = 0; i < 44; i++) {
+ extendedCharsArray[i] = ch;
+ ch++;
+ }
+ ch = 58;
+ for (int i = 44; i < 51; i++) {
+ extendedCharsArray[i] = ch;
+ ch++;
+ }
+ ch = 91;
+ for (int i = 51; i < 55; i++) {
+ extendedCharsArray[i] = ch;
+ ch++;
+ }
+ ch = 123;
+ for (int i = 55; i < 59; i++) {
+ extendedCharsArray[i] = ch;
+ ch++;
+ }
+ return extendedCharsArray;
+ }
+
+ public char[] getTagInValidFormatChars() throws Exception {
+ // Tag format is the same as defined for "Resource Name" :
+ // Allowed characters: Alphanumeric (a-zA-Z0-9), space (' '), underscore
+ // ('_'), dash ('-'), dot ('.')
+ char[] notValidCharsArray = new char[30];
+ char ch = 33;
+ for (int i = 0; i < 12; i++) {
+ notValidCharsArray[i] = ch;
+ ch++;
+ }
+ notValidCharsArray[13] = 47;
+ ch = 58;
+ for (int i = 14; i < 21; i++) {
+ notValidCharsArray[i] = ch;
+ ch++;
+ }
+ ch = 91;
+ for (int i = 21; i < 24; i++) {
+ notValidCharsArray[i] = ch;
+ ch++;
+ }
+ notValidCharsArray[24] = 96;
+ ch = 123;
+ for (int i = 25; i < 30; i++) {
+ notValidCharsArray[i] = ch;
+ ch++;
+ }
+ return notValidCharsArray;
+ }
+
+ public void Validation_UpdateWithIncompleteJsonBodyTest() throws Exception {
+ // init ADMIN user
+ User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+
+ // define and create resource
+ ResourceReqDetails resourceDetails = defineResourse();
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceId = resourceDetails.getUniqueId();
+ resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
+
+ // build Json Object
+ JSONObject jsonObject = JsonObjectBuilder(resourceDetails);
+
+ List<String> resource = new ArrayList<>();
+ resource.add("Resource");
+
+ // remove Description
+ UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "description",
+ ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource);
+ // remove Tags
+ UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "tags",
+ ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List);
+ // remove Category
+ UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "category",
+ ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resource);
+ // remove VendorName
+ UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorName",
+ ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List);
+ // remove VendorRelease
+ UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "vendorRelease",
+ ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List);
+ // remove AT&T Contact
+ UpdateAndValidateWithIncompletedJsonBody(sdncModifierDetails, jsonObject, resourceId, "contactId",
+ ActionStatus.COMPONENT_MISSING_CONTACT.name(), resource);
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, "0.1");
+ // validate response
+ AssertJUnit.assertNotNull("check response object is not null after get resource", getRestResponse);
+ AssertJUnit.assertNotNull("check error code exists in response after get resource",
+ getRestResponse.getErrorCode());
+ AssertJUnit.assertEquals("Check response code after update resource", 200,
+ getRestResponse.getErrorCode().intValue());
+
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "0.1");
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.0");
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, resourceDetails.getName(), "1.1");
+ }
+
+ // End of validation tests
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ protected ResourceReqDetails defineUpdatedResourse(String resourceName) {
+ String description = "updatedDescription";
+ ArrayList<String> resourceTags = new ArrayList<String>();
+ // Duplicate tags are allowed and should be de-duplicated by server side
+ resourceTags.add(resourceName);
+ resourceTags.add("tag1");
+ resourceTags.add("tag1");
+ resourceTags.add("tag2");
+ resourceTags.add("tag2");
+ String category = ServiceCategoriesEnum.VOIP.getValue();
+ ArrayList<String> derivedFrom = new ArrayList<String>();
+ derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());
+ String vendorName = "updatedOracle";
+ String vendorRelease = "3.5";
+ String contactId = "jh0001";
+ String icon = "myUpdatedICON";
+
+ ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, category,
+ derivedFrom, vendorName, vendorRelease, contactId, icon);
+ resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
+ ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
+
+ return resourceDetails;
+ }
+
+ protected ResourceReqDetails defineResourse() {
+ String resourceName = "cisco4";
+ String description = "description";
+ ArrayList<String> resourceTags = new ArrayList<String>();
+ resourceTags.add(resourceName);
+ ArrayList<String> derivedFrom = new ArrayList<String>();
+ derivedFrom.add(NormativeTypesEnum.ROOT.getNormativeName());// "tosca.nodes.Root");
+ String vendorName = "Oracle";
+ String vendorRelease = "1.5";
+ String contactId = "jh0003";
+ String icon = "objectStorage";
+
+ ResourceReqDetails resourceDetails = new ResourceReqDetails(resourceName, description, resourceTags, null,
+ derivedFrom, vendorName, vendorRelease, contactId, icon);
+ resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getCategory(),
+ ResourceCategoryEnum.GENERIC_INFRASTRUCTURE.getSubCategory());
+
+ return resourceDetails;
+ }
+
+ protected RestResponse createResource(User sdncModifierDetails, ResourceReqDetails resourceDetails)
+ throws Exception {
+ // clean ES DB
+ DbUtils.cleanAllAudits();
+
+ // create resource
+ RestResponse restResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
+
+ // validate response
+ AssertJUnit.assertNotNull("check response object is not null after create resource", restResponse);
+ AssertJUnit.assertNotNull("check error code exists in response after create resource",
+ restResponse.getErrorCode());
+ AssertJUnit.assertEquals("Check response code after create resource", 201,
+ restResponse.getErrorCode().intValue());
+
+ return restResponse;
+ }
+
+ protected RestResponse TryUpdateByAnotherVerb(ResourceReqDetails updatedResourceDetails, User sdncModifierDetails,
+ String uri) throws Exception {
+ // delete resource
+ Config config;
+ RestResponse ResourceResponse;
+ try {
+ config = Utils.getConfig();
+ Map<String, String> headersMap = new HashMap<String, String>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
+ HttpRequest http = new HttpRequest();
+ String url = String.format(Urls.UPDATE_RESOURCE_METADATA, config.getCatalogBeHost(),
+ config.getCatalogBePort(), updatedResourceDetails.getName() + ".0.1");
+
+ if (uri == "GET") {
+ ResourceResponse = http.httpSendGet(url, headersMap);
+ } else if (uri == "POST") {
+ Gson gson = new Gson();
+ String userBodyJson = gson.toJson(updatedResourceDetails);
+ ResourceResponse = http.httpSendPost(url, userBodyJson, headersMap);
+ } else if (uri == "DELETE") {
+ ResourceResponse = http.httpSendDelete(url, headersMap);
+ } else
+ return null;
+
+ return ResourceResponse;
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+ protected JSONObject JsonObjectBuilder(ResourceReqDetails resourceDetails) throws JSONException {
+ // json object: resourceName and icon are must
+ JSONObject jObject = new JSONObject();
+
+ List<String> tagsList = Arrays.asList(resourceDetails.getName());
+ List<String> derivedFromList = Arrays.asList("[tosca.nodes.Root]");
+
+ jObject.put("name", resourceDetails.getName());
+ jObject.put("description", "updatedDescription");
+ jObject.put("tags", tagsList);
+ jObject.put("category", ServiceCategoriesEnum.VOIP.getValue());
+ jObject.put("derivedFrom", derivedFromList);
+ jObject.put("vendorName", "newOracle");
+ jObject.put("vendorRelease", "1.5");
+ jObject.put("contactId", "jh0003");
+ jObject.put("icon", resourceDetails.getIcon());
+
+ return jObject;
+ }
+
+ protected JSONObject RemoveFromJsonObject(JSONObject jObject, String removedPropery) {
+ jObject.remove(removedPropery);
+
+ return jObject;
+ }
+
+ // purpose: function for controlling json body fields and validating
+ // response
+ protected void UpdateAndValidateWithIncompletedJsonBody(User sdncModifierDetails, JSONObject jsonObject,
+ String resourceId, String removedField, String errorMessage, List<String> variables) throws Exception {
+
+ JSONObject jObject = new JSONObject(jsonObject, JSONObject.getNames(jsonObject));
+ // remove description from jsonObject
+ jObject = RemoveFromJsonObject(jObject, removedField);
+ // update with incomplete body.
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(jObject.toString(),
+ sdncModifierDetails, resourceId);
+ // validate response
+ AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ AssertJUnit.assertNotNull("check error code exists in response after update resource",
+ updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(errorMessage, variables, updatedRestResponse.getResponse());
+
+ }
+
+ // purpose: function for validating error response
+ protected void UpdateAndValidate(User sdncModifierDetails, ResourceReqDetails resourceDetails,
+ String recievedMessage, List<String> variables) throws Exception {
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, "0.1");
+ // validate response
+ AssertJUnit.assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ AssertJUnit.assertNotNull("check error code exists in response after update resource",
+ updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(recievedMessage, variables, updatedRestResponse.getResponse());
+
+ }
+
+ protected void parseResponseAndValidateNonUpdatable(ResourceReqDetails resourceDetails, RestResponse restResponse)
+ throws Exception {
+ // parse response to javaObject
+ Resource updatedResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(restResponse.getResponse());
+ AssertJUnit.assertTrue(
+ !resourceDetails.getIsHighestVersion().equals(updatedResourceRespJavaObject.isHighestVersion()));
+ AssertJUnit.assertTrue(!resourceDetails.getVersion().equals(updatedResourceRespJavaObject.getName()));
+ AssertJUnit.assertTrue(!resourceDetails.getIsAbstract().equals(updatedResourceRespJavaObject.isAbstract()));
+ AssertJUnit.assertTrue(
+ !resourceDetails.getCreatorUserId().equals(updatedResourceRespJavaObject.getCreatorUserId()));
+ AssertJUnit.assertTrue(
+ !resourceDetails.getCreatorFullName().equals(updatedResourceRespJavaObject.getCreatorFullName()));
+ AssertJUnit.assertTrue(
+ !resourceDetails.getLastUpdateDate().equals(updatedResourceRespJavaObject.getLastUpdateDate()));
+ AssertJUnit
+ .assertTrue(!resourceDetails.getCreationDate().equals(updatedResourceRespJavaObject.getCreationDate()));
+ AssertJUnit.assertTrue(
+ !resourceDetails.getLastUpdaterUserId().equals(updatedResourceRespJavaObject.getLastUpdaterUserId()));
+ AssertJUnit.assertTrue(!resourceDetails.getLastUpdaterFullName()
+ .equals(updatedResourceRespJavaObject.getLastUpdaterFullName()));
+ AssertJUnit.assertTrue(
+ !resourceDetails.getLifecycleState().equals(updatedResourceRespJavaObject.getLifecycleState()));
+ AssertJUnit.assertTrue(!resourceDetails.getCost().equals(updatedResourceRespJavaObject.getCost()));
+ AssertJUnit
+ .assertTrue(!resourceDetails.getLicenseType().equals(updatedResourceRespJavaObject.getLicenseType()));
+ AssertJUnit.assertTrue(!resourceDetails.getUUID().equals(updatedResourceRespJavaObject.getUUID()));
+
+ }
+
+ protected void parseResponseAndValidate(ResourceReqDetails ResourceDetails, RestResponse restResponse)
+ throws Exception {
+ // parse response to javaObject
+ Resource updatedResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(restResponse.getResponse());
+ // validate request vs response
+ ResourceValidationUtils.validateResourceReqVsResp(ResourceDetails, updatedResourceRespJavaObject);
+ }
+
+ public ExpectedResourceAuditJavaObject constructFieldsForAuditValidation(ResourceReqDetails resourceDetails,
+ String resourceVersion) {
+
+ ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
+
+ expectedResourceAuditJavaObject.setAction("Checkout");
+ expectedResourceAuditJavaObject.setModifierUid(UserRoleEnum.ADMIN.getUserId());
+ expectedResourceAuditJavaObject.setModifierName(UserRoleEnum.ADMIN.getUserName());
+ expectedResourceAuditJavaObject.setStatus("200.0");
+ expectedResourceAuditJavaObject.setDesc("OK");
+ expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName().toLowerCase());
+ expectedResourceAuditJavaObject.setResourceType("Resource");
+ expectedResourceAuditJavaObject.setPrevVersion(String.valueOf(Float.parseFloat(resourceVersion) - 0.1f));
+ expectedResourceAuditJavaObject.setCurrVersion(resourceVersion);
+ expectedResourceAuditJavaObject.setPrevState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+ expectedResourceAuditJavaObject.setCurrState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString());
+
+ return expectedResourceAuditJavaObject;
+
+ }
+
+ public enum FieldToValidate {
+ contactId, Tags, VendorName, VendorRelease, Description
+ }
+
+ @Test
+ public void UpdateBy_postTest() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // update resource - without changing resourceName
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+
+ RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "POST");
+
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertNotNull("check response object is not null after update resource", getRestResponse);
+ parseResponseAndValidate(resourceDetails, getRestResponse);
+
+ }
+
+ @Test
+ public void UpdateBy_getTest() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // update resource - without changing resourceName
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+ RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails, "GET");
+
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertNotNull("check response object is not null after update resource", getRestResponse);
+ parseResponseAndValidate(resourceDetails, getRestResponse);
+
+ }
+
+ @Test
+ public void UpdateBy_deleteTest() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // update resource - without changing resourceName
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+ RestResponse updatedRestResponse = TryUpdateByAnotherVerb(updatedResourceDetails, sdncModifierDetails,
+ "DELETE");
+
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.NOT_ALLOWED.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ RestResponse getRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ assertNotNull("check response object is not null after update resource", getRestResponse);
+ parseResponseAndValidate(resourceDetails, getRestResponse);
+
+ }
+
+ // TODO DE
+ // @Ignore("")
+ @Test
+ public void UpdateWithInvaldJsonBodyTest() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ resourceDetails.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse));
+ String resourceId = resourceDetails.getUniqueId();
+
+ // update Descirption value
+ String description = "updatedDescription";
+
+ // send update with incompleted json, only description string
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(description, sdncModifierDetails,
+ resourceId);
+
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("check error code after update resource", 400, updatedRestResponse.getErrorCode().intValue());
+
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertNotNull("check response object is not null after update resource", getRestResponse);
+ parseResponseAndValidate(resourceDetails, getRestResponse);
+
+ }
+
+ // @Test
+ // public void UpdateResourceModifierNotOwnerStateTest() throws Exception {
+ //
+ //
+ // RestResponse restResponse = createResource(sdncModifierDetails,
+ // resourceDetails);
+ // String resourceName = resourceDetails.getName();
+ //
+ // // new user parameters
+ // String userFirstName = "Kot";
+ // String userLastName = "Matroskin";
+ // String role = "ADMIN";
+ // User sdncUserDetails = new User(userFirstName, userLastName,
+ // httpCspUserId, email, role,null);
+ // RestResponse deleteUserResponse = userUtils.deleteUser(sdncUserDetails,
+ // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
+ //
+ // RestResponse createUserResponse = UserUtils.createUser(sdncUserDetails,
+ // ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
+ //
+ // User updatedSdncModifierDetails = new User(userFirstName, userLastName,
+ // httpCspUserId, email,role,null);
+ // ResourceReqDetails updatedResourceDetails =
+ // defineUpdatedResourse(resourceName);
+ // RestResponse updatedRestResponse =
+ // ResourceRestUtils.updateResource(updatedResourceDetails,
+ // updatedSdncModifierDetails, resourceDetails.getUniqueId(), "");
+ //
+ // // validate response
+ // assertNotNull("check response object is not null after update resource",
+ // updatedRestResponse);
+ // assertNotNull("check error code exists in response after update
+ // resource", updatedRestResponse.getErrorCode());
+ // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(),
+ // Empty_List, updatedRestResponse.getResponse());
+ //
+ // RestResponse getRestResponse =
+ // ResourceRestUtils.getResource(sdncModifierDetails,
+ // resourceDetails.getUniqueId());
+ // assertNotNull("check response object is not null after update resource",
+ // getRestResponse);
+ // parseResponseAndValidate(resourceDetails, getRestResponse);
+ //
+ //
+ // }
+
+ @Test
+ public void UpdateResourceNameSensitiveTest() throws Exception {
+ User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+ String resourceName = "Ab";
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+ // Delete resources
+ RestResponse response = null;
+ response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
+ updatedResourceDetails.getName(), "0.1");
+ BaseRestUtils.checkDeleteResponse(response);
+ response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
+ updatedResourceDetails.getName(), "0.2");
+ BaseRestUtils.checkDeleteResponse(response);
+
+ RestResponse restResponse = createResource(sdncModifierDetails, updatedResourceDetails);
+ assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
+
+ // check-in Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails,
+ sdncModifierDetails, resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ // String resourceCertifyVersion = "0.1";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(updatedResourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ updatedResourceDetails.setName("ABC_-bt.aT");
+ ArrayList<String> resourceTag = new ArrayList<String>();
+ resourceTag.add(0, "ABC_-bt.aT");
+ updatedResourceDetails.setTags(resourceTag);
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, updatedResourceDetails.getUniqueId(), "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
+
+ // Delete resources
+ response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
+ updatedResourceDetails.getName(), "0.1");
+ BaseRestUtils.checkDeleteResponse(response);
+ response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
+ updatedResourceDetails.getName(), "0.2");
+ BaseRestUtils.checkDeleteResponse(response);
+
+ }
+
+ @Test
+ public void UpdateIcon_InegativeFlow() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ List<String> resourceList = new ArrayList<String>();
+ resourceList.add(0, "Resource");
+ // check InValid Characters
+ char[] notValidCharsArray = new char[59];
+ notValidCharsArray = getInValidChars();
+ // update metadata details
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+ RestResponse updatedRestResponse;
+
+ for (int i = 0; i < notValidCharsArray.length; i++) {
+ // change icon of metadata
+ updatedResourceDetails.setIcon("MyIcon" + notValidCharsArray[i]);
+ // PUT request
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource",
+ updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(), resourceList,
+ updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource icon", 400,
+ updatedRestResponse.getErrorCode().intValue());
+ assertEquals("Check response code after updating resource icon", "Bad Request",
+ updatedRestResponse.getResponseMessage().toString());
+
+ }
+
+ // empty icon
+ String updateIcon = "";
+ updatedResourceDetails.setIcon(updateIcon);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(), resourceList,
+ updatedRestResponse.getResponse());
+
+ // Icon length more then 25 characters
+ resourceList.add(1, "25");
+ updatedResourceDetails.setIcon("1234567890_-qwertyuiopASDNNN");
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT.name(), resourceList,
+ updatedRestResponse.getResponse());
+ assertEquals("Check response code after create resource", 400, updatedRestResponse.getErrorCode().intValue());
+ assertEquals("Check response code after updating resource icon", "Bad Request",
+ updatedRestResponse.getResponseMessage().toString());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ }
+
+ @Test
+ public void UpdateResource_NoTagsEqualToResourceName() throws Exception {
+
+ User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ ResourceReqDetails updatedResourceDetails = defineResourse();
+ updatedResourceDetails.setName("updatedResourceName");
+ List<String> tags = updatedResourceDetails.getTags();
+
+ for (Iterator<String> iter = tags.listIterator(); iter.hasNext(); ) {
+ String a = iter.next();
+ if (a.equals("updatedResourceName")) {
+ iter.remove();
+ }
+ }
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ List<String> resourceList = new ArrayList<String>();
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME.name(),
+ resourceList, updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource icon", 400,
+ updatedRestResponse.getErrorCode().intValue());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ }
+
+ @Test
+ public void UpdateResourceName_negativeFlow() throws Exception {
+ // The validation are done in Tag's validation
+ User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+
+ RestResponse updatedRestResponse;
+ RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
+ assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
+ String uniqueId = resourceDetails.getUniqueId();
+ String resourceName = resourceDetails.getName();
+ // check InValid Characters
+ char[] notValidCharsArray = new char[59];
+ notValidCharsArray = getInValidChars();
+ ArrayList<String> resource_Name = new ArrayList<String>();
+ List<String> resourceList = new ArrayList<String>();
+
+ ArrayList<String> resourceTags = new ArrayList<String>();
+ resourceList.add(0, "Resource");
+
+ // update metadata details
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+ for (int i = 0; i < notValidCharsArray.length; i++, resource_Name.clear()) {
+ if (i != 1 && i != 46
+ && /*
* i != 8 && i != 9 && i != 10 && i != 11 && i != 12 &&
*/ i != 31) // space ("") and dot(.)
- {
- // change resourceName parameter
- updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
- resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
- updatedResourceDetails.setTags(resource_Name);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncAdminModifierDetails, uniqueId, "");
- // validate response
- // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
- // Empty_List, updatedRestResponse.getResponse());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList,
- updatedRestResponse.getResponse());
-
- }
- }
-
- // resourceName length more then 50 characters
- // Duplicate tags are allowed and should be de-duplicated by server side
- resource_Name.add(resourceName);
- resource_Name.add("tag1");
- resource_Name.add("tag1");
- resource_Name.add("tag2");
- resource_Name.add("tag2");
-
- resourceList.add(1, "1024");
- // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
- updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
- // resource_Name.add("123456789012345678901234567890123456789012345678901");
- updatedResourceDetails.setTags(resource_Name);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
- uniqueId, "");
- // validate response
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList,
- updatedRestResponse.getResponse());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- // delete resource
- RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails,
- updatedResourceDetails.getName(), "0.1");
- BaseRestUtils.checkDeleteResponse(response);
- }
-
- @Test
- public void UpdateResourceInformation_NotCheckedOut() throws Exception {
-
- String resourceBaseVersion = "0.1";
- List<String> resourceList = new ArrayList<String>();
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // CheckIn Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
- assertNotNull("check response object is not null after checkout resource", checkoutResource);
- assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
- assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
-
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
- updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource icon", 409,
- updatedRestResponse.getErrorCode().intValue());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
-
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- }
-
- @Test
- public void UpdateResourceInformation_resourceVersion_11() throws Exception {
-
- User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // restResponse);
-
- // Certify Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- String resourceCertifyVersion = "1.0";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- List<String> resourceList = new ArrayList<String>();
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
- updatedRestResponse.getResponse());
- // assertEquals("Check response code after updating resource icon", 409,
- // updatedRestResponse.getErrorCode().intValue());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
-
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
-
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- }
-
- @Test
- public void UpdateResourceInformation_resourceVersion_02() throws Exception {
-
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // restResponse);
-
- // Certify Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- // String resourceCertifyVersion = "0.1";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after updating resource icon", 200,
- updatedRestResponse.getErrorCode().intValue());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
-
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
-
- // delete resource
- RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
- updatedResourceDetails.getName(), "0.1");
- BaseRestUtils.checkDeleteResponse(response);
- response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
- updatedResourceDetails.getName(), "0.2");
- BaseRestUtils.checkDeleteResponse(response);
-
- }
-
- @Test
- public void UpdateResourceIcon_resourceVersion_11() throws Exception {
- // Can be changed only if major version is "0".
-
- User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // restResponse);
-
- // Certify Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- String resourceCertifyVersion = "1.0";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- // ResourceReqDetails updatedResourceDetails =
- // defineUpdatedResourse(resourceName);
- ResourceReqDetails updatedResourceDetails = defineResourse();
- // updatedResourceDetails.setVendorName("updatedVandorName");
- updatedResourceDetails.setIcon("updatedIcon");
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- List<String> resourceList = new ArrayList<String>();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList,
- updatedRestResponse.getResponse());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- }
-
- @Test
- public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
- // Can be changed only if the major resource version is "0".
- User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // restResponse);
-
- // Certify Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- String resourceCertifyVersion = "1.0";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- // ResourceReqDetails updatedResourceDetails =
- // defineUpdatedResourse(resourceName);
- ResourceReqDetails updatedResourceDetails = defineResourse();
-
- updatedResourceDetails.setVendorName("updatedVandorName");
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- List<String> resourceList = new ArrayList<String>();
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(),
- resourceList, updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource icon", 400,
- updatedRestResponse.getErrorCode().intValue());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- }
-
- @Test
- public void UpdateResourceName_resourceVersion_11() throws Exception {
- // Can be changed only if the major resource version is "0".
- User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
- String resourceName = resourceDetails.getName();
-
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // restResponse);
-
- // Certify Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- String resourceCertifyVersion = "1.0";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+ {
+ // change resourceName parameter
+ updatedResourceDetails.setName("UpdatedResourceName" + notValidCharsArray[i]);
+ resource_Name.add("UpdatedResourceName" + notValidCharsArray[i]);
+ updatedResourceDetails.setTags(resource_Name);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncAdminModifierDetails, uniqueId, "");
+ // validate response
+ // ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_TAG.name(),
+ // Empty_List, updatedRestResponse.getResponse());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_COMPONENT_NAME.name(), resourceList,
+ updatedRestResponse.getResponse());
+
+ }
+ }
+
+ // resourceName length more then 50 characters
+ // Duplicate tags are allowed and should be de-duplicated by server side
+ resource_Name.add(resourceName);
+ resource_Name.add("tag1");
+ resource_Name.add("tag1");
+ resource_Name.add("tag2");
+ resource_Name.add("tag2");
+
+ resourceList.add(1, "1024");
+ // updatedResourceDetails.setName("123456789012345678901234567890123456789012345678901");
+ updatedResourceDetails.setName(new String(new char[1025]).replace("\0", "a"));
+ // resource_Name.add("123456789012345678901234567890123456789012345678901");
+ updatedResourceDetails.setTags(resource_Name);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
+ uniqueId, "");
+ // validate response
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name(), resourceList,
+ updatedRestResponse.getResponse());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ // delete resource
+ RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails,
+ updatedResourceDetails.getName(), "0.1");
+ BaseRestUtils.checkDeleteResponse(response);
+ }
+
+ @Test
+ public void UpdateResourceInformation_NotCheckedOut() throws Exception {
+
+ String resourceBaseVersion = "0.1";
+ List<String> resourceList = new ArrayList<String>();
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // CheckIn Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
+ assertNotNull("check response object is not null after checkout resource", checkoutResource);
+ assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
+ assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
+
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
+ updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource icon", 409,
+ updatedRestResponse.getErrorCode().intValue());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ }
+
+ @Test
+ public void UpdateResourceInformation_resourceVersion_11() throws Exception {
+
+ User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // restResponse);
+
+ // Certify Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ /*logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ String resourceCertifyVersion = "1.0";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ List<String> resourceList = new ArrayList<String>();
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), resourceList,
+ updatedRestResponse.getResponse());
+ // assertEquals("Check response code after updating resource icon", 409,
+ // updatedRestResponse.getErrorCode().intValue());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ }
+
+ @Test
+ public void UpdateResourceInformation_resourceVersion_02() throws Exception {
+
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // restResponse);
+
+ // Certify Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ // String resourceCertifyVersion = "0.1";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after updating resource icon", 200,
+ updatedRestResponse.getErrorCode().intValue());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(updatedResourceDetails, getResourceRespJavaObject);
+
+ // delete resource
+ RestResponse response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
+ updatedResourceDetails.getName(), "0.1");
+ BaseRestUtils.checkDeleteResponse(response);
+ response = ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails,
+ updatedResourceDetails.getName(), "0.2");
+ BaseRestUtils.checkDeleteResponse(response);
+
+ }
+
+ @Test
+ public void UpdateResourceIcon_resourceVersion_11() throws Exception {
+ // Can be changed only if major version is "0".
+
+ User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // restResponse);
+
+ // Certify Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ /*logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ String resourceCertifyVersion = "1.0";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ // ResourceReqDetails updatedResourceDetails =
+ // defineUpdatedResourse(resourceName);
+ ResourceReqDetails updatedResourceDetails = defineResourse();
+ // updatedResourceDetails.setVendorName("updatedVandorName");
+ updatedResourceDetails.setIcon("updatedIcon");
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ List<String> resourceList = new ArrayList<String>();
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED.name(), resourceList,
+ updatedRestResponse.getResponse());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ }
+
+ @Test
+ public void UpdateResourceVandorName_resourceVersion_11() throws Exception {
+ // Can be changed only if the major resource version is "0".
+ User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // restResponse);
+
+ // Certify Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ /*logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ String resourceCertifyVersion = "1.0";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ // ResourceReqDetails updatedResourceDetails =
+ // defineUpdatedResourse(resourceName);
+ ResourceReqDetails updatedResourceDetails = defineResourse();
+
+ updatedResourceDetails.setVendorName("updatedVandorName");
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ List<String> resourceList = new ArrayList<String>();
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED.name(),
+ resourceList, updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource icon", 400,
+ updatedRestResponse.getErrorCode().intValue());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ }
+
+ @Test
+ public void UpdateResourceName_resourceVersion_11() throws Exception {
+ // Can be changed only if the major resource version is "0".
+ User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("create resource failed", 201, restResponse.getErrorCode().intValue());
+ String resourceName = resourceDetails.getName();
+
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // restResponse);
+
+ // Certify Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ /*logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ String resourceCertifyVersion = "1.0";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
/*
* //ResourceReqDetails updatedResourceDetails =
@@ -1319,1330 +1306,1330 @@ public class UpdateResourceMetadataTest extends ComponentBaseTest {
* updatedResourceDetails.setResourceName("updatedResourceName");
* updatedResourceDetails.setIcon("updatedResourceName");
*/
- resourceDetails.setName("updatedResourceName");
- List<String> tagList = new ArrayList<String>();
- tagList.add(0, "updatedResourceName");
- resourceDetails.setTags(tagList);
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- List<String> resourceList = new ArrayList<String>();
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList,
- updatedRestResponse.getResponse());
-
- }
-
- @Test
- public void UpdateResourceTag_resourceVersion_11() throws Exception {
- // Tag Can be updated when major version is "0".
- User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // restResponse);
-
- // Certify Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- String resourceCertifyVersion = "1.0";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- // ResourceReqDetails updatedResourceDetails =
- // defineUpdatedResourse(resourceName);
- ResourceReqDetails updatedResourceDetails = defineResourse();
- // updatedResourceDetails.setVendorName("updatedVandorName");
-
- ArrayList<String> resourceTags = new ArrayList<String>();
- resourceTags.add("NewTag");
- resourceTags.add(resourceDetails.getName());
-
- updatedResourceDetails.setTags(resourceTags);
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
-
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertNotNull("check response object is not null after update resource", getRestResponse);
- parseResponseAndValidate(updatedResourceDetails, getRestResponse);
-
- }
-
- @Test
- public void UpdateAllowedParames_resourceVersion_11() throws Exception {
-
- // Tag, contactId, vendorRelease,tags And description - Can be also
- // updated when major version is NOT "0".
- User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
-
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // restResponse);
-
- // Certify Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- String resourceCertifyVersion = "1.0";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- // ResourceReqDetails updatedResourceDetails =
- // defineUpdatedResourse(resourceName);
- ResourceReqDetails updatedResourceDetails = defineResourse();
- // updatedResourceDetails.setVendorName("updatedVandorName");
-
- // updated allowed parameters when major resource version is NOT "0"
- ArrayList<String> resourceTags = new ArrayList<String>();
- resourceTags.add("NewTag");
- resourceTags.add(resourceDetails.getName());
- updatedResourceDetails.setTags(resourceTags);
- updatedResourceDetails.setDescription("UpdatedDescription");
- updatedResourceDetails.setVendorRelease("5.1");
- updatedResourceDetails.setContactId("bt750h");
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
-
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertNotNull("check response object is not null after update resource", getRestResponse);
- parseResponseAndValidate(updatedResourceDetails, getRestResponse);
-
- }
-
- @Test
- public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
- // DerivedFrom parameter - Can be updated when major version is "0".
- User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- String resourceBaseVersion = "0.1";
-
- // create resource
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String resourceName = resourceDetails.getName();
-
- // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
- // restResponse);
-
- // Certify Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
- resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- String resourceCertifyVersion = "1.0";
- logger.debug("Changing resource life cycle ");
- checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
-
- // ResourceReqDetails updatedResourceDetails =
- // defineUpdatedResourse(resourceName);
- ResourceReqDetails updatedResourceDetails = defineResourse();
- ArrayList<String> drivenFrom = new ArrayList<String>();
- drivenFrom.add(0, "tosca.nodes.Container.Application");
- updatedResourceDetails.setDerivedFrom(drivenFrom);
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
- // validate response
- List<String> resourceList = new ArrayList<String>();
- ResourceRestUtils.checkSuccess(updatedRestResponse);
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- }
-
- @Test
- public void UpdateResource_vendorNameValidation() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- String updatedVendorName = "";
- String uniqueId = resourceDetails.getUniqueId();
- resourceDetails.setVendorName(updatedVendorName);
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, uniqueId, "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- // update resource vendorName metadata: 1 characters
- updatedVendorName = " ";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- // update resource vendorName metadata: 25 characters
- updatedVendorName = "Verification and validati";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- // update resource vendorName metadata: 26 characters
- updatedVendorName = "Verification and validatii";
- // set vendorName
- List<String> myList = new ArrayList<String>();
- myList.add(0, "25");
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList,
- updatedRestResponse.getResponse());
-
- // update resource VendorRelease metadata: forbidden characters
- updatedVendorName = "A1<";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorName = "A1>";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorName = "A1:";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorName = "A1\"";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorName = "A1/";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorName = "A1\\";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorName = "A1|";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorName = "A1?";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorName = "A1*";
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- // update resource vendorName metadata: null
- updatedVendorName = null;
- // set vendorName
- resourceDetails.setVendorName(updatedVendorName);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- }
-
- @Test
- public void UpdateResource_vendorReleaseValidation() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- RestResponse updatedRestResponse;
- String uniqueId = resourceDetails.getUniqueId();
- String updatedVendorRelease;
- // set VendorRelease
-
- // update resource VendorRelease metadata: 1 characters
- updatedVendorRelease = "1";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- // update resource VendorRelease metadata: 25 characters
- updatedVendorRelease = "(!#1.00000000000000000000";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- // update resource VendorRelease metadata: 26 characters
- updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
- Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
-
- // UpdateAndValidate(sdncModifierDetails, resourceDetails,
- // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
- // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
-
- // update resource VendorRelease metadata: forbidden characters
- updatedVendorRelease = "A1<";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorRelease = "A1>";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorRelease = "A1:";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorRelease = "A1\"";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorRelease = "A1/";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorRelease = "A1\\";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorRelease = "A1|";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorRelease = "A1?";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- updatedVendorRelease = "A1*";
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- // update resource VendorRelease metadata: null
- updatedVendorRelease = null;
- // set VendorRelease
- resourceDetails.setVendorRelease(updatedVendorRelease);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- }
-
- @Test
- public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
- // (6
- // characters
- // now,
- // may
- // be
- // expanded
- // up
- // to
- // 8
- // characters
- // in
- // the
- // future).
- // Convert
- // Upper
- // case
- // character
- // to
- // lower
- // case
- RestResponse updatedRestResponse;
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- String uniqueId = resourceDetails.getUniqueId();
-
- List<String> myList = new ArrayList<String>();
- myList.add(0, "Resource");
- String updatedcontactId = "";
- resourceDetails.setContactId(updatedcontactId);
-
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "ab12345";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = " ";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "ab 50h";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "ab123c";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- updatedcontactId = "cd789E";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
-
- resourceDetails.setContactId(updatedcontactId.toLowerCase());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- updatedcontactId = "ef4567";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- updatedcontactId = "AA012A";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
-
- resourceDetails.setContactId(updatedcontactId.toLowerCase());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- updatedcontactId = "CD012c";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
-
- resourceDetails.setContactId(updatedcontactId.toLowerCase());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- updatedcontactId = "EF0123";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
-
- resourceDetails.setContactId(updatedcontactId.toLowerCase());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- ////////////////////////////// **************//////////////////////////////
- List<String> resource = Arrays.asList("Resource");
- updatedcontactId = "01345a";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "0y000B";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "Y1000b";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "abxyzC";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "cdXYZc";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "efXY1D";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "EFabcD";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "EFABCD";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "EFABC1";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "efui1D";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "efui1!";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "ef555!";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = ",f555";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- updatedcontactId = "EF55.5";
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- // update resource contactId metadata: extended character set (128–255)
- resourceDetails.setContactId(extendedCharsStringBuilder());
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- // update resource contactId metadata: null
- updatedcontactId = null;
- resourceDetails.setContactId(updatedcontactId);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
- updatedRestResponse.getResponse());
-
- }
-
- @Test
- public void UpdateResource_TagsFieldValidation() throws Exception {
- RestResponse updatedRestResponse;
- // define and create resource
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- String uniqueId = resourceDetails.getUniqueId();
-
- String updatedTagField = "";
- ArrayList<String> resourceTags = new ArrayList<String>();
- resourceTags.add(updatedTagField);
- // set description
- resourceDetails.setTags(resourceTags);
- List<String> variables = Arrays.asList("Resource", "tag");
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
- updatedRestResponse.getResponse());
-
- // update resource tags metadata: empty
- resourceTags = new ArrayList<String>();
- // set Tags
- resourceDetails.setTags(resourceTags);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List,
- updatedRestResponse.getResponse());
-
- // update resource description metadata: 1 characters
- updatedTagField = "A";
- resourceTags = new ArrayList<String>();
- resourceTags.add(updatedTagField);
- resourceTags.add(resourceDetails.getName());
- // set description
- resourceDetails.setTags(resourceTags);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- // OK - tag up to 50 chars
- updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
- resourceTags.add(updatedTagField);
- resourceDetails.setTags(resourceTags);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
- String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
- String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
- String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
- String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
- String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
- String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
- String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
- String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
- String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
- String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
- String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
- String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
- String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
- String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
- String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
- String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
- String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
- String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
- String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
-
- resourceTags = new ArrayList<String>();
- resourceTags.add(updatedTagField);
- resourceTags.add(updatedTagField1);
- resourceTags.add(updatedTagField2);
- resourceTags.add(updatedTagField3);
- resourceTags.add(updatedTagField4);
- resourceTags.add(updatedTagField5);
- resourceTags.add(updatedTagField6);
- resourceTags.add(updatedTagField7);
- resourceTags.add(updatedTagField8);
- resourceTags.add(updatedTagField9);
- resourceTags.add(updatedTagField10);
- resourceTags.add(updatedTagField11);
- resourceTags.add(updatedTagField12);
- resourceTags.add(updatedTagField13);
- resourceTags.add(updatedTagField14);
- resourceTags.add(updatedTagField15);
- resourceTags.add(updatedTagField16);
- resourceTags.add(updatedTagField17);
- resourceTags.add(updatedTagField18);
- resourceTags.add(updatedTagField19);
- resourceTags.add(resourceDetails.getName());
- // set description
- resourceDetails.setTags(resourceTags);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- // Add another tag-exceeds limit
- resourceTags.add("d");
- resourceDetails.setTags(resourceTags);
- ArrayList<String> myArray = new ArrayList<String>();
- myArray.add(0, "1024");
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray,
- updatedRestResponse.getResponse());
-
- // Tag exceeds limit - 51
- resourceTags = new ArrayList<String>();
- updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
- resourceTags.add(updatedTagField);
- resourceTags.add(resourceDetails.getName());
- // set description
- resourceDetails.setTags(resourceTags);
- myArray.remove(0);
- myArray.add(0, "50");
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray,
- updatedRestResponse.getResponse());
-
- }
-
- @Test
- public void UpdateResource_DesriptionFieldValidation() throws Exception {
- // define and create resource
- RestResponse updatedRestResponse;
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- String uniqueId = resourceDetails.getUniqueId();
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- List<String> resource = new ArrayList<>();
- resource.add("Resource");
- // update resource description metadata: 0 characters
- String updatedDescription = "";
- // set description
- resourceDetails.setDescription(updatedDescription);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
- updatedRestResponse.getResponse());
-
- // update resource description metadata: null
- updatedDescription = null;
- // set description
- resourceDetails.setDescription(updatedDescription);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
- updatedRestResponse.getResponse());
-
- // update resource description metadata: 1 characters
- updatedDescription = "A";
- // set description
- resourceDetails.setDescription(updatedDescription);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- // update resource description metadata: 1024 characters
- updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
- + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
- + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
- + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
- + "The longest quills grow from its shoulders to about a third of the animal's length."
- + "Its tail is covered in short, hollow quills that can rattle when threatened."
- + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
- + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
- + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
- // set description
- resourceDetails.setDescription(updatedDescription);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- parseResponseAndValidate(resourceDetails, updatedRestResponse);
-
- // update resource description metadata: 1025 characters
- updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
- + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
- + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
- + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
- + "The longest quills grow from its shoulders to about a third of the animal's length."
- + "Its tail is covered in short, hollow quills that can rattle when threatened."
- + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
- + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
- + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
- // set description
- resourceDetails.setDescription(updatedDescription);
- resource.add(1, "1024");
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
- "");
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource,
- updatedRestResponse.getResponse());
-
- }
-
- @Test
- public void UpdateResource_TagsFormatValidation() throws Exception {
- char[] notValidCharsArray = getTagInValidFormatChars();
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
- String resourceName = resourceDetails.getName();
-
- // update tag details
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
- ArrayList<String> resourceTags = new ArrayList<String>();
-
- String updatedTagField;
- RestResponse updatedRestResponse;
- List<String> variables = Arrays.asList("Resource", "tag");
-
- for (int i = 0; i < notValidCharsArray.length; i++) {
- updatedTagField = "UpdatedTag" + notValidCharsArray[i];
- resourceTags = new ArrayList<String>();
- resourceTags.add(updatedTagField);
- resourceTags.add(resourceDetails.getName());
- // set description
- updatedResourceDetails.setTags(resourceTags);
-
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId(), "");
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource",
- updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
- updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource icon", 400,
- updatedRestResponse.getErrorCode().intValue());
- assertEquals("Check response code after updating resource icon", "Bad Request",
- updatedRestResponse.getResponseMessage().toString());
-
- }
-
- }
-
- @Test
- public void UpdateResourceCategory_negativeFlow() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
- Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- String uniqueID = resourceDetails.getUniqueId();
-
- // Update resource Category Successfully
- ResourceReqDetails updatedResourceDetails = resourceDetails;
-
- updatedResourceDetails.removeAllCategories();
- updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(),
- ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
-
- // validate response
- List<String> resourceList = new ArrayList<String>();
- resourceList.add(0, "Resource");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
- updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
-
- // Updating resource category
- updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
- updatedResourceDetails.addCategory("");
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId(), "");
- // validate response
- resourceList = new ArrayList<String>();
- resourceList.add(0, "Resource");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList,
- updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
-
- // Updating resource category
- updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
- updatedResourceDetails.addCategory("XXXXXX");
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId(), "");
- // validate response
- resourceList = new ArrayList<String>();
- resourceList.add(0, "Resource");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
- updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
-
- // CheckIn Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
- assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
-
- // Update resource Category
- updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
- updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
- resourceDetails.getUniqueId(), "");
- // verify response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List,
- updatedRestResponse.getResponse());
- assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
-
- // CheckIn Resource
- logger.debug("Changing resource life cycle ");
- RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
- assertNotNull("check response object is not null after checkout resource", checkoutResource);
- assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
- assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
-
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
- assertNotNull("check response object is not null after update resource", getRestResponse);
- parseResponseAndValidate(resourceDetails, getRestResponse);
-
- }
-
- @Test
- public void UpdateResourceCategorySuccessfully() throws Exception {
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
- Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
-
- // Update resource Category Successfully
- ResourceReqDetails updatedResourceDetails = resourceDetails;
-
- updatedResourceDetails.removeAllCategories();
- updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(),
- ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncModifierDetails, resourceDetails.getUniqueId(), "");
-
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
- // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
- // updatedRestResponse);
- parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
-
- // validate category updated
- assertTrue(updatedResourceDetails.getCategories().get(0).getName()
- .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
-
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
- resourceDetails.getUniqueId());
- assertNotNull("check response object is not null after update resource", getRestResponse);
- parseResponseAndValidate(updatedResourceDetails, getRestResponse);
-
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
- }
-
- // Benny
-
- @Test
- public void Validation_UpdateIcon() throws Exception {
- // Fields to update (Forbidden)
- String _updatedIcon = "mySecondIcon.Jpg";
-
- // administrator permissions
- User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
-
- // define and create resource
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
-
- RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- String resourceName = resourceDetails.getName();
-
- // update metadata details
- ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
- // change icon of metadata
- updatedResourceDetails.setIcon(_updatedIcon);
- // PUT request
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
- sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
-
- // validate response
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(),
- Arrays.asList("Resource"), updatedRestResponse.getResponse());
-
- // empty icon
- _updatedIcon = "";
- updatedResourceDetails.setIcon(_updatedIcon);
- updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
- resourceDetails.getUniqueId(), "");
- assertNotNull("check response object is not null after update resource", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(),
- Arrays.asList("Resource"), updatedRestResponse.getResponse());
-
- // get resource with original name. original metadata should be returned
- RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
- resourceDetails.getUniqueId());
- // validate response
- assertNotNull("check response object is not null after get resource", getRestResponse);
- assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
-
- // parse updated response to javaObject
- Resource getResourceRespJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(getRestResponse.getResponse());
- // validate that metadata was not changed
- ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
-
- ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(),
- "0.1");
-
- }
-
- @Test
- public void UpdateResourceTypeSuccess() throws Exception {
- // LCS is CheckOut
- String newResourceType = ResourceTypeEnum.VL.toString();
- String currentResourceType = resourceDetails.getResourceType();
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- Resource currentResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(restResponse.getResponse());
-
- resourceDetails.setResourceType(newResourceType);
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
- assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
- Resource updatedResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
- // assertTrue("Check resource type after update resource",
- // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
- assertTrue("Check resource type after update resource",
- updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
-
- }
-
- @Test
- public void UpdateResourceTypeAndNameSuccess() throws Exception {
- // LCS is CheckOut
- String newResourceType = ResourceTypeEnum.VL.toString();
- String currentResourceType = resourceDetails.getResourceType();
- String newResourceName = "new Name";
-
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- Resource currentResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(restResponse.getResponse());
-
- resourceDetails.setResourceType(newResourceType);
- resourceDetails.setName(newResourceName);
- List<String> tags = resourceDetails.getTags();
- tags.add(newResourceName);
- resourceDetails.setTags(tags);
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
- assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
- Resource updatedResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
- assertTrue("Check resource type after update resource",
- updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
- assertTrue("Check resource name after update resource",
- updatedResourceJavaObject.getName().equals(newResourceName));
-
- }
-
- @Test
- public void UpdateResourceTypeAfterResourceCertification() throws Exception {
-
- String newResourceType = ResourceTypeEnum.VF.toString();
- String currentResourceType = resourceDetails.getResourceType();
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- Resource currentResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(restResponse.getResponse());
-
- resourceDetails.setResourceType(newResourceType);
- restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
- assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- LifeCycleStatesEnum.CHECKOUT);
- assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
- currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
- assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
- Resource updatedResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
- // assertTrue("Check resource type after update resource",
- // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
- assertTrue("Check resource type after update resource",
- updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
-
- }
-
- @Test
- public void UpdateResourceTypeCheckInLCS() throws Exception {
-
- String resourceType = ResourceTypeEnum.VL.toString();
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- Resource currentResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(restResponse.getResponse());
-
- resourceDetails.setResourceType(resourceType);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
- LifeCycleStatesEnum.CHECKIN);
- assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
-
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
-
- assertNotNull("check response object is not null after create resouce", updatedRestResponse);
- assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after create resource", errorInfo.getCode(),
- updatedRestResponse.getErrorCode());
-
- List<String> variables = new ArrayList<>();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
- updatedRestResponse.getResponse());
-
- }
-
- @Test
- public void UpdateResourceTypeCertifiedLCS() throws Exception {
-
- String resourceType = ResourceTypeEnum.VL.toString();
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- Resource currentResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(restResponse.getResponse());
-
- restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
- assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
-
- resourceDetails.setResourceType(resourceType);
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
-
- assertNotNull("check response object is not null after create resouce", updatedRestResponse);
- assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after create resource", errorInfo.getCode(),
- updatedRestResponse.getErrorCode());
-
- List<String> variables = new ArrayList<>();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
- updatedRestResponse.getResponse());
-
- }
-
- @Test
- public void UpdateResourceTypeInvalidType() throws Exception {
-
- String resourceType = "INVALID TYPE";
- RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
- assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
- Resource currentResourceJavaObject = ResponseParser
- .convertResourceResponseToJavaObject(restResponse.getResponse());
+ resourceDetails.setName("updatedResourceName");
+ List<String> tagList = new ArrayList<String>();
+ tagList.add(0, "updatedResourceName");
+ resourceDetails.setTags(tagList);
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ List<String> resourceList = new ArrayList<String>();
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED.name(), resourceList,
+ updatedRestResponse.getResponse());
+
+ }
+
+ @Test
+ public void UpdateResourceTag_resourceVersion_11() throws Exception {
+ // Tag Can be updated when major version is "0".
+ User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // restResponse);
+
+ // Certify Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ /*logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ String resourceCertifyVersion = "1.0";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ // ResourceReqDetails updatedResourceDetails =
+ // defineUpdatedResourse(resourceName);
+ ResourceReqDetails updatedResourceDetails = defineResourse();
+ // updatedResourceDetails.setVendorName("updatedVandorName");
+
+ ArrayList<String> resourceTags = new ArrayList<String>();
+ resourceTags.add("NewTag");
+ resourceTags.add(resourceDetails.getName());
+
+ updatedResourceDetails.setTags(resourceTags);
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertNotNull("check response object is not null after update resource", getRestResponse);
+ parseResponseAndValidate(updatedResourceDetails, getRestResponse);
+
+ }
+
+ @Test
+ public void UpdateAllowedParames_resourceVersion_11() throws Exception {
+
+ // Tag, contactId, vendorRelease,tags And description - Can be also
+ // updated when major version is NOT "0".
+ User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // restResponse);
+
+ // Certify Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ /*logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ String resourceCertifyVersion = "1.0";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ // ResourceReqDetails updatedResourceDetails =
+ // defineUpdatedResourse(resourceName);
+ ResourceReqDetails updatedResourceDetails = defineResourse();
+ // updatedResourceDetails.setVendorName("updatedVandorName");
+
+ // updated allowed parameters when major resource version is NOT "0"
+ ArrayList<String> resourceTags = new ArrayList<String>();
+ resourceTags.add("NewTag");
+ resourceTags.add(resourceDetails.getName());
+ updatedResourceDetails.setTags(resourceTags);
+ updatedResourceDetails.setDescription("UpdatedDescription");
+ updatedResourceDetails.setVendorRelease("5.1");
+ updatedResourceDetails.setContactId("bt750h");
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertNotNull("check response object is not null after update resource", getRestResponse);
+ parseResponseAndValidate(updatedResourceDetails, getRestResponse);
+
+ }
+
+ @Test
+ public void UpdateResourceDerivedFrom_resourceVersion_11() throws Exception {
+ // DerivedFrom parameter - Can be updated when major version is "0".
+ User adminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ String resourceBaseVersion = "0.1";
+
+ // create resource
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String resourceName = resourceDetails.getName();
+
+ // resourceUtils.addResourceMandatoryArtifacts(sdncModifierDetails,
+ // restResponse);
+
+ // Certify Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ /*logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.STARTCERTIFICATION);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());*/
+
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, adminModifierDetails,
+ resourceBaseVersion, LifeCycleStatesEnum.CERTIFY);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ String resourceCertifyVersion = "1.0";
+ logger.debug("Changing resource life cycle ");
+ checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceCertifyVersion, LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after checkout resource", 200, checkoutResource.getErrorCode().intValue());
+
+ // ResourceReqDetails updatedResourceDetails =
+ // defineUpdatedResourse(resourceName);
+ ResourceReqDetails updatedResourceDetails = defineResourse();
+ ArrayList<String> drivenFrom = new ArrayList<String>();
+ drivenFrom.add(0, "tosca.nodes.Container.Application");
+ updatedResourceDetails.setDerivedFrom(drivenFrom);
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+ // validate response
+ List<String> resourceList = new ArrayList<String>();
+ ResourceRestUtils.checkSuccess(updatedRestResponse);
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ }
+
+ @Test
+ public void UpdateResource_vendorNameValidation() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ String updatedVendorName = "";
+ String uniqueId = resourceDetails.getUniqueId();
+ resourceDetails.setVendorName(updatedVendorName);
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, uniqueId, "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ // update resource vendorName metadata: 1 characters
+ updatedVendorName = " ";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ // update resource vendorName metadata: 25 characters
+ updatedVendorName = "Verification and validati";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ // update resource vendorName metadata: 26 characters
+ updatedVendorName = "Verification and validatii";
+ // set vendorName
+ List<String> myList = new ArrayList<String>();
+ myList.add(0, "25");
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ // update resource VendorRelease metadata: forbidden characters
+ updatedVendorName = "A1<";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorName = "A1>";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorName = "A1:";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorName = "A1\"";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorName = "A1/";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorName = "A1\\";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorName = "A1|";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorName = "A1?";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorName = "A1*";
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ // update resource vendorName metadata: null
+ updatedVendorName = null;
+ // set vendorName
+ resourceDetails.setVendorName(updatedVendorName);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_NAME.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ }
+
+ @Test
+ public void UpdateResource_vendorReleaseValidation() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ RestResponse updatedRestResponse;
+ String uniqueId = resourceDetails.getUniqueId();
+ String updatedVendorRelease;
+ // set VendorRelease
+
+ // update resource VendorRelease metadata: 1 characters
+ updatedVendorRelease = "1";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ // update resource VendorRelease metadata: 25 characters
+ updatedVendorRelease = "(!#1.00000000000000000000";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ // update resource VendorRelease metadata: 26 characters
+ updatedVendorRelease = "(!#1.000000000000000000005";// set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
+ Arrays.asList("" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH), updatedRestResponse.getResponse());
+
+ // UpdateAndValidate(sdncModifierDetails, resourceDetails,
+ // ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT.name(),
+ // Arrays.asList(""+ValidationUtils.VENDOR_RELEASE_MAX_LENGTH));
+
+ // update resource VendorRelease metadata: forbidden characters
+ updatedVendorRelease = "A1<";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorRelease = "A1>";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorRelease = "A1:";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorRelease = "A1\"";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorRelease = "A1/";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorRelease = "A1\\";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorRelease = "A1|";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorRelease = "A1?";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ updatedVendorRelease = "A1*";
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ // update resource VendorRelease metadata: null
+ updatedVendorRelease = null;
+ // set VendorRelease
+ resourceDetails.setVendorRelease(updatedVendorRelease);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_VENDOR_RELEASE.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ }
+
+ @Test
+ public void UpdateResource_contactIdValidation() throws Exception { // [a-zA-Z]{2}[0-9]{3}[a-zA-Z0-9]{1}
+ // (6
+ // characters
+ // now,
+ // may
+ // be
+ // expanded
+ // up
+ // to
+ // 8
+ // characters
+ // in
+ // the
+ // future).
+ // Convert
+ // Upper
+ // case
+ // character
+ // to
+ // lower
+ // case
+ RestResponse updatedRestResponse;
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ String uniqueId = resourceDetails.getUniqueId();
+
+ List<String> myList = new ArrayList<String>();
+ myList.add(0, "Resource");
+ String updatedcontactId = "";
+ resourceDetails.setContactId(updatedcontactId);
+
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "ab12345";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = " ";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "ab 50h";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "ab123c";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ updatedcontactId = "cd789E";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+
+ resourceDetails.setContactId(updatedcontactId.toLowerCase());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ updatedcontactId = "ef4567";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ updatedcontactId = "AA012A";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+
+ resourceDetails.setContactId(updatedcontactId.toLowerCase());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ updatedcontactId = "CD012c";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+
+ resourceDetails.setContactId(updatedcontactId.toLowerCase());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ updatedcontactId = "EF0123";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+
+ resourceDetails.setContactId(updatedcontactId.toLowerCase());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ ////////////////////////////// **************//////////////////////////////
+ List<String> resource = Arrays.asList("Resource");
+ updatedcontactId = "01345a";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "0y000B";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "Y1000b";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "abxyzC";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "cdXYZc";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "efXY1D";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "EFabcD";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "EFABCD";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "EFABC1";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "efui1D";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "efui1!";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "ef555!";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = ",f555";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ updatedcontactId = "EF55.5";
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ // update resource contactId metadata: extended character set (128–255)
+ resourceDetails.setContactId(extendedCharsStringBuilder());
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ // update resource contactId metadata: null
+ updatedcontactId = null;
+ resourceDetails.setContactId(updatedcontactId);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CONTACT.name(), myList,
+ updatedRestResponse.getResponse());
+
+ }
+
+ @Test
+ public void UpdateResource_TagsFieldValidation() throws Exception {
+ RestResponse updatedRestResponse;
+ // define and create resource
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ String uniqueId = resourceDetails.getUniqueId();
+
+ String updatedTagField = "";
+ ArrayList<String> resourceTags = new ArrayList<String>();
+ resourceTags.add(updatedTagField);
+ // set description
+ resourceDetails.setTags(resourceTags);
+ List<String> variables = Arrays.asList("Resource", "tag");
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
+ updatedRestResponse.getResponse());
+
+ // update resource tags metadata: empty
+ resourceTags = new ArrayList<String>();
+ // set Tags
+ resourceDetails.setTags(resourceTags);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_TAGS.name(), Empty_List,
+ updatedRestResponse.getResponse());
+
+ // update resource description metadata: 1 characters
+ updatedTagField = "A";
+ resourceTags = new ArrayList<String>();
+ resourceTags.add(updatedTagField);
+ resourceTags.add(resourceDetails.getName());
+ // set description
+ resourceDetails.setTags(resourceTags);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ // OK - tag up to 50 chars
+ updatedTagField = "The Indian-crested.porcupine_The Indian cresteddds";
+ resourceTags.add(updatedTagField);
+ resourceDetails.setTags(resourceTags);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ // OK - sum is 1024, 50x20+48+20(commas)+6(cisco4 - resource name)
+ String updatedTagField1 = "The Indian-crested.porcupine_The Indian crestedd01";
+ String updatedTagField2 = "The Indian-crested.porcupine_The Indian crestedd02";
+ String updatedTagField3 = "The Indian-crested.porcupine_The Indian crestedd03";
+ String updatedTagField4 = "The Indian-crested.porcupine_The Indian crestedd04";
+ String updatedTagField5 = "The Indian-crested.porcupine_The Indian crestedd05";
+ String updatedTagField6 = "The Indian-crested.porcupine_The Indian crestedd06";
+ String updatedTagField7 = "The Indian-crested.porcupine_The Indian crestedd07";
+ String updatedTagField8 = "The Indian-crested.porcupine_The Indian crestedd08";
+ String updatedTagField9 = "The Indian-crested.porcupine_The Indian crestedd09";
+ String updatedTagField10 = "The Indian-crested.porcupine_The Indian crestedd10";
+ String updatedTagField11 = "The Indian-crested.porcupine_The Indian crestedd11";
+ String updatedTagField12 = "The Indian-crested.porcupine_The Indian crestedd12";
+ String updatedTagField13 = "The Indian-crested.porcupine_The Indian crestedd13";
+ String updatedTagField14 = "The Indian-crested.porcupine_The Indian crestedd14";
+ String updatedTagField15 = "The Indian-crested.porcupine_The Indian crestedd15";
+ String updatedTagField16 = "The Indian-crested.porcupine_The Indian crestedd16";
+ String updatedTagField17 = "The Indian-crested.porcupine_The Indian crestedd17";
+ String updatedTagField18 = "The Indian-crested.porcupine_The Indian crestedd18";
+ String updatedTagField19 = "The Indian-crested.porcupine_The Indian crestaa";
+
+ resourceTags = new ArrayList<String>();
+ resourceTags.add(updatedTagField);
+ resourceTags.add(updatedTagField1);
+ resourceTags.add(updatedTagField2);
+ resourceTags.add(updatedTagField3);
+ resourceTags.add(updatedTagField4);
+ resourceTags.add(updatedTagField5);
+ resourceTags.add(updatedTagField6);
+ resourceTags.add(updatedTagField7);
+ resourceTags.add(updatedTagField8);
+ resourceTags.add(updatedTagField9);
+ resourceTags.add(updatedTagField10);
+ resourceTags.add(updatedTagField11);
+ resourceTags.add(updatedTagField12);
+ resourceTags.add(updatedTagField13);
+ resourceTags.add(updatedTagField14);
+ resourceTags.add(updatedTagField15);
+ resourceTags.add(updatedTagField16);
+ resourceTags.add(updatedTagField17);
+ resourceTags.add(updatedTagField18);
+ resourceTags.add(updatedTagField19);
+ resourceTags.add(resourceDetails.getName());
+ // set description
+ resourceDetails.setTags(resourceTags);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ // Add another tag-exceeds limit
+ resourceTags.add("d");
+ resourceDetails.setTags(resourceTags);
+ ArrayList<String> myArray = new ArrayList<String>();
+ myArray.add(0, "1024");
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT.name(), myArray,
+ updatedRestResponse.getResponse());
+
+ // Tag exceeds limit - 51
+ resourceTags = new ArrayList<String>();
+ updatedTagField = "The Indian-crested.porcupine_The Indian crestedddsw";
+ resourceTags.add(updatedTagField);
+ resourceTags.add(resourceDetails.getName());
+ // set description
+ resourceDetails.setTags(resourceTags);
+ myArray.remove(0);
+ myArray.add(0, "50");
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT.name(), myArray,
+ updatedRestResponse.getResponse());
+
+ }
+
+ @Test
+ public void UpdateResource_DesriptionFieldValidation() throws Exception {
+ // define and create resource
+ RestResponse updatedRestResponse;
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ String uniqueId = resourceDetails.getUniqueId();
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ List<String> resource = new ArrayList<>();
+ resource.add("Resource");
+ // update resource description metadata: 0 characters
+ String updatedDescription = "";
+ // set description
+ resourceDetails.setDescription(updatedDescription);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
+ updatedRestResponse.getResponse());
+
+ // update resource description metadata: null
+ updatedDescription = null;
+ // set description
+ resourceDetails.setDescription(updatedDescription);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_DESCRIPTION.name(), resource,
+ updatedRestResponse.getResponse());
+
+ // update resource description metadata: 1 characters
+ updatedDescription = "A";
+ // set description
+ resourceDetails.setDescription(updatedDescription);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ // update resource description metadata: 1024 characters
+ updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
+ + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
+ + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
+ + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
+ + "The longest quills grow from its shoulders to about a third of the animal's length."
+ + "Its tail is covered in short, hollow quills that can rattle when threatened."
+ + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
+ + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
+ + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury";
+ // set description
+ resourceDetails.setDescription(updatedDescription);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ parseResponseAndValidate(resourceDetails, updatedRestResponse);
+
+ // update resource description metadata: 1025 characters
+ updatedDescription = "The Indian crested porcupine *{Hystrix indica}*, or Indian porcupine is a member of the Old World porcupines."
+ + "It is quite an adaptable rodent, found throughout southern Asia and the Middle East."
+ + "It is tolerant of several different habitats: mountains, tropical and subtropical grasslands, scrublands, and forests."
+ + "It is a large rodent, growing more than 0.9 m = (3 ft) long and weighing 14.5 kg = (32 lb)! [citation needed] It is covered in multiple layers of quills."
+ + "The longest quills grow from its shoulders to about a third of the animal's length."
+ + "Its tail is covered in short, hollow quills that can rattle when threatened."
+ + "It has broad feet and long claws for digging. When attacked, the Indian crested porcupine raises its quills and rattles the hollow quills on its tail."
+ + "If the predator persists past these threats, the porcupine launches a backwards assault, hoping to stab its attacker with its quills."
+ + "It does this so effectively that most brushes between predators and the Indian porcupine end in death or severe injury.";
+ // set description
+ resourceDetails.setDescription(updatedDescription);
+ resource.add(1, "1024");
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails, sdncModifierDetails, uniqueId,
+ "");
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT.name(), resource,
+ updatedRestResponse.getResponse());
+
+ }
+
+ @Test
+ public void UpdateResource_TagsFormatValidation() throws Exception {
+ char[] notValidCharsArray = getTagInValidFormatChars();
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check recourse created ", 201, restResponse.getErrorCode().intValue());
+ String resourceName = resourceDetails.getName();
+
+ // update tag details
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+ ArrayList<String> resourceTags = new ArrayList<String>();
+
+ String updatedTagField;
+ RestResponse updatedRestResponse;
+ List<String> variables = Arrays.asList("Resource", "tag");
+
+ for (int i = 0; i < notValidCharsArray.length; i++) {
+ updatedTagField = "UpdatedTag" + notValidCharsArray[i];
+ resourceTags = new ArrayList<String>();
+ resourceTags.add(updatedTagField);
+ resourceTags.add(resourceDetails.getName());
+ // set description
+ updatedResourceDetails.setTags(resourceTags);
+
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource",
+ updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_FIELD_FORMAT.name(), variables,
+ updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource icon", 400,
+ updatedRestResponse.getErrorCode().intValue());
+ assertEquals("Check response code after updating resource icon", "Bad Request",
+ updatedRestResponse.getResponseMessage().toString());
+
+ }
+
+ }
+
+ @Test
+ public void UpdateResourceCategory_negativeFlow() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
+ Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+ String uniqueID = resourceDetails.getUniqueId();
+
+ // Update resource Category Successfully
+ ResourceReqDetails updatedResourceDetails = resourceDetails;
+
+ updatedResourceDetails.removeAllCategories();
+ updatedResourceDetails.addCategoryChain(ServiceCategoriesEnum.MOBILITY.getValue(),
+ ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+
+ // validate response
+ List<String> resourceList = new ArrayList<String>();
+ resourceList.add(0, "Resource");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
+ updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
+
+ // Updating resource category
+ updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
+ updatedResourceDetails.addCategory("");
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ // validate response
+ resourceList = new ArrayList<String>();
+ resourceList.add(0, "Resource");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_CATEGORY.name(), resourceList,
+ updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
+
+ // Updating resource category
+ updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
+ updatedResourceDetails.addCategory("XXXXXX");
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ // validate response
+ resourceList = new ArrayList<String>();
+ resourceList.add(0, "Resource");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_CATEGORY.name(), resourceList,
+ updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource", 400, updatedRestResponse.getErrorCode().intValue());
+
+ // CheckIn Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkoutResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKIN); // NOT_CERTIFIED_CHECKIN
+ assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
+
+ // Update resource Category
+ updatedResourceDetails = defineUpdateResourceWithNonUpdatableFields(resourceBeforeUpdate);
+ updatedResourceDetails.addCategory(ServiceCategoriesEnum.VOIP.getValue());
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ // verify response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), Empty_List,
+ updatedRestResponse.getResponse());
+ assertEquals("Check response code after updating resource", 409, updatedRestResponse.getErrorCode().intValue());
+
+ // CheckIn Resource
+ logger.debug("Changing resource life cycle ");
+ RestResponse checkinResource = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ resourceDetails.getVersion(), LifeCycleStatesEnum.CHECKOUT); // NOT_CERTIFIED_CHECKIN
+ assertNotNull("check response object is not null after checkout resource", checkoutResource);
+ assertNotNull("check error code exists in response after checkIn resource", checkoutResource.getErrorCode());
+ assertEquals("Check response code after checkin resource", 200, checkoutResource.getErrorCode().intValue());
+
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails, uniqueID);
+ assertNotNull("check response object is not null after update resource", getRestResponse);
+ parseResponseAndValidate(resourceDetails, getRestResponse);
+
+ }
+
+ @Test
+ public void UpdateResourceCategorySuccessfully() throws Exception {
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after update resource", 201, restResponse.getErrorCode().intValue());
+ Resource resourceBeforeUpdate = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+
+ // Update resource Category Successfully
+ ResourceReqDetails updatedResourceDetails = resourceDetails;
+
+ updatedResourceDetails.removeAllCategories();
+ updatedResourceDetails.addCategoryChain(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory(),
+ ResourceCategoryEnum.APPLICATION_L4_DATABASE.getSubCategory());
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncModifierDetails, resourceDetails.getUniqueId(), "");
+
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, updatedRestResponse.getErrorCode().intValue());
+ // parseResponseAndValidateNonUpdatable(updatedResourceDetails,
+ // updatedRestResponse);
+ parseResponseAndValidate(updatedResourceDetails, updatedRestResponse);
+
+ // validate category updated
+ assertTrue(updatedResourceDetails.getCategories().get(0).getName()
+ .equals(ResourceCategoryEnum.APPLICATION_L4_DATABASE.getCategory()));
+
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncModifierDetails,
+ resourceDetails.getUniqueId());
+ assertNotNull("check response object is not null after update resource", getRestResponse);
+ parseResponseAndValidate(updatedResourceDetails, getRestResponse);
+
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncModifierDetails, updatedResourceDetails.getName(), "0.1");
+ }
+
+ // Benny
+
+ @Test
+ public void Validation_UpdateIcon() throws Exception {
+ // Fields to update (Forbidden)
+ String _updatedIcon = "mySecondIcon.Jpg";
+
+ // administrator permissions
+ User sdncAdminModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+
+ // define and create resource
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, resourceDetails.getName(), "0.1");
+
+ RestResponse restResponse = createResource(sdncAdminModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ String resourceName = resourceDetails.getName();
+
+ // update metadata details
+ ResourceReqDetails updatedResourceDetails = defineUpdatedResourse(resourceName);
+ // change icon of metadata
+ updatedResourceDetails.setIcon(_updatedIcon);
+ // PUT request
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails,
+ sdncAdminModifierDetails, resourceDetails.getUniqueId(), "");
+
+ // validate response
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_INVALID_ICON.name(),
+ Arrays.asList("Resource"), updatedRestResponse.getResponse());
+
+ // empty icon
+ _updatedIcon = "";
+ updatedResourceDetails.setIcon(_updatedIcon);
+ updatedRestResponse = ResourceRestUtils.updateResourceMetadata(updatedResourceDetails, sdncAdminModifierDetails,
+ resourceDetails.getUniqueId(), "");
+ assertNotNull("check response object is not null after update resource", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.COMPONENT_MISSING_ICON.name(),
+ Arrays.asList("Resource"), updatedRestResponse.getResponse());
+
+ // get resource with original name. original metadata should be returned
+ RestResponse getRestResponse = ResourceRestUtils.getResource(sdncAdminModifierDetails,
+ resourceDetails.getUniqueId());
+ // validate response
+ assertNotNull("check response object is not null after get resource", getRestResponse);
+ assertNotNull("check error code exists in response after get resource", getRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", 200, getRestResponse.getErrorCode().intValue());
+
+ // parse updated response to javaObject
+ Resource getResourceRespJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(getRestResponse.getResponse());
+ // validate that metadata was not changed
+ ResourceValidationUtils.validateResourceReqVsResp(resourceDetails, getResourceRespJavaObject);
+
+ ResourceRestUtils.deleteResourceByNameAndVersion(sdncAdminModifierDetails, updatedResourceDetails.getName(),
+ "0.1");
+
+ }
+
+ @Test
+ public void UpdateResourceTypeSuccess() throws Exception {
+ // LCS is CheckOut
+ String newResourceType = ResourceTypeEnum.VL.toString();
+ String currentResourceType = resourceDetails.getResourceType();
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ Resource currentResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(restResponse.getResponse());
+
+ resourceDetails.setResourceType(newResourceType);
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
+ assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
+ Resource updatedResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
+ // assertTrue("Check resource type after update resource",
+ // updatedResourceJavaObject.getResourceType().toString().equals(resourceType));
+ assertTrue("Check resource type after update resource",
+ updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
+
+ }
+
+ @Test
+ public void UpdateResourceTypeAndNameSuccess() throws Exception {
+ // LCS is CheckOut
+ String newResourceType = ResourceTypeEnum.VL.toString();
+ String currentResourceType = resourceDetails.getResourceType();
+ String newResourceName = "new Name";
+
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ Resource currentResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(restResponse.getResponse());
+
+ resourceDetails.setResourceType(newResourceType);
+ resourceDetails.setName(newResourceName);
+ List<String> tags = resourceDetails.getTags();
+ tags.add(newResourceName);
+ resourceDetails.setTags(tags);
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
+ assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
+ Resource updatedResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
+ assertTrue("Check resource type after update resource",
+ updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
+ assertTrue("Check resource name after update resource",
+ updatedResourceJavaObject.getName().equals(newResourceName));
+
+ }
+
+ @Test
+ public void UpdateResourceTypeAfterResourceCertification() throws Exception {
+
+ String newResourceType = ResourceTypeEnum.VF.toString();
+ String currentResourceType = resourceDetails.getResourceType();
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ Resource currentResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(restResponse.getResponse());
+
+ resourceDetails.setResourceType(newResourceType);
+ restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
+ assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
+ restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
+ currentResourceJavaObject = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
+ assertEquals("Check response code after create resource", 200, updatedRestResponse.getErrorCode().intValue());
+ Resource updatedResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(updatedRestResponse.getResponse());
+ // assertTrue("Check resource type after update resource",
+ // updatedResourceJavaObject.getResourceType().toString().equals(newResourceType));
+ assertTrue("Check resource type after update resource",
+ updatedResourceJavaObject.getResourceType().toString().equals(currentResourceType));
+
+ }
+
+ @Test
+ public void UpdateResourceTypeCheckInLCS() throws Exception {
+
+ String resourceType = ResourceTypeEnum.VL.toString();
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ Resource currentResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(restResponse.getResponse());
+
+ resourceDetails.setResourceType(resourceType);
+ restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncModifierDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
+
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
+
+ assertNotNull("check response object is not null after create resouce", updatedRestResponse);
+ assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after create resource", errorInfo.getCode(),
+ updatedRestResponse.getErrorCode());
+
+ List<String> variables = new ArrayList<>();
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
+ updatedRestResponse.getResponse());
+
+ }
+
+ @Test
+ public void UpdateResourceTypeCertifiedLCS() throws Exception {
+
+ String resourceType = ResourceTypeEnum.VL.toString();
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ Resource currentResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(restResponse.getResponse());
+
+ restResponse = LifecycleRestUtils.certifyResource(resourceDetails);
+ assertEquals("Check response code after resource CheckIn", 200, restResponse.getErrorCode().intValue());
+
+ resourceDetails.setResourceType(resourceType);
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
+
+ assertNotNull("check response object is not null after create resouce", updatedRestResponse);
+ assertNotNull("check error code exists in response after create resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after create resource", errorInfo.getCode(),
+ updatedRestResponse.getErrorCode());
+
+ List<String> variables = new ArrayList<>();
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), variables,
+ updatedRestResponse.getResponse());
+
+ }
+
+ @Test
+ public void UpdateResourceTypeInvalidType() throws Exception {
+
+ String resourceType = "INVALID TYPE";
+ RestResponse restResponse = createResource(sdncModifierDetails, resourceDetails);
+ assertEquals("Check response code after create resource", 201, restResponse.getErrorCode().intValue());
+ Resource currentResourceJavaObject = ResponseParser
+ .convertResourceResponseToJavaObject(restResponse.getResponse());
- resourceDetails.setResourceType(resourceType);
- RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
- sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
-
- assertNotNull("check response object is not null after update resouce", updatedRestResponse);
- assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
- assertEquals("Check response code after update resource", errorInfo.getCode(),
- updatedRestResponse.getErrorCode());
+ resourceDetails.setResourceType(resourceType);
+ RestResponse updatedRestResponse = ResourceRestUtils.updateResourceMetadata(resourceDetails,
+ sdncModifierDetails, currentResourceJavaObject.getUniqueId(), "");
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
+
+ assertNotNull("check response object is not null after update resouce", updatedRestResponse);
+ assertNotNull("check error code exists in response after update resource", updatedRestResponse.getErrorCode());
+ assertEquals("Check response code after update resource", errorInfo.getCode(),
+ updatedRestResponse.getErrorCode());
- List<String> variables = new ArrayList<>();
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables,
- updatedRestResponse.getResponse());
+ List<String> variables = new ArrayList<>();
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.INVALID_CONTENT.name(), variables,
+ updatedRestResponse.getResponse());
- }
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java
index 895390f764..82a894f4eb 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VFResourceInstanceNameCRUD.java
@@ -20,14 +20,8 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
+import com.google.gson.Gson;
+import fj.data.Either;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -49,19 +43,18 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
public class VFResourceInstanceNameCRUD extends ComponentBaseTest {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java
index 37e7539fd9..c731b59184 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/ValidateExtendedVfData.java
@@ -20,11 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.List;
-
+import fj.data.Either;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
@@ -36,12 +32,7 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.AssocType;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
@@ -51,7 +42,10 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import fj.data.Either;
+import java.util.List;
+
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
public class ValidateExtendedVfData extends ComponentBaseTest {
@@ -217,7 +211,7 @@ public class ValidateExtendedVfData extends ComponentBaseTest {
callAllCheckMethods(resource);
}
- @Test
+ /*@Test
public void lifeCycleRequestForCertification() throws Exception {
RestResponse response = LifecycleRestUtils.changeComponentState(resourceDetailsVF, sdncUserDetails,
@@ -232,7 +226,7 @@ public class ValidateExtendedVfData extends ComponentBaseTest {
Resource resource = ResponseParser.convertResourceResponseToJavaObject(response.getResponse());
callAllCheckMethods(resource);
- }
+ }*/
@Test
public void lifeCycleCertificationRequest() throws Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java
index dddab57873..e966b4aae9 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/resource/VfComponentInstanceCRUDTest.java
@@ -20,56 +20,31 @@
package org.openecomp.sdc.ci.tests.execute.resource;
-import static org.junit.Assert.assertTrue;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_DELETE;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_NOT_FOUND;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
import org.junit.Rule;
import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.CapReqDef;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.RelationshipImpl;
-import org.openecomp.sdc.be.model.RelationshipInfo;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*;
+
public class VfComponentInstanceCRUDTest extends ComponentInstanceBaseTest {
@Rule
@@ -1728,7 +1703,7 @@ public class VfComponentInstanceCRUDTest extends ComponentInstanceBaseTest {
}
- @Test
+ /*@Test
public void testUnsatisfiedCpReqInVF() throws Exception {
// Certify all the needed atomic resources
@@ -1766,7 +1741,7 @@ public class VfComponentInstanceCRUDTest extends ComponentInstanceBaseTest {
submitForTesting = LifecycleRestUtils.changeResourceState(resourceDetailsVF_02, sdncDesignerDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
BaseValidationUtils.checkSuccess(submitForTesting);
- }
+ }*/
private void getVfResourceReqCapUsingAPI(int numberOfRIs, int numberOfRelations, User user)
throws IOException, Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java
index c8a20cf44a..5bb01d5dd6 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ChangeServiceDistributionStatusApiTest.java
@@ -20,23 +20,11 @@
package org.openecomp.sdc.ci.tests.execute.service;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
@@ -59,6 +47,12 @@ import org.openecomp.sdc.ci.tests.utils.validation.ServiceValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.testng.AssertJUnit.*;
+
public class ChangeServiceDistributionStatusApiTest extends ComponentBaseTest {
protected ResourceReqDetails resourceDetails;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java
index 56cfeb54ea..071624676f 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java
@@ -20,14 +20,7 @@
package org.openecomp.sdc.ci.tests.execute.service;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
+import com.fasterxml.jackson.annotation.JsonIgnore;
import org.json.JSONObject;
import org.junit.Rule;
import org.junit.rules.TestName;
@@ -56,12 +49,7 @@ import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ServiceValidationUtils;
@@ -69,7 +57,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
public class CreateServiceMetadataApiTest extends ComponentBaseTest {
private static Logger logger = LoggerFactory.getLogger(CreateServiceMetadataApiTest.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java
index 760d002856..a0091f9a7a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetAllServiceVersions.java
@@ -20,14 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.service;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -54,6 +46,14 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
public class GetAllServiceVersions extends ComponentBaseTest {
protected ResourceReqDetails resourceDetails;
protected ServiceReqDetails serviceDetails;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java
index 0417d565e3..544a7b1b63 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetComponentAuditApiTest.java
@@ -20,14 +20,9 @@
package org.openecomp.sdc.ci.tests.execute.service;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import fj.data.Either;
import org.apache.http.HttpStatus;
import org.junit.Rule;
import org.junit.rules.TestName;
@@ -50,23 +45,21 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
import org.openecomp.sdc.common.datastructure.Wrapper;
import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertTrue;
public class GetComponentAuditApiTest extends ComponentBaseTest {
@@ -140,7 +133,7 @@ public class GetComponentAuditApiTest extends ComponentBaseTest {
List<String> actions = new ArrayList<>();
JsonArray jsonArray = element.getAsJsonArray();
for( int i =0 ; i < jsonArray.size(); i++){
- actions.add(jsonArray.get(i).getAsJsonObject().get(AuditingFieldsKeysEnum.AUDIT_ACTION.getDisplayName()).getAsString());
+ actions.add(jsonArray.get(i).getAsJsonObject().get(AuditingFieldsKey.AUDIT_ACTION.getDisplayName()).getAsString());
}
long checkinCount = actions.stream().filter( e -> e.equals(AuditingActionEnum.CHECKIN_RESOURCE.getName())).count();
assertTrue(checkinCount == 5);
@@ -161,13 +154,13 @@ public class GetComponentAuditApiTest extends ComponentBaseTest {
}
protected void certifyResource(ResourceReqDetails defaultResource) throws IOException {
- RestResponse response = LifecycleRestUtils.changeResourceState(defaultResource, sdncDesignerUser,
+/* RestResponse response = LifecycleRestUtils.changeResourceState(defaultResource, sdncDesignerUser,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
AssertJUnit.assertTrue(response.getErrorCode() == HttpStatus.SC_OK);
response = LifecycleRestUtils.changeResourceState(defaultResource, sdncTesterUser,
LifeCycleStatesEnum.STARTCERTIFICATION);
- AssertJUnit.assertTrue(response.getErrorCode() == HttpStatus.SC_OK);
- response = LifecycleRestUtils.changeResourceState(defaultResource, sdncTesterUser, LifeCycleStatesEnum.CERTIFY);
+ AssertJUnit.assertTrue(response.getErrorCode() == HttpStatus.SC_OK);*/
+ RestResponse response = LifecycleRestUtils.changeResourceState(defaultResource, sdncTesterUser, LifeCycleStatesEnum.CERTIFY);
AssertJUnit.assertTrue(response.getErrorCode() == HttpStatus.SC_OK);
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java
index 19bed4d380..fc99946b91 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/GetServiceLatestVersionTest.java
@@ -20,13 +20,9 @@
package org.openecomp.sdc.ci.tests.execute.service;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -39,646 +35,638 @@ import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertTrue;
public class GetServiceLatestVersionTest extends ComponentInstanceBaseTest {
- protected ArtifactReqDetails heatArtifactDetails;
-
- @Rule
- public static TestName name = new TestName();
-
- public GetServiceLatestVersionTest() {
- super(name, GetServiceLatestVersionTest.class.getName());
- }
-
- @BeforeMethod
- public void before() throws Exception {
- initMembers();
- createAtomicResource(resourceDetailsVFC_01);
- changeResourceStateToCertified(resourceDetailsVFC_01);
- createAtomicResource(resourceDetailsCP_01);
- changeResourceStateToCertified(resourceDetailsCP_01);
- createAtomicResource(resourceDetailsVL_01);
- changeResourceStateToCertified(resourceDetailsVL_01);
- createVF(resourceDetailsVF_01);
- certifyVf(resourceDetailsVF_01);
- createService(serviceDetails_01);
- createService(serviceDetails_02);
- createService(serviceDetails_03);
- createProduct(productDetails_01);
- createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // create
- // certified
- // VF
- // instance
- // in
- // service
- /*
- * RestResponse restResponse =
+ protected ArtifactReqDetails heatArtifactDetails;
+
+ @Rule
+ public static TestName name = new TestName();
+
+ public GetServiceLatestVersionTest() {
+ super(name, GetServiceLatestVersionTest.class.getName());
+ }
+
+ @BeforeMethod
+ public void before() throws Exception {
+ initMembers();
+ createAtomicResource(resourceDetailsVFC_01);
+ changeResourceStateToCertified(resourceDetailsVFC_01);
+ createAtomicResource(resourceDetailsCP_01);
+ changeResourceStateToCertified(resourceDetailsCP_01);
+ createAtomicResource(resourceDetailsVL_01);
+ changeResourceStateToCertified(resourceDetailsVL_01);
+ createVF(resourceDetailsVF_01);
+ certifyVf(resourceDetailsVF_01);
+ createService(serviceDetails_01);
+ createService(serviceDetails_02);
+ createService(serviceDetails_03);
+ createProduct(productDetails_01);
+ createVFInstanceDuringSetup(serviceDetails_01, resourceDetailsVF_01, sdncDesignerDetails); // create
+ // certified
+ // VF
+ // instance
+ // in
+ // service
+ /*
+ * RestResponse restResponse =
* LifecycleRestUtils.changeServiceState(serviceDetails_01,
* sdncDesignerDetails, LifeCycleStates.CHECKIN);
* ResourceRestUtils.checkSuccess(restResponse);
*/
- }
-
- public void initMembers() throws Exception {
- heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
- sdncPsDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST1);
- sdncPmDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
- sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncTesterDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- resourceDetailsVFC_01 = ElementFactory.getDefaultResourceByType("VFC100", NormativeTypesEnum.COMPUTE,
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(),
- ResourceTypeEnum.VFC.toString()); // resourceType = VFC
- resourceDetailsVF_01 = ElementFactory.getDefaultResourceByType("VF100", NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(),
- ResourceTypeEnum.VF.toString());
- resourceDetailsCP_01 = ElementFactory.getDefaultResourceByType("CP100", NormativeTypesEnum.PORT,
- ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(),
- ResourceTypeEnum.CP.toString());
- resourceDetailsVL_01 = ElementFactory.getDefaultResourceByType("VL100", NormativeTypesEnum.NETWORK,
- ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(),
- ResourceTypeEnum.VL.toString());
- serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY,
- sdncDesignerDetails.getUserId());
- serviceDetails_02 = ElementFactory.getDefaultService("newtestservice2", ServiceCategoriesEnum.MOBILITY,
- sdncDesignerDetails.getUserId());
- serviceDetails_03 = ElementFactory.getDefaultService("newtestservice3", ServiceCategoriesEnum.MOBILITY,
- sdncDesignerDetails.getUserId());
- productDetails_01 = ElementFactory.getDefaultProduct("product01");
- }
-
- @Test
- public void getServicesLatestVersionServiceInCheckOutState() throws Exception {
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPsDetails1);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertNull("No Service returned, one service in checkout state 0.1", servcieFromList);
- }
-
- @Test
- public void getServicesLatestVersionServiceInCheckInState() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPsDetails1);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.1"));
- }
-
- @Test
- public void getServicesLatestVersionByPm() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPmDetails1);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.1"));
- }
-
- @Test
- public void getServicesLatestVersionByAdmin() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncAdminDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.1"));
- }
-
- @Test
- public void getServicesLatestVersionService02CheckOutState() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- String serviceUniqueID = ResponseParser.getUniqueIdFromResponse(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueID);
- assertTrue(servcieFromList.getVersion().equals("0.1"));
- servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertNull(servcieFromList);
- }
-
- @Test
- public void getServicesLatestVersionService02CheckInState() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.2"));
- }
-
- @Test
- public void getServicesLatestVersionServiceWaitingForCertification() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.2"));
- }
-
- @Test
- public void getServicesLatestVersionServiceCertificationInProgress() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.2"));
- }
-
- @Test
- public void getServicesLatestVersionServiceCertificationFail() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.FAILCERTIFICATION);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.2"));
- }
-
- @Test
- public void getServicesLatestVersionServiceCertifed() throws Exception {
- certifyService(serviceDetails_01);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("1.0"));
- }
-
- @Test
- public void getLatestVersionServiceHasSeveralCertifedVersion_01() throws Exception {
- RestResponse certifyServiceResponse;
- String serviceUniqueIdFromResponse = null;
- int numberOfCertifiedService = 3;
- for (int i = 0; i < numberOfCertifiedService; i++) {
- certifyServiceResponse = certifyService(serviceDetails_01);
- ServiceRestUtils.checkSuccess(certifyServiceResponse);
- if (i == (numberOfCertifiedService - 1)) {
- serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(certifyServiceResponse);
- }
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- }
- // We have service with following versions : 1.0, 2.0 ,3.0 and
- // 3.1(checkedOut)
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse);
- assertTrue(servcieFromList.getVersion().equals("3.0"));
- }
-
- @Test
- public void getLatestVersionServiceHasSeveralCertifedVersions02() throws Exception {
- RestResponse certifyServiceResponse;
- certifyServiceResponse = certifyService(serviceDetails_01);
- ServiceRestUtils.checkSuccess(certifyServiceResponse);
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- certifyServiceResponse = certifyService(serviceDetails_01);
- ServiceRestUtils.checkSuccess(certifyServiceResponse);
- // We have service with following versions : 1.0, 2.0
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("2.0"));
- }
-
- @Test
- public void getLatestVersionServiceCertifedWasCheckedOutAndCheckedin() throws Exception {
- RestResponse certifyServiceResponse;
- int numberOfCertifiedService = 3;
- for (int i = 0; i < numberOfCertifiedService; i++) {
- certifyServiceResponse = certifyService(serviceDetails_01);
- ServiceRestUtils.checkSuccess(certifyServiceResponse);
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- }
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- // We have service with following versions : 1.0, 2.0 and 2.1(checkedIn)
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("3.1"));
- }
-
- @Test
- public void getLatestVersionServiceCheckOutCertifedService() throws Exception {
- RestResponse restResponse;
- String serviceUniqueIdFromResponse = null;
- RestResponse certifyServiceResponse = certifyService(serviceDetails_01);
- ServiceRestUtils.checkSuccess(certifyServiceResponse);
- for (int i = 0; i < 11; i++) {
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- if (i == (10)) {
- serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse);
- }
- }
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- // We have service with following versions : 1.0 and 1.11(Check-out)
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse);
- assertTrue(servcieFromList.getVersion().equals("1.11"));
- }
-
- @Test
- public void getLatestVersionServiceCheckOutCheckInCertifedService() throws Exception {
- RestResponse restResponse;
- String serviceUniqueIdFromResponse = null;
- RestResponse certifyServiceResponse = certifyService(serviceDetails_01);
- ServiceRestUtils.checkSuccess(certifyServiceResponse);
- for (int i = 0; i < 12; i++) {
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- if (i == (11)) {
- serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse);
- }
- }
- // We have service with following versions : 1.0 and 1.11(Check-out)
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse);
- assertTrue(servcieFromList.getVersion().equals("1.12"));
- }
-
- @Test
- public void getLatestVersionServiceCertifedCheckedOutAndInWaitingForCertificationState() throws Exception {
- certifyService(serviceDetails_01); // 1.0
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ServiceRestUtils.checkSuccess(restResponse);
- // We have service with following versions : 1.0 and 1.1(Waiting For
- // Certification)
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("1.1"));
- }
-
- @Test
- public void getLatestVersionServiceCertifedCheckedOutAndInCertificationInProgressState() throws Exception {
- certifyService(serviceDetails_01); // 1.0
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- ServiceRestUtils.checkSuccess(restResponse);
- // We have service with following versions : 1.0 and 1.1(Certification
- // In Progress)
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("1.1"));
- }
-
- // DE190818
- @Test(enabled = false)
- public void getLatestVersionByNonAsdcUser() throws Exception {
- User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- nonAsdcUser.setUserId("gg750g");
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(nonAsdcUser);
- assertTrue(getServicesLatestVersion.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- getServicesLatestVersion.getResponse());
- }
-
- // DE190818
- @Test(enabled = false)
- public void getLatestVersionUserIdIsEmpty() throws Exception {
- User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- nonAsdcUser.setUserId("");
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(nonAsdcUser);
- assertTrue(getServicesLatestVersion.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
- getServicesLatestVersion.getResponse());
- }
-
- @Test
- public void getServicesLatestVersionByTester() throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncTesterDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 1);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.1"));
- }
-
- @Test
- public void getLatestVersionSeveralServicesInDifferentVersion() throws Exception {
- RestResponse restResponse = certifyService(serviceDetails_01); // 1.0
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = certifyService(serviceDetails_01);
- ServiceRestUtils.checkSuccess(restResponse);
- String service1_UniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_01
- // version is 2.1
- // (check-out)
-
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_02
- // version 0.2
- // (Check-in)
-
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- String service3_UniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_03
- // version 0.2
- // (Check-out)
-
- RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
- ServiceRestUtils.checkSuccess(getServicesLatestVersion);
- List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
- assertTrue(serviceList.size() == 3);
- Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, service1_UniqueIdFromResponse);
- assertTrue(servcieFromList.getVersion().equals("2.0"));
- servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_02.getUniqueId());
- assertTrue(servcieFromList.getVersion().equals("0.2"));
- servcieFromList = getResourceObjectFromResourceListByUid(serviceList, service3_UniqueIdFromResponse);
- assertTrue(servcieFromList.getVersion().equals("0.1"));
- }
-
- ///////////////////////////////////////////////////////////////
- private RestResponse certifyService(ServiceReqDetails serviceDetails) throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKOUT);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
- LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails,
- LifeCycleStatesEnum.STARTCERTIFICATION);
- ServiceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails,
- LifeCycleStatesEnum.CERTIFY);
- ServiceRestUtils.checkSuccess(restResponse);
- return restResponse;
- }
-
- protected List<Service> restResponseToResourceObjectList(RestResponse restResponse) {
- JsonElement jelement = new JsonParser().parse(restResponse.getResponse());
- JsonArray jsonArray = jelement.getAsJsonArray();
- List<Service> restResponseArray = new ArrayList<>();
- Service service = null;
- for (int i = 0; i < jsonArray.size(); i++) {
- String serviceString = (String) jsonArray.get(i).toString();
- service = ResponseParser.convertServiceResponseToJavaObject(serviceString);
- restResponseArray.add(service);
- }
- return restResponseArray;
- }
-
- protected Service getResourceObjectFromResourceListByUid(List<Service> serviceList, String uid) {
- if (serviceList != null && serviceList.size() > 0) {
- for (Service service : serviceList) {
- if (service.getUniqueId().equals(uid))
- return service;
- }
- } else
- return null;
- return null;
- }
-
- private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception {
- RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
- LifeCycleStatesEnum.CHECKIN);
- ResourceRestUtils.checkSuccess(restResponse);
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
+ }
+
+ public void initMembers() throws Exception {
+ heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
+ sdncPsDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST1);
+ sdncPmDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1);
+ sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+ sdncTesterDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
+ resourceDetailsVFC_01 = ElementFactory.getDefaultResourceByType("VFC100", NormativeTypesEnum.COMPUTE,
+ ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(),
+ ResourceTypeEnum.VFC.toString()); // resourceType = VFC
+ resourceDetailsVF_01 = ElementFactory.getDefaultResourceByType("VF100", NormativeTypesEnum.ROOT,
+ ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(),
+ ResourceTypeEnum.VF.toString());
+ resourceDetailsCP_01 = ElementFactory.getDefaultResourceByType("CP100", NormativeTypesEnum.PORT,
+ ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(),
+ ResourceTypeEnum.CP.toString());
+ resourceDetailsVL_01 = ElementFactory.getDefaultResourceByType("VL100", NormativeTypesEnum.NETWORK,
+ ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(),
+ ResourceTypeEnum.VL.toString());
+ serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY,
+ sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
+ serviceDetails_02 = ElementFactory.getDefaultService("newtestservice2", ServiceCategoriesEnum.MOBILITY,
+ sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
+ serviceDetails_03 = ElementFactory.getDefaultService("newtestservice3", ServiceCategoriesEnum.MOBILITY,
+ sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
+ productDetails_01 = ElementFactory.getDefaultProduct("product01");
+ }
+
+ @Test
+ public void getServicesLatestVersionServiceInCheckOutState() throws Exception {
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPsDetails1);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertNull("No Service returned, one service in checkout state 0.1", servcieFromList);
+ }
+
+ @Test
+ public void getServicesLatestVersionServiceInCheckInState() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPsDetails1);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.1"));
+ }
+
+ @Test
+ public void getServicesLatestVersionByPm() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncPmDetails1);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.1"));
+ }
+
+ @Test
+ public void getServicesLatestVersionByAdmin() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncAdminDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.1"));
+ }
+
+ @Test
+ public void getServicesLatestVersionService02CheckOutState() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ String serviceUniqueID = ResponseParser.getUniqueIdFromResponse(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueID);
+ assertTrue(servcieFromList.getVersion().equals("0.1"));
+ servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertNull(servcieFromList);
+ }
+
+ @Test
+ public void getServicesLatestVersionService02CheckInState() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.2"));
+ }
+
+ @Test
+ public void getServicesLatestVersionServiceWaitingForCertification() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.2"));
+ }
+
+ @Test
+ public void getServicesLatestVersionServiceCertificationInProgress() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
+ LifeCycleStatesEnum.STARTCERTIFICATION);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.2"));
+ }
+
+ @Test
+ public void getServicesLatestVersionServiceCertificationFail() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
+ LifeCycleStatesEnum.STARTCERTIFICATION);
+ ResourceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
+ LifeCycleStatesEnum.FAILCERTIFICATION);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.2"));
+ }
+
+ @Test
+ public void getServicesLatestVersionServiceCertifed() throws Exception {
+ certifyService(serviceDetails_01);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("1.0"));
+ }
+
+ @Test
+ public void getLatestVersionServiceHasSeveralCertifedVersion_01() throws Exception {
+ RestResponse certifyServiceResponse;
+ String serviceUniqueIdFromResponse = null;
+ int numberOfCertifiedService = 3;
+ for (int i = 0; i < numberOfCertifiedService; i++) {
+ certifyServiceResponse = certifyService(serviceDetails_01);
+ ServiceRestUtils.checkSuccess(certifyServiceResponse);
+ if (i == (numberOfCertifiedService - 1)) {
+ serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(certifyServiceResponse);
+ }
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ }
+ // We have service with following versions : 1.0, 2.0 ,3.0 and
+ // 3.1(checkedOut)
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse);
+ assertTrue(servcieFromList.getVersion().equals("3.0"));
+ }
+
+ @Test
+ public void getLatestVersionServiceHasSeveralCertifedVersions02() throws Exception {
+ RestResponse certifyServiceResponse;
+ certifyServiceResponse = certifyService(serviceDetails_01);
+ ServiceRestUtils.checkSuccess(certifyServiceResponse);
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ certifyServiceResponse = certifyService(serviceDetails_01);
+ ServiceRestUtils.checkSuccess(certifyServiceResponse);
+ // We have service with following versions : 1.0, 2.0
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("2.0"));
+ }
+
+ @Test
+ public void getLatestVersionServiceCertifedWasCheckedOutAndCheckedin() throws Exception {
+ RestResponse certifyServiceResponse;
+ int numberOfCertifiedService = 3;
+ for (int i = 0; i < numberOfCertifiedService; i++) {
+ certifyServiceResponse = certifyService(serviceDetails_01);
+ ServiceRestUtils.checkSuccess(certifyServiceResponse);
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ }
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ // We have service with following versions : 1.0, 2.0 and 2.1(checkedIn)
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("3.1"));
+ }
+
+ @Test
+ public void getLatestVersionServiceCheckOutCertifedService() throws Exception {
+ RestResponse restResponse;
+ String serviceUniqueIdFromResponse = null;
+ RestResponse certifyServiceResponse = certifyService(serviceDetails_01);
+ ServiceRestUtils.checkSuccess(certifyServiceResponse);
+ for (int i = 0; i < 11; i++) {
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ if (i == (10)) {
+ serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse);
+ }
+ }
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ // We have service with following versions : 1.0 and 1.11(Check-out)
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse);
+ assertTrue(servcieFromList.getVersion().equals("1.11"));
+ }
+
+ @Test
+ public void getLatestVersionServiceCheckOutCheckInCertifedService() throws Exception {
+ RestResponse restResponse;
+ String serviceUniqueIdFromResponse = null;
+ RestResponse certifyServiceResponse = certifyService(serviceDetails_01);
+ ServiceRestUtils.checkSuccess(certifyServiceResponse);
+ for (int i = 0; i < 12; i++) {
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ if (i == (11)) {
+ serviceUniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse);
+ }
+ }
+ // We have service with following versions : 1.0 and 1.11(Check-out)
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceUniqueIdFromResponse);
+ assertTrue(servcieFromList.getVersion().equals("1.12"));
+ }
+
+ @Test
+ public void getLatestVersionServiceCertifedCheckedOutAndInWaitingForCertificationState() throws Exception {
+ certifyService(serviceDetails_01); // 1.0
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ ServiceRestUtils.checkSuccess(restResponse);
+ // We have service with following versions : 1.0 and 1.1(Waiting For
+ // Certification)
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("1.1"));
+ }
+
+ @Test
+ public void getLatestVersionServiceCertifedCheckedOutAndInCertificationInProgressState() throws Exception {
+ certifyService(serviceDetails_01); // 1.0
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncTesterDetails,
+ LifeCycleStatesEnum.STARTCERTIFICATION);
+ ServiceRestUtils.checkSuccess(restResponse);
+ // We have service with following versions : 1.0 and 1.1(Certification
+ // In Progress)
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("1.1"));
+ }
+
+ // DE190818
+ @Test(enabled = false)
+ public void getLatestVersionByNonAsdcUser() throws Exception {
+ User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ nonAsdcUser.setUserId("gg750g");
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(nonAsdcUser);
+ assertTrue(getServicesLatestVersion.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
+ getServicesLatestVersion.getResponse());
+ }
+
+ // DE190818
+ @Test(enabled = false)
+ public void getLatestVersionUserIdIsEmpty() throws Exception {
+ User nonAsdcUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ nonAsdcUser.setUserId("");
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(nonAsdcUser);
+ assertTrue(getServicesLatestVersion.getErrorCode() == STATUS_CODE_RESTRICTED_OPERATION);
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
+ getServicesLatestVersion.getResponse());
+ }
+
+ @Test
+ public void getServicesLatestVersionByTester() throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncTesterDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 1);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_01.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.1"));
+ }
+
+ @Test
+ public void getLatestVersionSeveralServicesInDifferentVersion() throws Exception {
+ RestResponse restResponse = certifyService(serviceDetails_01); // 1.0
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = certifyService(serviceDetails_01);
+ ServiceRestUtils.checkSuccess(restResponse);
+ String service1_UniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_01, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_01
+ // version is 2.1
+ // (check-out)
+
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_02, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_02
+ // version 0.2
+ // (Check-in)
+
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ String service3_UniqueIdFromResponse = ResponseParser.getUniqueIdFromResponse(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails_03, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse); // serviceDetails_03
+ // version 0.2
+ // (Check-out)
+
+ RestResponse getServicesLatestVersion = ServiceRestUtils.getServiceLatestVersionList(sdncDesignerDetails);
+ ServiceRestUtils.checkSuccess(getServicesLatestVersion);
+ List<Service> serviceList = restResponseToResourceObjectList(getServicesLatestVersion);
+ assertTrue(serviceList.size() == 3);
+ Service servcieFromList = getResourceObjectFromResourceListByUid(serviceList, service1_UniqueIdFromResponse);
+ assertTrue(servcieFromList.getVersion().equals("2.0"));
+ servcieFromList = getResourceObjectFromResourceListByUid(serviceList, serviceDetails_02.getUniqueId());
+ assertTrue(servcieFromList.getVersion().equals("0.2"));
+ servcieFromList = getResourceObjectFromResourceListByUid(serviceList, service3_UniqueIdFromResponse);
+ assertTrue(servcieFromList.getVersion().equals("0.1"));
+ }
+
+ ///////////////////////////////////////////////////////////////
+ private RestResponse certifyService(ServiceReqDetails serviceDetails) throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKOUT);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncDesignerDetails,
+ LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails,
+ LifeCycleStatesEnum.STARTCERTIFICATION);
+ ServiceRestUtils.checkSuccess(restResponse);
+ restResponse = LifecycleRestUtils.changeServiceState(serviceDetails, sdncTesterDetails,
+ LifeCycleStatesEnum.CERTIFY);
+ ServiceRestUtils.checkSuccess(restResponse);
+ return restResponse;
+ }
+
+ protected List<Service> restResponseToResourceObjectList(RestResponse restResponse) {
+ JsonElement jelement = new JsonParser().parse(restResponse.getResponse());
+ JsonArray jsonArray = jelement.getAsJsonArray();
+ List<Service> restResponseArray = new ArrayList<>();
+ Service service = null;
+ for (int i = 0; i < jsonArray.size(); i++) {
+ String serviceString = (String) jsonArray.get(i).toString();
+ service = ResponseParser.convertServiceResponseToJavaObject(serviceString);
+ restResponseArray.add(service);
+ }
+ return restResponseArray;
+ }
+
+ protected Service getResourceObjectFromResourceListByUid(List<Service> serviceList, String uid) {
+ if (serviceList != null && serviceList.size() > 0) {
+ for (Service service : serviceList) {
+ if (service.getUniqueId().equals(uid))
+ return service;
+ }
+ } else
+ return null;
+ return null;
+ }
+
+ private RestResponse changeResourceStateToCertified(ResourceReqDetails resourceDetails) throws Exception {
+ RestResponse restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
+ LifeCycleStatesEnum.CHECKIN);
+ ResourceRestUtils.checkSuccess(restResponse);
+ /*restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncDesignerDetails,
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
if (restResponse.getErrorCode() == 200) {
restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails,
LifeCycleStatesEnum.STARTCERTIFICATION);
} else
return restResponse;
- if (restResponse.getErrorCode() == 200) {
- restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails,
- LifeCycleStatesEnum.CERTIFY);
- if (restResponse.getErrorCode() == 200) {
- String newVersion = ResponseParser.getVersionFromResponse(restResponse);
- resourceDetails.setVersion(newVersion);
- resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- resourceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
- resourceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
- String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(),
- "uniqueId");
- resourceDetails.setUniqueId(uniqueIdFromRresponse);
- }
- }
- return restResponse;
- }
-
- // private void certifyVf(ResourceReqDetails resource) throws Exception {
- // RestResponse createAtomicResourceInstance =
- // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_01,
- // sdncDesignerDetails);
- // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- // createAtomicResourceInstance =
- // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01,
- // sdncDesignerDetails);
- // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- // createAtomicResourceInstance =
- // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01,
- // sdncDesignerDetails);
- // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- // //createVFInstanceDuringSetup(service, resource, sdncDesignerDetails);
- // RestResponse response =
- // ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails,
- // sdncDesignerDetails, resource.getUniqueId());
- // ResourceRestUtils.checkSuccess(response);
- // RestResponse changeResourceStateToCertified =
- // changeResourceStateToCertified(resource);
- // ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
- // }
-
- private void certifyVf(ResourceReqDetails resource) throws Exception {
- RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String cpCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String computeCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01,
- sdncDesignerDetails);
- ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
- String vlCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
-
- // Fixing Vl/Cp req/cap
- ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE;
- User user = sdncDesignerDetails;
- fulfillCpRequirement(resource, cpCompInstId, computeCompInstId, computeCompInstId, user, containerCompType);
- consumeVlCapability(resource, cpCompInstId, vlCompInstId, cpCompInstId, user, containerCompType);
-
- RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails,
- sdncDesignerDetails, resource.getUniqueId());
- ResourceRestUtils.checkSuccess(response);
- RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource);
- ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
- }
+ if (restResponse.getErrorCode() == 200) {*/
+ restResponse = LifecycleRestUtils.changeResourceState(resourceDetails, sdncTesterDetails, LifeCycleStatesEnum.CERTIFY);
+ if (restResponse.getErrorCode() == 200) {
+ String newVersion = ResponseParser.getVersionFromResponse(restResponse);
+ resourceDetails.setVersion(newVersion);
+ resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
+ resourceDetails.setLastUpdaterUserId(sdncTesterDetails.getUserId());
+ resourceDetails.setLastUpdaterFullName(sdncTesterDetails.getFullName());
+ String uniqueIdFromRresponse = ResponseParser.getValueFromJsonResponse(restResponse.getResponse(),
+ "uniqueId");
+ resourceDetails.setUniqueId(uniqueIdFromRresponse);
+ }
+ return restResponse;
+ }
+
+ // private void certifyVf(ResourceReqDetails resource) throws Exception {
+ // RestResponse createAtomicResourceInstance =
+ // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_01,
+ // sdncDesignerDetails);
+ // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ // createAtomicResourceInstance =
+ // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01,
+ // sdncDesignerDetails);
+ // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ // createAtomicResourceInstance =
+ // createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01,
+ // sdncDesignerDetails);
+ // ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ // //createVFInstanceDuringSetup(service, resource, sdncDesignerDetails);
+ // RestResponse response =
+ // ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails,
+ // sdncDesignerDetails, resource.getUniqueId());
+ // ResourceRestUtils.checkSuccess(response);
+ // RestResponse changeResourceStateToCertified =
+ // changeResourceStateToCertified(resource);
+ // ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
+ // }
+
+ private void certifyVf(ResourceReqDetails resource) throws Exception {
+ RestResponse createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsCP_01,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ String cpCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
+
+ createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVFC_01,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ String computeCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
+
+ createAtomicResourceInstance = createAtomicInstanceForVFDuringSetup(resource, resourceDetailsVL_01,
+ sdncDesignerDetails);
+ ResourceRestUtils.checkCreateResponse(createAtomicResourceInstance);
+ String vlCompInstId = ResponseParser.getUniqueIdFromResponse(createAtomicResourceInstance);
+
+ // Fixing Vl/Cp req/cap
+ ComponentTypeEnum containerCompType = ComponentTypeEnum.RESOURCE;
+ User user = sdncDesignerDetails;
+ fulfillCpRequirement(resource, cpCompInstId, computeCompInstId, computeCompInstId, user, containerCompType);
+ consumeVlCapability(resource, cpCompInstId, vlCompInstId, cpCompInstId, user, containerCompType);
+
+ RestResponse response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails,
+ sdncDesignerDetails, resource.getUniqueId());
+ ResourceRestUtils.checkSuccess(response);
+ RestResponse changeResourceStateToCertified = changeResourceStateToCertified(resource);
+ ResourceRestUtils.checkSuccess(changeResourceStateToCertified);
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java
index fdec8346fc..6db27b9e4f 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ReqCapOccurrencesTest.java
@@ -20,57 +20,34 @@
package org.openecomp.sdc.ci.tests.execute.service;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-
import org.apache.http.client.ClientProtocolException;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.CapReqDef;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.RelationshipImpl;
-import org.openecomp.sdc.be.model.RelationshipInfo;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.general.ImportUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
+import static org.testng.AssertJUnit.*;
+
public class ReqCapOccurrencesTest extends ComponentInstanceBaseTest {
private ImportReqDetails importReqDetails1; // atomic resource
@@ -164,7 +141,7 @@ public class ReqCapOccurrencesTest extends ComponentInstanceBaseTest {
ResourceRestUtils.checkCreateResponse(createResourceVF200);
// Create Service
serviceDetails_01 = ElementFactory.getDefaultService("newtestservice1", ServiceCategoriesEnum.MOBILITY,
- sdncDesignerDetails.getUserId());
+ sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
RestResponse createServiceRestResponse = ServiceRestUtils.createService(serviceDetails_01, sdncDesignerDetails);
ResourceRestUtils.checkCreateResponse(createServiceRestResponse);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java
index b2728ea0da..60ca71d676 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/ServiceComponentInstanceCRUDTest.java
@@ -20,45 +20,20 @@
package org.openecomp.sdc.ci.tests.execute.service;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import org.codehaus.jettison.json.JSONException;
import org.json.JSONArray;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.CapReqDef;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentInstanceBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.*;
import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.slf4j.Logger;
@@ -67,6 +42,15 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest {
private static Logger log = LoggerFactory.getLogger(ServiceComponentInstanceCRUDTest.class.getName());
private static final String SPACE_STRING = " ";
@@ -115,9 +99,9 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest
}
private void certifyResource(ResourceReqDetails resource) throws Exception {
- changeResourceLifecycleState(resource, sdncDesignerDetails.getUserId(),
+ /*changeResourceLifecycleState(resource, sdncDesignerDetails.getUserId(),
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
- changeResourceLifecycleState(resource, sdncTesterDetails.getUserId(), LifeCycleStatesEnum.STARTCERTIFICATION);
+ changeResourceLifecycleState(resource, sdncTesterDetails.getUserId(), LifeCycleStatesEnum.STARTCERTIFICATION);*/
changeResourceLifecycleState(resource, sdncTesterDetails.getUserId(), LifeCycleStatesEnum.CERTIFY);
}
@@ -444,7 +428,7 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest
getComponentAndValidateRIs(serviceDetails_01, 2, 0);
}
- @Test
+ /*@Test
public void createResourceInstance_ResourceInCertificationRequestStateTest() throws Exception {
changeResourceLifecycleState(resourceDetailsVF_01, sdncDesignerDetails.getUserId(),
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
@@ -453,9 +437,9 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest
createVFInstanceAndAtomicResourceInstanceSuccessully(resourceDetailsVF_01, resourceDetailsCP_01);
getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
+ }*/
- @Test
+ /*@Test
public void createResourceInstance_startCertificationStateTest() throws Exception {
changeResourceLifecycleState(resourceDetailsVF_01, sdncDesignerDetails.getUserId(),
LifeCycleStatesEnum.CERTIFICATIONREQUEST);
@@ -471,7 +455,7 @@ public class ServiceComponentInstanceCRUDTest extends ComponentInstanceBaseTest
sdncDesignerDetails);
getComponentAndValidateRIs(serviceDetails_01, 2, 0);
- }
+ }*/
@Test
public void createResourceInstance_certifiedStateTest() throws Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java
index 304f61d280..18c2614040 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.service;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jettison.json.JSONException;
import org.junit.Rule;
@@ -59,6 +52,13 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+
public class UpdateServiceMetadataTest extends ComponentBaseTest {
protected ArrayList<String> listForMessage = new ArrayList<String>();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java
index 28cf1b787f..df1e6b2a6e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java
@@ -20,18 +20,8 @@
package org.openecomp.sdc.ci.tests.execute.user;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import com.google.gson.*;
+import com.google.gson.reflect.TypeToken;
import org.apache.http.HttpStatus;
import org.junit.Rule;
import org.junit.rules.TestName;
@@ -54,11 +44,7 @@ import org.openecomp.sdc.ci.tests.users.UserResponseMessageEnum;
import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.general.Convertor;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.UserRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ResourceValidationUtils;
@@ -69,12 +55,10 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.reflect.TypeToken;
+import java.util.*;
+import java.util.Map.Entry;
+
+import static org.testng.AssertJUnit.*;
/**
* @author alitvinsky
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java
index 2f979f3d15..d509966490 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/CreateUserApiTest.java
@@ -20,11 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.user;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.io.IOException;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -47,6 +42,11 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.IOException;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+
public class CreateUserApiTest extends ComponentBaseTest {
protected User sdncAdminUser;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java
index c7c2fdd998..5a56af5d4c 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/GovernorWorkspaceApiTest.java
@@ -20,14 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.user;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.List;
-
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.junit.Rule;
@@ -50,17 +42,18 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ServiceValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.IOException;
+import java.util.List;
+
+import static org.testng.AssertJUnit.*;
+
public class GovernorWorkspaceApiTest extends ComponentBaseTest {
private static Logger logger = LoggerFactory.getLogger(GovernorWorkspaceApiTest.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/ComplexResourceBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/ComplexResourceBaseTest.java
index 14c7a37101..32f355d14c 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/ComplexResourceBaseTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/ComplexResourceBaseTest.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.ci.tests.preRequisites;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -42,14 +36,13 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.annotations.BeforeMethod;
+import java.io.IOException;
+
+import static org.testng.AssertJUnit.*;
+
public class ComplexResourceBaseTest extends ComponentBaseTest {
protected ServiceReqDetails serviceDetails;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/DownloadArtifactBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/DownloadArtifactBaseTest.java
index bde68528bf..a512206035 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/DownloadArtifactBaseTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/DownloadArtifactBaseTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.ci.tests.preRequisites;
-import java.io.IOException;
-
import org.apache.log4j.lf5.util.ResourceUtils;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -39,14 +37,12 @@ import org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest;
import org.openecomp.sdc.ci.tests.utils.ArtifactUtils;
import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
+import java.io.IOException;
+
public class DownloadArtifactBaseTest extends ComponentBaseTest {
protected ResourceReqDetails downloadResourceDetails;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/SimpleOneRsrcOneServiceTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/SimpleOneRsrcOneServiceTest.java
index add06a587c..319109a604 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/SimpleOneRsrcOneServiceTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/preRequisites/SimpleOneRsrcOneServiceTest.java
@@ -20,10 +20,6 @@
package org.openecomp.sdc.ci.tests.preRequisites;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-
import org.apache.log4j.lf5.util.ResourceUtils;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.model.User;
@@ -42,6 +38,10 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
import org.testng.annotations.BeforeMethod;
+import java.io.IOException;
+
+import static org.testng.AssertJUnit.assertTrue;
+
public abstract class SimpleOneRsrcOneServiceTest extends ComponentBaseTest {
protected ResourceReqDetails resourceDetails;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java
index a5155021fa..c1a4e39905 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java
@@ -20,6 +20,13 @@
package org.openecomp.sdc.ci.tests.run;
+import org.apache.log4j.PropertyConfigurator;
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.TestNG;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -34,13 +41,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-import org.apache.log4j.PropertyConfigurator;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.TestNG;
-
public class StartTest {
// private List<Class<? extends AttSdcTest>> testClasses = new
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest2backup.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest2backup.java
index c9b1e134ac..bb53610802 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest2backup.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest2backup.java
@@ -20,6 +20,17 @@
package org.openecomp.sdc.ci.tests.run;
+import org.apache.log4j.PropertyConfigurator;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+import org.openecomp.sdc.ci.tests.api.AttSdcTest;
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.utils.Utils;
+import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -36,17 +47,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-import org.apache.log4j.PropertyConfigurator;
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-import org.openecomp.sdc.ci.tests.api.AttSdcTest;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
public class StartTest2backup {
private List<Class<? extends AttSdcTest>> testClasses = new ArrayList<Class<? extends AttSdcTest>>();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/CrudE2E.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/CrudE2E.java
index b676b29bda..f3d48bfeff 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/CrudE2E.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/CrudE2E.java
@@ -20,42 +20,26 @@
package org.openecomp.sdc.ci.tests.sanity;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
+import fj.data.Either;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Rule;
import org.junit.rules.TestName;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.AssocType;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
-import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
public class CrudE2E extends ComponentBaseTest {
private static Logger log = LoggerFactory.getLogger(CrudE2E.class.getName());
@@ -196,10 +180,10 @@ public class CrudE2E extends ComponentBaseTest {
//////// certify VF1 - failed due to uncertified CP instance ////////
- RestResponse changeVfStateFailed = LifecycleRestUtils.changeComponentState(resourceDetailsVF_01, designer, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ /*RestResponse changeVfStateFailed = LifecycleRestUtils.changeComponentState(resourceDetailsVF_01, designer, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
Resource resResourceDetailsVF_01 = (Resource) resourceDetailsVF_01;
variablesAsList = Arrays.asList(resResourceDetailsVF_01.getResourceType().toString(), resourceDetailsCP_01.getName());
- ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name(), variablesAsList, changeVfStateFailed.getResponse());
+ ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name(), variablesAsList, changeVfStateFailed.getResponse());*/
//////// certify resources CP1 ////////
resourceDetailsCP_01 = AtomicOperationUtils.changeComponentState(resourceDetailsCP_01, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
@@ -226,10 +210,10 @@ public class CrudE2E extends ComponentBaseTest {
//////// certify service1 - failed due to uncertified instances ////////
designer = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- RestResponse changeServicetStateFailed = LifecycleRestUtils.changeComponentState(defaultService1, designer, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
+ /*RestResponse changeServicetStateFailed = LifecycleRestUtils.changeComponentState(defaultService1, designer, LifeCycleStatesEnum.CERTIFICATIONREQUEST);
variablesAsList = Arrays.asList(defaultService1.getComponentType().toString().toLowerCase(), resourceDetailsVF_01.getName());
ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name(), variablesAsList, changeServicetStateFailed.getResponse());
-
+*/
////// change VF1 state to CERTIFIED
resourceDetailsVF_01 = AtomicOperationUtils.changeComponentState(resourceDetailsVF_01, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java
index 33cf6cbb98..e6e96ccba8 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/MultipleResourceUpdate.java
@@ -20,11 +20,6 @@
package org.openecomp.sdc.ci.tests.sanity;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -32,11 +27,7 @@ import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.AssocType;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
@@ -44,6 +35,11 @@ import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.AssertJUnit.assertTrue;
+
public class MultipleResourceUpdate extends ComponentBaseTest {
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
index a64c3771c3..99bfad6bbd 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
@@ -21,9 +21,8 @@
package org.openecomp.sdc.ci.tests.sanity;
-
-
-
+import com.aventstack.extentreports.Status;
+import fj.data.Either;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -42,16 +41,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Optional;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-import com.aventstack.extentreports.Status;
-import com.clearspring.analytics.util.Pair;
-
-import fj.data.Either;
+import org.testng.annotations.*;
@@ -108,9 +98,8 @@ public class Onboard extends ComponentBaseTest {
ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile));
User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
- Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filePath, vnfFile, user);
- VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right;
- vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left);
+ VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filePath, vnfFile, user);
+// vendorSoftwareProductObject.setName(vendorSoftwareProductObject.getName());
// create VF base on VNF imported from previous step - have, resourceReqDetails object include part of resource metadata
// ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaAnnotationsTypesDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaAnnotationsTypesDefinition.java
new file mode 100644
index 0000000000..da84077f7e
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaAnnotationsTypesDefinition.java
@@ -0,0 +1,29 @@
+package org.openecomp.sdc.ci.tests.tosca.datatypes;
+
+import org.openecomp.sdc.ci.tests.datatypes.enums.ToscaKeysEnum;
+import org.yaml.snakeyaml.TypeDescription;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ToscaAnnotationsTypesDefinition extends ToscaTypesDefinition {
+
+ public static final String SOURCE_ANNOTATION = "org.openecomp.annotations.Source";
+
+ private Map<String, ToscaTypeDefinition> annotation_types = new HashMap<>();
+
+ public Map<String, ToscaTypeDefinition> getAnnotation_types() {
+ return annotation_types;
+ }
+
+ public void setAnnotation_types(Map<String, ToscaTypeDefinition> annotation_types) {
+ this.annotation_types = annotation_types;
+ }
+
+ public static TypeDescription getTypeDescription(){
+ TypeDescription typeDescription = new TypeDescription(ToscaAnnotationsTypesDefinition.class);
+ typeDescription.putListPropertyType(ToscaKeysEnum.IMPORTS.getToscaKey(), String.class);
+ typeDescription.putMapPropertyType(ToscaKeysEnum.ANNOTATION_TYPES.getToscaKey(), String.class, ToscaTypeDefinition.class);
+ return typeDescription;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java
index 3a63237e99..5bbb71b853 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaDefinition.java
@@ -20,13 +20,13 @@
package org.openecomp.sdc.ci.tests.tosca.datatypes;
+import org.yaml.snakeyaml.TypeDescription;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.yaml.snakeyaml.TypeDescription;
-
public class ToscaDefinition {
String tosca_definitions_version;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java
index 53409024df..e6c2a4f45e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupPropertyDefinition.java
@@ -109,4 +109,42 @@ public class ToscaGroupPropertyDefinition {
TypeDescription typeDescription = new TypeDescription(ToscaGroupPropertyDefinition.class);
return typeDescription;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ToscaGroupPropertyDefinition that = (ToscaGroupPropertyDefinition) o;
+
+ if (min_vf_module_instances != null ? !min_vf_module_instances.equals(that.min_vf_module_instances) : that.min_vf_module_instances != null)
+ return false;
+ if (max_vf_module_instances != null ? !max_vf_module_instances.equals(that.max_vf_module_instances) : that.max_vf_module_instances != null)
+ return false;
+ if (vf_module_label != null ? !vf_module_label.equals(that.vf_module_label) : that.vf_module_label != null)
+ return false;
+ if (vfc_list != null ? !vfc_list.equals(that.vfc_list) : that.vfc_list != null) return false;
+ if (vf_module_type != null ? !vf_module_type.equals(that.vf_module_type) : that.vf_module_type != null)
+ return false;
+ if (vf_module_description != null ? !vf_module_description.equals(that.vf_module_description) : that.vf_module_description != null)
+ return false;
+ if (initial_count != null ? !initial_count.equals(that.initial_count) : that.initial_count != null)
+ return false;
+ if (volume_group != null ? !volume_group.equals(that.volume_group) : that.volume_group != null) return false;
+ return availability_zone_count != null ? availability_zone_count.equals(that.availability_zone_count) : that.availability_zone_count == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = min_vf_module_instances != null ? min_vf_module_instances.hashCode() : 0;
+ result = 31 * result + (max_vf_module_instances != null ? max_vf_module_instances.hashCode() : 0);
+ result = 31 * result + (vf_module_label != null ? vf_module_label.hashCode() : 0);
+ result = 31 * result + (vfc_list != null ? vfc_list.hashCode() : 0);
+ result = 31 * result + (vf_module_type != null ? vf_module_type.hashCode() : 0);
+ result = 31 * result + (vf_module_description != null ? vf_module_description.hashCode() : 0);
+ result = 31 * result + (initial_count != null ? initial_count.hashCode() : 0);
+ result = 31 * result + (volume_group != null ? volume_group.hashCode() : 0);
+ result = 31 * result + (availability_zone_count != null ? availability_zone_count.hashCode() : 0);
+ return result;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java
index fd30691963..a536578e09 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaGroupsTopologyTemplateDefinition.java
@@ -20,37 +20,45 @@
package org.openecomp.sdc.ci.tests.tosca.datatypes;
+import org.yaml.snakeyaml.TypeDescription;
+
+import java.io.Serializable;
import java.util.List;
import java.util.Map;
-import org.yaml.snakeyaml.TypeDescription;
-
// spec page 102
-public class ToscaGroupsTopologyTemplateDefinition {
+public class ToscaGroupsTopologyTemplateDefinition extends ToscaServiceGroupsMetadataDefinition implements Serializable {
- private String type; // required
- private String description;
+ public static final long serialVersionUID = -6373752349967949120L;
+ public String type; // required
+ public String description;
// private Map<String, String> properties;
- private ToscaGroupPropertyDefinition properties;
- private Map<String, String> targets; // required
- private Map<String, Object> interfaces;
- private List<String> members;
+ public ToscaGroupPropertyDefinition properties;
+ public Map<String, String> targets; // required
+ public Map<String, Object> interfaces;
+ public List<String> members;
// private Map<String, String> metadata;
- private ToscaServiceGroupsMetadataDefinition metadata;
+// private ToscaServiceGroupsMetadataDefinition metadata;
public ToscaGroupsTopologyTemplateDefinition() {
super();
}
- public ToscaServiceGroupsMetadataDefinition getMetadata() {
- return metadata;
- }
-
+// public ToscaServiceGroupsMetadataDefinition getMetadata() {
+// return metadata;
+// }
+//
public void setMetadata(ToscaServiceGroupsMetadataDefinition metadata) {
- this.metadata = metadata;
+ this.vfModuleModelCustomizationUUID = metadata.vfModuleModelCustomizationUUID;
+ this.vfModuleModelInvariantUUID = metadata.vfModuleModelInvariantUUID;
+ this.vfModuleModelName = metadata.vfModuleModelName;
+ this.vfModuleModelUUID = metadata.vfModuleModelUUID;
+ this.vfModuleModelVersion = metadata.vfModuleModelVersion;
}
+
+
public String getType() {
return type;
}
@@ -115,10 +123,42 @@ public class ToscaGroupsTopologyTemplateDefinition {
// this.metadata = metadata;
// }
+// @Override
+// public String toString() {
+// return "ToscaGroupsTopologyTemplateDefinition [type=" + type + ", description=" + description + ", properties=" + properties + ", targets=" + targets + ", interfaces=" + interfaces + ", members=" + members + ", metadata=" + metadata
+// + "]";
+// }
+
+
@Override
public String toString() {
- return "ToscaGroupsTopologyTemplateDefinition [type=" + type + ", description=" + description + ", properties=" + properties + ", targets=" + targets + ", interfaces=" + interfaces + ", members=" + members + ", metadata=" + metadata
- + "]";
+ return "ToscaGroupsTopologyTemplateDefinition{" +
+ "type='" + type + '\'' +
+ ", description='" + description + '\'' +
+ ", properties=" + properties +
+ ", targets=" + targets +
+ ", interfaces=" + interfaces +
+ ", members=" + members +
+ '}';
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ToscaGroupsTopologyTemplateDefinition)) return false;
+ if (!super.equals(o)) return false;
+
+ ToscaGroupsTopologyTemplateDefinition that = (ToscaGroupsTopologyTemplateDefinition) o;
+
+// if (type != null ? !type.equals(that.type) : that.type != null) return false;
+// if (description != null ? !description.equals(that.description) : that.description != null) return false;
+// if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false;
+// if (targets != null ? !targets.equals(that.targets) : that.targets != null) return false;
+// if (interfaces != null ? !interfaces.equals(that.interfaces) : that.interfaces != null) return false;
+// return members != null ? members.equals(that.members) : that.members == null;
+
+ return (properties != null ? properties.equals(that.properties) : false);
}
//gets Type description for Yaml snake
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsAnnotation.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsAnnotation.java
new file mode 100644
index 0000000000..4d31bdf9ee
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsAnnotation.java
@@ -0,0 +1,51 @@
+package org.openecomp.sdc.ci.tests.tosca.datatypes;
+
+import org.yaml.snakeyaml.TypeDescription;
+
+import java.util.Map;
+import java.util.Objects;
+
+public class ToscaInputsAnnotation {
+
+ String name;
+ String type;
+ private Map<String, Object> properties;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+
+
+ //gets Type description for Yaml snake
+ public static TypeDescription getTypeDescription(){
+ return new TypeDescription(ToscaInputsAnnotation.class);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ToscaInputsAnnotation that = (ToscaInputsAnnotation) o;
+ return Objects.equals(type, that.type);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type);
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java
index c3b11f2666..3f0bac06d4 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaInputsTopologyTemplateDefinition.java
@@ -20,14 +20,13 @@
package org.openecomp.sdc.ci.tests.tosca.datatypes;
+import com.google.gson.annotations.SerializedName;
+import org.yaml.snakeyaml.TypeDescription;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import org.yaml.snakeyaml.TypeDescription;
-
-import com.google.gson.annotations.SerializedName;
-
public class ToscaInputsTopologyTemplateDefinition {
public String name;
@@ -40,11 +39,12 @@ public class ToscaInputsTopologyTemplateDefinition {
public Object Default;
public String status;
- public List<Object> constraints = new ArrayList<Object>();
+ public List<Object> constraints = new ArrayList<>();
public Map<String, Object> entry_schema;
public Object value;
+ public Map<String, ToscaInputsAnnotation> annotations;
- public ToscaInputsTopologyTemplateDefinition(String name, String type, String description, Boolean required, Object default1, String status, List<Object> constraints, Map<String, Object> entry_schema, Object value, Boolean immutable, Boolean hidden) {
+ public ToscaInputsTopologyTemplateDefinition(String name, String type, String description, Boolean required, Object default1, String status, List<Object> constraints, Map<String, Object> entry_schema, Object value, Boolean immutable, Boolean hidden, Map<String, ToscaInputsAnnotation> annotations) {
super();
this.name = name;
this.type = type;
@@ -57,6 +57,7 @@ public class ToscaInputsTopologyTemplateDefinition {
this.value = value;
this.immutable = immutable;
this.hidden = hidden;
+ this.annotations = annotations;
}
public ToscaInputsTopologyTemplateDefinition() {
@@ -164,11 +165,20 @@ public class ToscaInputsTopologyTemplateDefinition {
this.value = value;
}
+ public Map<String, ToscaInputsAnnotation> getAnnotations() {
+ return annotations;
+ }
+
+ public void setAnnotations(Map<String, ToscaInputsAnnotation> annotations) {
+ this.annotations = annotations;
+ }
+
//gets Type description for Yaml snake
public static TypeDescription getTypeDescription(){
TypeDescription typeDescription = new TypeDescription(ToscaInputsTopologyTemplateDefinition.class);
typeDescription.putListPropertyType("constraints", Object.class);
typeDescription.putMapPropertyType("entry_schema", String.class, Object.class);
+ typeDescription.putMapPropertyType("annotations", String.class, ToscaInputsAnnotation.class);
return typeDescription;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaNodeTemplatesTopologyTemplateDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaNodeTemplatesTopologyTemplateDefinition.java
index 168f7c6c56..442656ebf6 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaNodeTemplatesTopologyTemplateDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaNodeTemplatesTopologyTemplateDefinition.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.ci.tests.tosca.datatypes;
+import org.yaml.snakeyaml.TypeDescription;
+
import java.util.List;
import java.util.Map;
-import org.yaml.snakeyaml.TypeDescription;
-
public class ToscaNodeTemplatesTopologyTemplateDefinition {
private String name;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java
index 9f1d544738..1e36099289 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaParameterConstants.java
@@ -2,10 +2,11 @@ package org.openecomp.sdc.ci.tests.tosca.datatypes;
public interface ToscaParameterConstants {
- public static final String ENTRY_DEFINITION = "Entry-Definitions";
- public static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
- public static final String HEAT_META_PATH = "Artifacts/HEAT.meta";
- public static final String IMPORT_STRUCTURE = "importStructure";
- public static final String NODE_TYPES = "node_types";
- public static final String PROPERTIES = "properties";
+ String TOSCA_DEFINITION_PATH = "Definitions";
+ String ENTRY_DEFINITION = "Entry-Definitions";
+ String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
+ String HEAT_META_PATH = "Artifacts/HEAT.meta";
+ String IMPORT_STRUCTURE = "importStructure";
+ String NODE_TYPES = "node_types";
+ String PROPERTIES = "properties";
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java
index da8c99a59f..5b50b0e854 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaServiceGroupsMetadataDefinition.java
@@ -20,7 +20,11 @@
package org.openecomp.sdc.ci.tests.tosca.datatypes;
-public class ToscaServiceGroupsMetadataDefinition {
+import java.io.Serializable;
+
+public class ToscaServiceGroupsMetadataDefinition implements Serializable {
+
+ public static final long serialVersionUID = -6373756459974949120L;
public String vfModuleModelName;
public String vfModuleModelInvariantUUID;
@@ -77,7 +81,26 @@ public class ToscaServiceGroupsMetadataDefinition {
return "ToscaGroupsMetadataDefinition [vfModuleModelName=" + vfModuleModelName + ", vfModuleModelInvariantUUID=" + vfModuleModelInvariantUUID + ", vfModuleModelCustomizationUUID=" + vfModuleModelCustomizationUUID
+ ", vfModuleModelUUID=" + vfModuleModelUUID + ", vfModuleModelVersion=" + vfModuleModelVersion + "]";
}
-
-
-
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ToscaServiceGroupsMetadataDefinition)) return false;
+
+ ToscaServiceGroupsMetadataDefinition that = (ToscaServiceGroupsMetadataDefinition) o;
+
+ if (vfModuleModelName != null ? !vfModuleModelName.equals(that.vfModuleModelName) : that.vfModuleModelName != null)
+ return false;
+ if (!vfModuleModelInvariantUUID.equals(that.vfModuleModelInvariantUUID)) return false;
+ if (vfModuleModelCustomizationUUID != null ? !vfModuleModelCustomizationUUID.equals(that.vfModuleModelCustomizationUUID) : that.vfModuleModelCustomizationUUID != null)
+ return false;
+ if (vfModuleModelUUID != null ? !vfModuleModelUUID.equals(that.vfModuleModelUUID) : that.vfModuleModelUUID != null)
+ return false;
+ return vfModuleModelVersion != null ? vfModuleModelVersion.equals(that.vfModuleModelVersion) : that.vfModuleModelVersion == null;
+ }
+
+ @Override
+ public int hashCode() {
+ return vfModuleModelInvariantUUID.hashCode();
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaSubstitutionMappingsDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaSubstitutionMappingsDefinition.java
index 9b474e9ea6..d3bb2a03d0 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaSubstitutionMappingsDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaSubstitutionMappingsDefinition.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.ci.tests.tosca.datatypes;
+import org.yaml.snakeyaml.TypeDescription;
+
import java.util.HashMap;
import java.util.Map;
-import org.yaml.snakeyaml.TypeDescription;
-
public class ToscaSubstitutionMappingsDefinition {
private String node_type;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java
index 03f83b4b15..9b2996044a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTopologyTemplateDefinition.java
@@ -20,17 +20,12 @@
package org.openecomp.sdc.ci.tests.tosca.datatypes;
+import org.yaml.snakeyaml.TypeDescription;
+
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.yaml.snakeyaml.TypeDescription;
-
-import com.clearspring.analytics.util.Pair;
-
-import io.netty.util.collection.IntObjectMap.Entry;
-
// spec page 104
public class ToscaTopologyTemplateDefinition {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTypeDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTypeDefinition.java
new file mode 100644
index 0000000000..e208b77974
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTypeDefinition.java
@@ -0,0 +1,26 @@
+package org.openecomp.sdc.ci.tests.tosca.datatypes;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ToscaTypeDefinition {
+
+ private String description;
+ private Map<String, Object> properties = new HashMap<>();
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTypesDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTypesDefinition.java
new file mode 100644
index 0000000000..6fc8044d87
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/ToscaTypesDefinition.java
@@ -0,0 +1,26 @@
+package org.openecomp.sdc.ci.tests.tosca.datatypes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ToscaTypesDefinition {
+
+ private String tosca_definitions_version;
+ private List<String> imports = new ArrayList<>();
+
+ public String getTosca_definitions_version() {
+ return tosca_definitions_version;
+ }
+
+ public void setTosca_definitions_version(String tosca_definitions_version) {
+ this.tosca_definitions_version = tosca_definitions_version;
+ }
+
+ public List<String> getImports() {
+ return imports;
+ }
+
+ public void setImports(List<String> imports) {
+ this.imports = imports;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/VfModuleDefinition.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/VfModuleDefinition.java
new file mode 100644
index 0000000000..2f9c1d47c2
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/datatypes/VfModuleDefinition.java
@@ -0,0 +1,37 @@
+package org.openecomp.sdc.ci.tests.tosca.datatypes;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class VfModuleDefinition extends ToscaGroupsTopologyTemplateDefinition implements Serializable {
+
+ private List<String> artifacts;
+
+ public static final long serialVersionUID = -6373756459967949586L;
+
+ public List<String> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(List<String> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof VfModuleDefinition)) return false;
+ if (!super.equals(o)) return false;
+
+ VfModuleDefinition that = (VfModuleDefinition) o;
+
+ return artifacts != null ? artifacts.containsAll(that.artifacts) : that.artifacts == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ result = 31 * result + (artifacts != null ? artifacts.hashCode() : 0);
+ return result;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/model/ToscaMetadataFieldsPresentationEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/model/ToscaMetadataFieldsPresentationEnum.java
index cdea2ff69c..247a41dd8f 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/model/ToscaMetadataFieldsPresentationEnum.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/tosca/model/ToscaMetadataFieldsPresentationEnum.java
@@ -23,6 +23,7 @@ public class ToscaMetadataFieldsPresentationEnum {
SERVICE_ECOMP_NAMING ("serviceEcompNaming", ComponentTypeEnum.SERVICE.value),
ECOMP_GENERATED_NAMING ("ecompGeneratedNaming", ComponentTypeEnum.SERVICE.value),
NAMING_POLICY ("namingPolicy", ComponentTypeEnum.SERVICE.value),
+ INSTANTIATION_TYPE ("instantiationType", ComponentTypeEnum.SERVICE.value),
// node_template
CUSTOMIZATION_UUID ("customizationUUID", ComponentTypeEnum.NODE_TEMPLATE.value),
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java
index 157377f47f..fc717ca79d 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java
@@ -20,30 +20,51 @@
package org.openecomp.sdc.ci.tests.utils;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
+import org.apache.commons.codec.binary.Base64;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
+import org.junit.Assert;
+import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition;
import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
import org.openecomp.sdc.ci.tests.datatypes.PropertyHeatMetaDefinition;
import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition;
import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaParameterConstants;
+import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import static org.testng.AssertJUnit.assertTrue;
+
public class CsarParserUtils {
+ public static final String CSAR_ARTIFACT = "assettoscacsar";
private static Logger log = LoggerFactory.getLogger(CsarValidationUtils.class.getName());
+ public static byte[] downloadComponentCsar(Component csarOwner, User user) throws Exception {
+ String artifactUniqeId = csarOwner.getToscaArtifacts().get(CSAR_ARTIFACT).getUniqueId();
+ RestResponse csarResponse = ArtifactRestUtils.downloadResourceArtifactInternalApi(csarOwner.getUniqueId(), user, artifactUniqeId);
+ Assert.assertNotNull(csarResponse);
+ BaseRestUtils.checkSuccess(csarResponse);
+ ArtifactUiDownloadData artifactUiDownloadData = ResponseParser.parseToObject(csarResponse.getResponse(),
+ ArtifactUiDownloadData.class);
+ byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
+ return Base64.decodeBase64(fromUiDownload);
+ }
+
public static List<TypeHeatMetaDefinition> getListTypeHeatMetaDefinition(File csarFileLocation) throws Exception {
String artifactHeatMetaLocation = ToscaParameterConstants.HEAT_META_PATH;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java
index 8270515643..0b62f4a2d0 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java
@@ -1,11 +1,5 @@
package org.openecomp.sdc.ci.tests.utils;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
@@ -15,6 +9,12 @@ import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.toscaparser.api.parameters.Input;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
public class CsarToscaTester {
public static void processCsar(SdcToscaParserFactory factory, File file) throws SdcToscaParserException {
@@ -78,7 +78,8 @@ public class CsarToscaTester {
private static void generateReport(String time, String name, String currentCsarDir, List<String> criticalsReport, String type)
throws IOException {
FileWriter fw;
- fw = new FileWriter(new File(currentCsarDir + "/" + criticalsReport.size() + "-"+type+"-" + name +"-"+time + ".txt"));
+ try (FileWriter fileWriter = fw = new FileWriter(new File(currentCsarDir + "/" + criticalsReport.size() + "-" + type + "-" + name + "-" + time + ".txt"))) {
+ }
for (String exception : criticalsReport) {
fw.write(exception);
fw.write("\r\n");
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java
index 16266fb03f..dea9084149 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DbUtils.java
@@ -20,14 +20,12 @@
package org.openecomp.sdc.ci.tests.utils;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
+import com.google.gson.*;
+import com.thinkaurelius.titan.core.TitanEdge;
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanVertex;
+import fj.data.Either;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -39,17 +37,9 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.users.UserAuditJavaObject;
import org.openecomp.sdc.ci.tests.utils.cassandra.CassandraUtils;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.thinkaurelius.titan.core.TitanEdge;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
-
-import fj.data.Either;
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
public class DbUtils {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java
index 7d90eb0b6d..3b11388505 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.ci.tests.utils;
+import org.apache.commons.codec.binary.Base64;
+
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
-import org.apache.commons.codec.binary.Base64;
-
public class Decoder {
public static String encode(byte[] byteArrayToEncode) {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java
index 835ef6ebb3..479fdcb220 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/DistributionUtils.java
@@ -20,15 +20,8 @@
package org.openecomp.sdc.ci.tests.utils;
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import com.clearspring.analytics.util.Pair;
+import com.google.gson.Gson;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
@@ -40,19 +33,19 @@ import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.DistributionMonitorObject;
import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
-import org.openecomp.sdc.ci.tests.datatypes.enums.DistributionNotificationStatusEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
-//import org.openecomp.sdc.be.components.distribution.engine.DistributionStatusNotificationEnum;
-import com.clearspring.analytics.util.Pair;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.*;
+import java.util.Map.Entry;
-import fj.data.Either;
+//import org.openecomp.sdc.be.components.distribution.engine.DistributionStatusNotificationEnum;
public class DistributionUtils extends BaseRestUtils{
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ReqCap.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ReqCap.java
index 9ac02a0092..55cc748e99 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ReqCap.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ReqCap.java
@@ -20,47 +20,26 @@
package org.openecomp.sdc.ci.tests.utils;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.RelationshipInfo;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.testng.Assert;
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import static org.testng.AssertJUnit.*;
+
public class ReqCap {
public static Map<String, List<CapabilityDefinition>> expectedContainerCapabilities;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
index f345aad60c..be235d03ae 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaParserUtils.java
@@ -20,26 +20,8 @@
package org.openecomp.sdc.ci.tests.utils;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Map;
-
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupsTopologyTemplateDefinition;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaImportsDefinition;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaInputsTopologyTemplateDefinition;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaMetadataDefinition;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaNodeTemplatesTopologyTemplateDefinition;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaParameterConstants;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaSubstitutionMappingsDefinition;
-import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinition;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.*;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils;
@@ -51,6 +33,16 @@ import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.introspector.PropertyUtils;
+import java.io.File;
+import java.io.FileInputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+
public class ToscaParserUtils {
private static Logger log = LoggerFactory.getLogger(ToscaParserUtils.class.getName());
@@ -112,7 +104,8 @@ public class ToscaParserUtils {
// File path = new File("C:/Data/D2.0/TOSCA_Ex/Definitions/tosca_definition_version.yaml");
FileInputStream fis = null;
try {
- fis = new FileInputStream(path);
+ try (FileInputStream fileInputStream = fis = new FileInputStream(path)) {
+ }
} catch (Exception e) {
System.out.println("Exception: " + e);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaTypesDefinitionUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaTypesDefinitionUtils.java
new file mode 100644
index 0000000000..4af84a7d4e
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/ToscaTypesDefinitionUtils.java
@@ -0,0 +1,54 @@
+package org.openecomp.sdc.ci.tests.utils;
+
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaAnnotationsTypesDefinition;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaParameterConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+import static org.junit.Assert.assertNotNull;
+import static org.openecomp.sdc.ci.tests.utils.CsarParserUtils.downloadComponentCsar;
+import static org.openecomp.sdc.ci.tests.utils.ToscaParserUtils.getDataFromZipFileByBytes;
+import static org.testng.AssertJUnit.fail;
+
+public class ToscaTypesDefinitionUtils {
+
+ private ToscaTypesDefinitionUtils() {
+ }
+
+ private static final String ANNOTATIONS_TYPE_PATH = ToscaParameterConstants.TOSCA_DEFINITION_PATH + "/annotations.yml";
+ private static Logger log = LoggerFactory.getLogger(ToscaTypesDefinitionUtils.class);
+
+ public static ToscaAnnotationsTypesDefinition getToscaAnnotationsFromCsar(Component csarOwner, User user) throws Exception {
+ byte[] decodeBase64 = downloadComponentCsar(csarOwner, user);
+ String dataFromZipFileByBytes = getDataFromZipFileByBytes(ANNOTATIONS_TYPE_PATH, decodeBase64);
+ assertNotNull(dataFromZipFileByBytes);
+ return parseToscaAnnotationsYml(dataFromZipFileByBytes);
+ }
+
+ private static ToscaAnnotationsTypesDefinition parseToscaAnnotationsYml(String payload){
+ Constructor constructor = initToscaAnnotationDefObject();
+ return (ToscaAnnotationsTypesDefinition) parseToscaYamlPayload(payload, constructor);
+ }
+
+ private static Object parseToscaYamlPayload(String payload, Constructor constructor) {
+ Yaml yaml = new Yaml(constructor);
+ try {
+ return yaml.load(payload);
+ } catch (Exception e) {
+ log.debug("Failed to parse tosca yaml file", e);
+ e.printStackTrace();
+ fail("Failed to parse tosca yaml file");
+ }
+ return null;
+ }
+
+ private static Constructor initToscaAnnotationDefObject() {
+ Constructor toscaStructure = new Constructor(ToscaAnnotationsTypesDefinition.class);
+ toscaStructure.addTypeDescription(ToscaAnnotationsTypesDefinition.getTypeDescription());
+ return toscaStructure;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java
index 05dcc7e663..ea6ef62618 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java
@@ -20,9 +20,20 @@
package org.openecomp.sdc.ci.tests.utils;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
+import org.openecomp.sdc.ci.tests.tosca.model.ToscaMetadataFieldsPresentationEnum;
+import org.openecomp.sdc.common.api.ToscaNodeTypeInfo;
+import org.openecomp.sdc.common.api.YamlConstants;
+import org.yaml.snakeyaml.Yaml;
import java.io.File;
import java.io.FileInputStream;
@@ -31,23 +42,13 @@ import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.log4j.Logger;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.common.api.ToscaNodeTypeInfo;
-import org.openecomp.sdc.common.api.YamlConstants;
-import org.yaml.snakeyaml.Yaml;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import static org.testng.AssertJUnit.*;
public final class Utils {
@@ -701,7 +702,49 @@ public final class Utils {
long startTime = System.nanoTime();
func.run();
long estimateTime = System.nanoTime();
- long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime);
+ Long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime);
return duration;
}
+
+ public static Long getAndValidateActionDuration (Runnable action, int regularTestRunTime){
+ Long actualTestRunTime = null;
+ try {
+ actualTestRunTime = Utils.getActionDuration(() -> {
+ try {
+ action.run();
+ } catch (Throwable throwable) {
+ throwable.printStackTrace();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ double factor = 1.5;
+
+ assertTrue("Expected test run time should be less than " + regularTestRunTime*factor + ", " +
+ "actual time is " + actualTestRunTime , regularTestRunTime*factor>actualTestRunTime);
+// SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + actualTestRunTime + " seconds");
+ return actualTestRunTime;
+ }
+
+
+ public static Map<String, String> generateServiceMetadataToExpectedObject(ServiceReqDetails serviceReqDetails, Component component) {
+
+ Map<String, String> metadata = new HashMap<>();
+
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, serviceReqDetails.getCategories().get(0).getName());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, serviceReqDetails.getDescription());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, component.getInvariantUUID());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, "Service");
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, component.getUUID());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, component.getName());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INSTANTIATION_TYPE.value, serviceReqDetails.getInstantiationType());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_TYPE.value, serviceReqDetails.getServiceType());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_ROLE.value, serviceReqDetails.getServiceRole());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAMING_POLICY.value, serviceReqDetails.getNamingPolicy());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.ECOMP_GENERATED_NAMING.value, serviceReqDetails.getEcompGeneratedNaming().toString());
+ metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_ECOMP_NAMING.value, serviceReqDetails.getEcompGeneratedNaming().toString());//equals to ECOMP_GENERATED_NAMING
+
+ return metadata;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java
index aa68392adc..20a137d8fa 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils.java
@@ -20,32 +20,22 @@
package org.openecomp.sdc.ci.tests.utils.cassandra;
-import java.io.FileNotFoundException;
+import com.datastax.driver.core.*;
import com.datastax.driver.core.policies.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+import com.datastax.driver.core.querybuilder.QueryBuilder;
+import com.datastax.driver.core.querybuilder.Select;
+import com.datastax.driver.core.querybuilder.Select.Where;
import org.javatuples.Pair;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.KeyspaceMetadata;
-import com.datastax.driver.core.Metadata;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
-import com.datastax.driver.core.TableMetadata;
-import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
-import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
-import com.datastax.driver.core.policies.DefaultRetryPolicy;
-import com.datastax.driver.core.policies.LoadBalancingPolicy;
-import com.datastax.driver.core.policies.TokenAwarePolicy;
-import com.datastax.driver.core.querybuilder.QueryBuilder;
-import com.datastax.driver.core.querybuilder.Select;
-import com.datastax.driver.core.querybuilder.Select.Where;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
public final class CassandraUtils {
private static Logger logger = LoggerFactory.getLogger(CassandraUtils.class.getName());
@@ -173,7 +163,7 @@ public final class CassandraUtils {
}
}
- public static List<Row> fetchFromTable(String keyspace, String tableName, List<Pair<AuditingFieldsKeysEnum, String>> fields) throws FileNotFoundException {
+ public static List<Row> fetchFromTable(String keyspace, String tableName, List<Pair<AuditingFieldsKey, String>> fields) throws FileNotFoundException {
List<Pair<String, String>> fieldsConverted = new ArrayList<>();
@@ -184,7 +174,7 @@ public final class CassandraUtils {
fields.forEach(pair -> {
Pair<String, String> newPair;
- if (pair.getValue0() == AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL) {
+ if (pair.getValue0() == AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL) {
newPair = new Pair<String, String>("RESOURE_URL", pair.getValue1());
} else {
@@ -208,7 +198,7 @@ public final class CassandraUtils {
if (session != null) {
Select select = QueryBuilder.select().all().from(keyspace, tableName);
if (fields != null) {
- // Set<Entry<AuditingFieldsKeysEnum, String>> entrySet =
+ // Set<Entry<AuditingFieldsKey, String>> entrySet =
// fields.entrySet();
// fields.
boolean multiple = (fields.size() > 1) ? true : false;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils2.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils2.java
index 8381bbdd21..ebb3b33a87 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils2.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/cassandra/CassandraUtils2.java
@@ -20,26 +20,20 @@
package org.openecomp.sdc.ci.tests.utils.cassandra;
-import java.io.FileNotFoundException;
-import java.util.Collection;
-import java.util.List;
-
+import com.datastax.driver.core.*;
+import com.datastax.driver.core.querybuilder.QueryBuilder;
+import com.datastax.driver.core.querybuilder.Select;
+import com.datastax.driver.core.querybuilder.Select.Where;
import org.javatuples.Pair;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.KeyspaceMetadata;
-import com.datastax.driver.core.Metadata;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
-import com.datastax.driver.core.TableMetadata;
-import com.datastax.driver.core.querybuilder.QueryBuilder;
-import com.datastax.driver.core.querybuilder.Select;
-import com.datastax.driver.core.querybuilder.Select.Where;
+import java.io.FileNotFoundException;
+import java.util.Collection;
+import java.util.List;
public final class CassandraUtils2 {
private static Logger logger = LoggerFactory.getLogger(CassandraUtils2.class.getName());
@@ -110,10 +104,10 @@ public final class CassandraUtils2 {
}
public static List<Row> fetchFromTable(String keyspace, String tableName,
- List<Pair<AuditingFieldsKeysEnum, String>> fields) throws FileNotFoundException {
+ List<Pair<AuditingFieldsKey, String>> fields) throws FileNotFoundException {
- // List<Pair<AuditingFieldsKeysEnum, String>>
- // Map<AuditingFieldsKeysEnum, String>
+ // List<Pair<AuditingFieldsKey, String>>
+ // Map<AuditingFieldsKey, String>
Cluster cluster = null;
Session session;
@@ -125,14 +119,14 @@ public final class CassandraUtils2 {
if (session != null) {
Select select = QueryBuilder.select().all().from(keyspace, tableName);
if (fields != null) {
- // Set<Entry<AuditingFieldsKeysEnum, String>> entrySet =
+ // Set<Entry<AuditingFieldsKey, String>> entrySet =
// fields.entrySet();
// fields.
boolean multiple = (fields.size() > 1) ? true : false;
Where where = null;
int size = 0;
- for (Pair<AuditingFieldsKeysEnum, String> pair : fields) {
+ for (Pair<AuditingFieldsKey, String> pair : fields) {
++size;
if (size == 1) {
where = select.where(QueryBuilder.eq(pair.getValue0().getDisplayName(), pair.getValue1()));
@@ -161,9 +155,9 @@ public final class CassandraUtils2 {
}
//
// public static void main(String[] args) throws FileNotFoundException {
- // Map<AuditingFieldsKeysEnum, String> map = new HashMap<>();
- // map.put(AuditingFieldsKeysEnum.AUDIT_ACTION, "Access");
- // map.put(AuditingFieldsKeysEnum.AUDIT_STATUS, "200");
+ // Map<AuditingFieldsKey, String> map = new HashMap<>();
+ // map.put(AuditingFieldsKey.AUDIT_ACTION, "Access");
+ // map.put(AuditingFieldsKey.AUDIT_STATUS, "200");
// // CassandraUtils.truncateTable("sdcartifact", "resources");
//// CassandraUtils.truncateAllTables("sdcaudit");
// CassandraUtils.fetchFromTable("sdcaudit", "useraccessevent", map );
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java
index 36fdf06a36..8e5079db92 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,92 +20,58 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
-
+import com.aventstack.extentreports.Status;
+import com.google.gson.Gson;
+import fj.data.Either;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONException;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.ExtentTestActions;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.DistributionMonitorObject;
-import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.PropertyReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.*;
+import org.openecomp.sdc.ci.tests.datatypes.enums.*;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
import org.openecomp.sdc.ci.tests.utils.CsarToscaTester;
import org.openecomp.sdc.ci.tests.utils.DistributionUtils;
+import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ComponentInstanceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ConsumerRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.LifecycleRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.openecomp.sdc.common.util.GeneralUtility;
import org.testng.SkipException;
-import com.aventstack.extentreports.Status;
-import com.google.gson.Gson;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
public final class AtomicOperationUtils {
static final String basicAuthentication = "Basic Y2k6MTIzNDU2";
-
+
private AtomicOperationUtils() {
throw new UnsupportedOperationException();
}
@@ -113,7 +79,7 @@ public final class AtomicOperationUtils {
// *********** RESOURCE ****************
/**
* Import a vfc From tosca file
- *
+ *
* @param filePath
* @param fileName
* @return
@@ -190,7 +156,7 @@ public final class AtomicOperationUtils {
throw new AtomicOperationException(e);
}
}
-
+
public static Either<Resource, RestResponse> createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum resourceType, NormativeTypesEnum normativeTypes, ResourceCategoryEnum resourceCategory, UserRoleEnum userRole, Boolean validateState)
throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
@@ -247,7 +213,7 @@ public final class AtomicOperationUtils {
throw new AtomicOperationException(e);
}
}
-
+
// *********** SERVICE ****************
public static Either<Service, RestResponse> createDefaultService(UserRoleEnum userRole, Boolean validateState) throws Exception {
@@ -346,56 +312,61 @@ public final class AtomicOperationUtils {
Boolean isValidationFailed = false;
RestResponse lifeCycleStatesResponse = null;
- User defaultUser = ElementFactory.getDefaultUser(userRole);
+ User defaultUser;
- LifeCycleStatesEnum curentCompState = LifeCycleStatesEnum.findByCompState(component.getLifecycleState().toString());
+ LifeCycleStatesEnum currentCompState = LifeCycleStatesEnum.findByCompState(component.getLifecycleState().toString());
- if (curentCompState == targetState) {
+ if (currentCompState == targetState) {
component = getComponentObject(component, userRole);
return Pair.of(component, null);
}
-
+ String componentType = component.getComponentType().getValue();
ArrayList<String> lifeCycleStatesEnumList = new ArrayList<>();
- if (curentCompState.equals(LifeCycleStatesEnum.CHECKIN) && targetState.equals(LifeCycleStatesEnum.CHECKOUT)) {
+ if (currentCompState.equals(LifeCycleStatesEnum.CHECKIN) && targetState.equals(LifeCycleStatesEnum.CHECKOUT)) {
lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
+// TODO Andrey added component type condition
} else {
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFICATIONREQUEST.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.STARTCERTIFICATION.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFY.toString());
+ if (componentType.equals("Resource")) {
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFY.toString());
+ } else {
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFICATIONREQUEST.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.STARTCERTIFICATION.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFY.toString());
+ }
}
for (int i = 0; i < lifeCycleStatesEnumList.size(); i++) {
- if (lifeCycleStatesEnumList.get(i).equals(curentCompState.name())) {
+ if (lifeCycleStatesEnumList.get(i).equals(currentCompState.name())) {
int a;
a = (i == lifeCycleStatesEnumList.size() - 1) ? 0 : i + 1;
-
for (int n = a; n < lifeCycleStatesEnumList.size(); n++) {
- if (lifeCycleStatesEnumList.get(n).equals(LifeCycleStatesEnum.STARTCERTIFICATION.name()) || lifeCycleStatesEnumList.get(n).equals(LifeCycleStatesEnum.CERTIFY.name())) {
+ if ((lifeCycleStatesEnumList.get(n).equals(LifeCycleStatesEnum.STARTCERTIFICATION.name()) || lifeCycleStatesEnumList.get(n).equals(LifeCycleStatesEnum.CERTIFY.name())) && !componentType.equals("Resource")) {
defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
- } else
+ } else {
defaultUser = ElementFactory.getDefaultUser(userRole);
-
+ }
lifeCycleStatesResponse = LifecycleRestUtils.changeComponentState(component, defaultUser, LifeCycleStatesEnum.findByState(lifeCycleStatesEnumList.get(n)));
if (lifeCycleStatesResponse.getErrorCode() != LifecycleRestUtils.STATUS_CODE_SUCCESS)
isValidationFailed = true;
- if (lifeCycleStatesEnumList.get(n).equals(targetState.toString()) || isValidationFailed == true) {
+ if (lifeCycleStatesEnumList.get(n).equals(targetState.toString()) || isValidationFailed) {
break;
}
}
}
-
}
Component componentJavaObject = getComponentObject(component, userRole);
- if (validateState == true && isValidationFailed == true) {
- assertTrue("change state failed" + lifeCycleStatesResponse.getResponse(), false);
+ if (validateState && isValidationFailed) {
+ assertTrue("change state to [" + targetState.getState() + "] failed" + lifeCycleStatesResponse.getResponse(), false);
return Pair.of(componentJavaObject, lifeCycleStatesResponse);
}
- if (isValidationFailed == true) {
+ if (isValidationFailed) {
return Pair.of(componentJavaObject, lifeCycleStatesResponse);
}
@@ -425,7 +396,7 @@ public final class AtomicOperationUtils {
return distributionService;
}
-
+
public static void toscaValidation(Component component, String vnfFile) throws Exception {
ISdcCsarHelper fdntCsarHelper;
@@ -444,7 +415,7 @@ public final class AtomicOperationUtils {
User defaultUser = ElementFactory.getDefaultUser(userRole);
ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(null, artifactType, deploymentTrue);
- if (deploymentTrue == false)
+ if (!deploymentTrue)
artifactDetails.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL.getType());
RestResponse uploadArtifactResp = ArtifactRestUtils.uploadArtifact(artifactDetails, component, defaultUser);
@@ -462,7 +433,7 @@ public final class AtomicOperationUtils {
// *********** CONTAINERS *****************
/**
* Adds Component instance to Component
- *
+ *
* @param compInstParent
* @param compContainer
* @return
@@ -483,7 +454,7 @@ public final class AtomicOperationUtils {
throw new SkipException("Open bug DE262001");
}
else{
- assertTrue("error - " + createComponentInstance.getErrorCode() + "instead - " + ServiceRestUtils.STATUS_CODE_CREATED, createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
+ assertTrue("error - " + createComponentInstance.getErrorCode() + "instead - " + ServiceRestUtils.STATUS_CODE_CREATED, createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
}
}
@@ -528,86 +499,79 @@ public final class AtomicOperationUtils {
public static Resource getResourceObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
// User defaultUser = ElementFactory.getDefaultUser(userRole);
RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
- Resource container = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- return container;
+ return ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
}
-
+
public static Resource getResourceObject(String uniqueId) throws Exception {
RestResponse restResponse = ResourceRestUtils.getResource(uniqueId);
- Resource resource = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- return resource;
+ return ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
}
-
+
public static Resource getResourceObjectByNameAndVersion(UserRoleEnum sdncModifierDetails, String resourceName, String resourceVersion) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(sdncModifierDetails);
RestResponse resourceResponse = ResourceRestUtils.getResourceByNameAndVersion(defaultUser.getUserId(), resourceName, resourceVersion);
- Resource container = ResponseParser.convertResourceResponseToJavaObject(resourceResponse.getResponse());
- return container;
+ return ResponseParser.convertResourceResponseToJavaObject(resourceResponse.getResponse());
}
public static Service getServiceObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
- Service container = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- return container;
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
}
-
+
public static Service getServiceObjectByNameAndVersion(UserRoleEnum sdncModifierDetails, String serviceName, String serviceVersion) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(sdncModifierDetails);
RestResponse serviceResponse = ServiceRestUtils.getServiceByNameAndVersion(defaultUser, serviceName, serviceVersion);
- Service container = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- return container;
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
}
-
+
public static Service getServiceObject(String uniqueId) throws Exception {
RestResponse serviceResponse = ServiceRestUtils.getService(uniqueId);
- Service container = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- return container;
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
}
public static Product getProductObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
- Product container = ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
- return container;
+ return ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
}
public static Component getComponentObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
User defaultUser = ElementFactory.getDefaultUser(userRole);
switch (containerDetails.getComponentType()) {
- case RESOURCE:
- RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- break;
- case SERVICE:
- RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- break;
- case PRODUCT:
- RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
- containerDetails = ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
- break;
- default:
- break;
+ case RESOURCE:
+ RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+ break;
+ case SERVICE:
+ RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
+ break;
+ case PRODUCT:
+ RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
+ break;
+ default:
+ break;
}
return containerDetails;
}
- public static Component convertReposnseToComponentObject(Component containerDetails, RestResponse restresponse) throws Exception {
+ public static Component convertReposnseToComponentObject(Component containerDetails, RestResponse restresponse) {
switch (containerDetails.getComponentType()) {
- case RESOURCE:
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(restresponse.getResponse());
- break;
- case SERVICE:
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(restresponse.getResponse());
- break;
- case PRODUCT:
- containerDetails = ResponseParser.convertProductResponseToJavaObject(restresponse.getResponse());
- break;
- default:
- break;
+ case RESOURCE:
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(restresponse.getResponse());
+ break;
+ case SERVICE:
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(restresponse.getResponse());
+ break;
+ case PRODUCT:
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(restresponse.getResponse());
+ break;
+ default:
+ break;
}
return containerDetails;
}
@@ -624,17 +588,17 @@ public final class AtomicOperationUtils {
if (associate2ResourceInstancesResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS) {
switch (containerDetails.getComponentType()) {
- case RESOURCE:
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- case SERVICE:
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- case PRODUCT:
- containerDetails = ResponseParser.convertProductResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- default:
- break;
+ case RESOURCE:
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ case SERVICE:
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ case PRODUCT:
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ default:
+ break;
}
return Either.left(containerDetails);
@@ -736,10 +700,13 @@ public final class AtomicOperationUtils {
return Either.right(addPropertyResponse);
}
- public static Either<GroupDefinition, RestResponse> updateGroupPropertyOnResource(List<PropertyDataDefinition> propertyObject, Resource resource, String groupId, User user, Boolean validateState) throws Exception {
+ public static Either<GroupDefinition, RestResponse> updateGroupPropertyOnResource(String maxVFModuleInstacesValue, Resource resource, String groupId, User user, Boolean validateState) throws Exception {
- Gson gson = new Gson();
- RestResponse updateGroupPropertyResponse = PropertyRestUtils.updateGroupProperty(resource, groupId, gson.toJson(propertyObject), user);
+// Gson gson = new Gson();
+ // Json group property object
+ String propertyObjectJson = "[{\"defaultValue\":null,\"description\":\"The maximum instances of this VF-Module\",\"name\":\"max_vf_module_instances\",\"parentUniqueId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances\",\"password\":false,\"required\":false,\"schema\":{\"property\":{}},\"type\":\"integer\",\"uniqueId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances.property.3\",\"value\":\"" + maxVFModuleInstacesValue + "\",\"definition\":false,\"getInputValues\":null,\"constraints\":null,\"valueUniqueUid\":null,\"ownerId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances\"}]";
+// GroupProperty property = gson.fromJson(propertyObjectJson, GroupProperty.class);
+ RestResponse updateGroupPropertyResponse = PropertyRestUtils.updateGroupProperty(resource, groupId, propertyObjectJson, user);
if (validateState) {
assertTrue("update group property to resource failed: " + updateGroupPropertyResponse.getResponseMessage(), updateGroupPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
@@ -770,7 +737,7 @@ public final class AtomicOperationUtils {
/**
* Builds Resource From rest response
- *
+ *
* @param resourceResp
* @return
*/
@@ -792,10 +759,10 @@ public final class AtomicOperationUtils {
private static final long serialVersionUID = 1L;
}
-
+
/**
* Import resource from CSAR
- *
+ *
* @param resourceType
* @param userRole
* @param fileName
@@ -803,32 +770,94 @@ public final class AtomicOperationUtils {
* @return Resource
* @throws Exception
*/
- public static Resource importResourceFromCSAR(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, String... filePath) throws Exception {
+ public static Resource importResourceFromCsar(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, String... filePath) throws Exception {
// Get the CSARs path
String realFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ;
if (filePath != null && filePath.length > 0) {
- realFilePath = filePath.toString();
+ StringBuffer result = new StringBuffer();
+ for(String currStr: filePath){
+ result.append(currStr);
+ }
+// realFilePath = Arrays.toString(filePath);
+ realFilePath = result.toString();
}
-
+
// Create default import resource & user
+ return importResourceFromCsarFile(resourceType, userRole, fileName, realFilePath);
+ }
+
+ public static Resource importResourceFromCsarFile(ResourceTypeEnum resourceType, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
+ RestResponse createResource = getCreateResourceRestResponse(resourceType, userRole, csarFileName, csarFilePath);
+ BaseRestUtils.checkCreateResponse(createResource);
+ return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
+ }
+
+ public static Resource importCertifiedResourceFromCsar(ResourceTypeEnum resourceType, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
+ RestResponse createResource = getCreateCertifiedResourceRestResponse(resourceType, userRole, csarFileName, csarFilePath);
+ BaseRestUtils.checkSuccess(createResource);
+ return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
+ }
+ public static RestResponse getCreateResourceRestResponse(ResourceTypeEnum resourceType, UserRoleEnum userRole,
+ String csarFileName, String csarFilePath) throws IOException, Exception {
+
+ ImportReqDetails resourceDetails = buildImportReqDetails(resourceType, csarFileName, csarFilePath);
+ User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
+ RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
+ return createResource;
+ }
+
+ public static RestResponse getCreateCertifiedResourceRestResponse(ResourceTypeEnum resourceType, UserRoleEnum userRole,
+ String csarFileName, String csarFilePath) throws IOException, Exception {
+
+ ImportReqDetails resourceDetails = buildImportReqDetails(resourceType, csarFileName, csarFilePath);
+ User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
+ RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
+ BaseRestUtils.checkCreateResponse(response);
+ return LCSbaseTest.certifyResource(resourceDetails, sdncModifierDetails);
+ }
+
+ private static ImportReqDetails buildImportReqDetails(ResourceTypeEnum resourceType, String csarFileName, String csarFilePath) throws IOException {
ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
+ Path path = Paths.get(csarFilePath + File.separator + csarFileName);
+ byte[] data = Files.readAllBytes(path);
+ String payloadName = csarFileName;
+ String payloadData = Base64.encodeBase64String(data);
+ resourceDetails.setPayloadData(payloadData);
+ resourceDetails.setCsarUUID(payloadName);
+ resourceDetails.setPayloadName(payloadName);
+ resourceDetails.setResourceType(resourceType.name());
+ return resourceDetails;
+ }
+
+ public static Resource updateResourceFromCsar(Resource resource, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
-
+
byte[] data = null;
- Path path = Paths.get(realFilePath + File.separator + fileName);
+ Path path = Paths.get(csarFilePath + File.separator + csarFileName);
data = Files.readAllBytes(path);
- String payloadName = fileName;
+ String payloadName = csarFileName;
String payloadData = Base64.encodeBase64String(data);
+ ImportReqDetails resourceDetails = new ImportReqDetails(resource, payloadName, payloadData);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setCsarUUID(payloadName);
resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(resourceType.name());
-
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(createResource);
- return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- };
-
+
+ String userId = sdncModifierDetails.getUserId();
+ Config config = Utils.getConfig();
+ String url = String.format(Urls.UPDATE_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort(), resource.getUniqueId());
+
+ Map<String, String> headersMap = ResourceRestUtils.prepareHeadersMap(userId);
+
+ Gson gson = new Gson();
+ String userBodyJson = gson.toJson(resourceDetails);
+ String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
+ headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
+ HttpRequest http = new HttpRequest();
+ RestResponse updateResourceResponse = http.httpSendPut(url, userBodyJson, headersMap);
+ BaseRestUtils.checkSuccess(updateResourceResponse);
+ return ResponseParser.parseToObjectUsingMapper(updateResourceResponse.getResponse(), Resource.class);
+ }
+
public static Either<Resource, RestResponse> importResourceByFileName(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, Boolean validateState, String... filePath) throws IOException {
String realFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ;
@@ -838,7 +867,7 @@ public final class AtomicOperationUtils {
try {
User defaultUser = ElementFactory.getDefaultUser(userRole);
- ResourceReqDetails defaultResource = ElementFactory.getDefaultResource(defaultUser);
+ ResourceReqDetails defaultResource = ElementFactory.getDefaultResource(defaultUser);
ImportReqDetails defaultImportResource = ElementFactory.getDefaultImportResource(defaultResource);
ImportUtils.getImportResourceDetailsByPathAndName(defaultImportResource, realFilePath, fileName);
RestResponse resourceResp = ResourceRestUtils.createResource(defaultImportResource, defaultUser);
@@ -856,7 +885,7 @@ public final class AtomicOperationUtils {
throw new AtomicOperationException(e);
}
}
-
+
public static Either<String, RestResponse> getComponenetArtifactPayload(Component component, String artifactType) throws Exception {
String url;
@@ -894,14 +923,14 @@ public final class AtomicOperationUtils {
assertTrue(response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS);
}
return response;
-
+
} catch (Exception e) {
throw new AtomicOperationException(e);
}
}
-
+
public static Either <RestResponse, Map<String, List<DistributionMonitorObject>>> getSortedDistributionStatusMap(Service service, Boolean validateState) {
-
+
try {
ServiceDistributionStatus serviceDistributionObject = DistributionUtils.getLatestServiceDistributionObject(service);
RestResponse response = getDistributionStatusByDistributionId(serviceDistributionObject.getDistributionID(), true);
@@ -916,10 +945,10 @@ public final class AtomicOperationUtils {
} catch (Exception e) {
throw new AtomicOperationException(e);
}
-
+
}
-
-
+
+
/**
* @param service
* @param pollingCount
@@ -928,13 +957,13 @@ public final class AtomicOperationUtils {
* @throws Exception
*/
public static Boolean distributeAndValidateService(Service service, int pollingCount, int pollingInterval) throws Exception {
- int firstPollingInterval = 30000; //this value define first be polling topic time, should change if DC configuration changed
+ int firstPollingInterval = 30000; //this value define first be polling topic time, should change if DC configuration changed
Boolean statusFlag = true;
AtomicOperationUtils.distributeService(service, true);
TimeUnit.MILLISECONDS.sleep(firstPollingInterval);
int timeOut = pollingCount * pollingInterval;
com.clearspring.analytics.util.Pair<Boolean,Map<String,List<String>>> verifyDistributionStatus = null;
-
+
while (timeOut > 0) {
Map<String,List<DistributionMonitorObject>> sortedDistributionStatusMap = AtomicOperationUtils.getSortedDistributionStatusMap(service, true).right().value();
verifyDistributionStatus = DistributionUtils.verifyDistributionStatus(sortedDistributionStatusMap);
@@ -945,7 +974,7 @@ public final class AtomicOperationUtils {
timeOut = 0;
}
}
-
+
if((verifyDistributionStatus.right != null && ! verifyDistributionStatus.right.isEmpty())){
for(Entry<String, List<String>> entry : verifyDistributionStatus.right.entrySet()){
if(ComponentBaseTest.getExtendTest() != null){
@@ -958,9 +987,33 @@ public final class AtomicOperationUtils {
}
return statusFlag;
}
-
+
public static Boolean distributeAndValidateService(Service service) throws Exception {
return distributeAndValidateService(service, 10, 10000);
}
+
+ /**
+ * @param resource to download csar file via API
+ * @return Tosca definition object from main yaml file
+ */
+ public static ToscaDefinition downloadAndGetToscaMainYamlObjectApi(Resource resource, File filesFolder) throws Exception {
+ File vfCsarFileName = new File(File.separator + "VfCsar_" + ElementFactory.generateUUIDforSufix() + ".csar");
+ OnboardingUtillViaApis.downloadToscaCsarToDirectory(resource, new File(filesFolder.getPath() + vfCsarFileName));
+ return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + vfCsarFileName));
+ }
+
+
+ public static ComponentInstance getServiceComponentInstanceByName(Service service, String name, Boolean validateState){
+ List<ComponentInstance> compInstances = service.getComponentInstances();
+ for (ComponentInstance instance: compInstances){
+ String compName = instance.getName();
+ if (compName.equals(name))
+ return instance;
+ }
+ if (validateState) {
+ assertEquals("Component instance name " + name + " not found", name, null);
+ }
+ return null;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java
index cbae462d80..031d2d8e72 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/Convertor.java
@@ -20,24 +20,13 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
-import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.Product;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.*;
import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit;
@@ -46,6 +35,13 @@ import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedUserCRUDAudit;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.common.api.Constants;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
+import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
+
public class Convertor {
// ***** resource *****
public static ResourceRespJavaObject constructFieldsForRespValidation(ResourceReqDetails resourceDetails,
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java
index d1701241fe..e303682a37 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ElementFactory.java
@@ -24,6 +24,8 @@ import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
@@ -287,26 +289,26 @@ public class ElementFactory {
// *** SERVICE ***
public static ServiceReqDetails getDefaultService() {
- return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, "al1976");
+ return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, "al1976", ServiceInstantiationType.A_LA_CARTE.getValue());
}
public static ServiceReqDetails getDefaultService(String contactId) {
- return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, contactId);
+ return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, contactId, ServiceInstantiationType.A_LA_CARTE.getValue());
}
public static ServiceReqDetails getDefaultService(User user) {
- return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, user.getUserId());
+ return getDefaultService(CI_SERVICE, ServiceCategoriesEnum.MOBILITY, user.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
}
-
- public static ServiceReqDetails getServiceByCategory(ServiceCategoriesEnum category) {
- return getDefaultService(CI_SERVICE, category, "al1976");
- }
-
+
public static ServiceReqDetails getDefaultService(ServiceCategoriesEnum category, User user) {
- return getDefaultService(CI_SERVICE, category, user.getUserId());
+ return getDefaultService(CI_SERVICE, category, user.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue());
+ }
+
+ public static ServiceReqDetails getServiceByCategory(ServiceCategoriesEnum category) {
+ return getDefaultService(CI_SERVICE, category, "al1976", ServiceInstantiationType.A_LA_CARTE.getValue());
}
- public static ServiceReqDetails getDefaultService(String serviceName, ServiceCategoriesEnum category, String contactId) {
+ public static ServiceReqDetails getDefaultService(String serviceName, ServiceCategoriesEnum category, String contactId, String instantiationType) {
serviceName = (serviceName + generateUUIDforSufix());
ArrayList<String> tags = new ArrayList<>();
tags.add("serviceTag");
@@ -315,7 +317,7 @@ public class ElementFactory {
String description = "service Description";
String icon = "defaulticon";
- ServiceReqDetails serviceDetails = new ServiceReqDetails(serviceName, category.getValue(), tags, description, contactId, icon);
+ ServiceReqDetails serviceDetails = new ServiceReqDetails(serviceName, category.getValue(), tags, description, contactId, icon, instantiationType);
return serviceDetails;
}
@@ -375,7 +377,7 @@ public class ElementFactory {
public static ComponentInstanceReqDetails getDefaultComponentInstance(String name) {
String resourceUid = "resourceId";
- ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, name);
+ ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, name, null);
return resourceInstanceDetails;
@@ -383,7 +385,7 @@ public class ElementFactory {
public static ComponentInstanceReqDetails getDefaultComponentInstance(String name, ComponentReqDetails componentReqDetails) {
String resourceUid = componentReqDetails.getUniqueId();
- ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, name);
+ ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, name, null);
return resourceInstanceDetails;
@@ -392,7 +394,7 @@ public class ElementFactory {
public static ComponentInstanceReqDetails getComponentResourceInstance(ComponentReqDetails compInstOriginDetails) {
String compInstName = (compInstOriginDetails.getName() != null ? compInstOriginDetails.getName() : "resourceInstanceName");
String resourceUid = compInstOriginDetails.getUniqueId();
- ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, compInstName);
+ ComponentInstanceReqDetails resourceInstanceDetails = new ComponentInstanceReqDetails(resourceUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, compInstName, null);
return resourceInstanceDetails;
}
@@ -400,7 +402,7 @@ public class ElementFactory {
public static ComponentInstanceReqDetails getComponentInstance(Component compInstOriginDetails) {
String compInstName = (compInstOriginDetails.getName() != null ? compInstOriginDetails.getName() : "componentInstanceName");
String compInsUid = compInstOriginDetails.getUniqueId();
- ComponentInstanceReqDetails componentInstanceDetails = new ComponentInstanceReqDetails(compInsUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, compInstName);
+ ComponentInstanceReqDetails componentInstanceDetails = new ComponentInstanceReqDetails(compInsUid, RESOURCE_INSTANCE_DESCRIPTION, RESOURCE_INSTANCE_POS_X, RESOURCE_INSTANCE_POS_Y, compInstName, compInstOriginDetails.getComponentType() == ComponentTypeEnum.SERVICE ? OriginTypeEnum.ServiceProxy.name() : null);
return componentInstanceDetails;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java
index 7af18dd3b7..72610331d9 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileHandling.java
@@ -21,29 +21,6 @@
package org.openecomp.sdc.ci.tests.utils.general;
import com.aventstack.extentreports.Status;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
-
import org.apache.commons.io.FileUtils;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
@@ -51,7 +28,6 @@ import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.common.util.GeneralUtility;
import org.yaml.snakeyaml.Yaml;
-import com.aventstack.extentreports.Status;
import java.io.*;
import java.nio.file.Paths;
import java.util.*;
@@ -342,9 +318,10 @@ public class FileHandling {
File dir = new File(directoryPath);
try {
FileUtils.cleanDirectory(dir);
+ } catch (IllegalArgumentException e) {
+ System.out.println("Failed to clean " + dir);
} catch (IOException e) {
- System.out.println("Failed to delete " + dir);
- ComponentBaseTest.getExtendTest().log(Status.INFO, "Failed to delete " + dir);
+ System.out.println("Failed to clean " + dir);
}
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java
index f0ca9dd517..226c734c91 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/FileUtils.java
@@ -20,7 +20,11 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.testng.AssertJUnit.assertTrue;
+import fj.data.Either;
+import org.openecomp.sdc.ci.tests.utils.Decoder;
+import org.openecomp.sdc.ci.tests.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -31,12 +35,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.openecomp.sdc.ci.tests.utils.Decoder;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertTrue;
public class FileUtils {
static Logger logger = LoggerFactory.getLogger(Utils.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java
index 7e5a7d69a2..3b1dcdac1e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/ImportUtils.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.ci.tests.utils.general;
+import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
+
import java.io.IOException;
import java.util.List;
-import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
-
public class ImportUtils {
public static ImportReqDetails getImportResourceDetailsByPathAndName(ImportReqDetails importReqDetails,
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java
index 5f9ec1bfc8..f9ce645fc7 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java
@@ -20,23 +20,8 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import com.aventstack.extentreports.Status;
-import com.clearspring.analytics.util.Pair;
import com.google.gson.Gson;
import fj.data.Either;
-
import org.apache.commons.codec.binary.Base64;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.Resource;
@@ -55,61 +40,22 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import com.clearspring.analytics.util.Pair;
-import com.google.gson.Gson;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
-import fj.data.Either;
+import static org.testng.AssertJUnit.assertTrue;
public class OnboardingUtillViaApis {
-// protected static Map<String, String> prepareHeadersMap(String userId) {
-// Map<String, String> headersMap = new HashMap<String, String>();
-// headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
-// headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
-// headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId);
-// return headersMap;
-// }
-
- public static Pair<String, VendorSoftwareProductObject> createVspViaApis(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile, User user) throws Exception {
-
- VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject();
+ public static VendorSoftwareProductObject createVspViaApis(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile, User user) throws Exception {
AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(user);
- Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, user, amdocsLicenseMembers);
- VendorSoftwareProductObject map = createVendorSoftwareProduct.right;
- vendorSoftwareProductObject.setAttContact(map.getAttContact());
- vendorSoftwareProductObject.setCategory(map.getCategory());
- vendorSoftwareProductObject.setComponentId(map.getComponentId());
- vendorSoftwareProductObject.setDescription(map.getDescription());
- vendorSoftwareProductObject.setSubCategory(map.getSubCategory());
- vendorSoftwareProductObject.setVendorName(map.getVendorName());
- vendorSoftwareProductObject.setVspId(map.getVspId());
- Pair<String, VendorSoftwareProductObject> pair = new Pair<String, VendorSoftwareProductObject>(createVendorSoftwareProduct.left, vendorSoftwareProductObject);
- return pair;
+ return VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, user, amdocsLicenseMembers);
}
-/* public static Resource createResourceFromVSP(Pair<String, Map<String, String>> createVendorSoftwareProduct, String vspName) throws Exception {
- List<String> tags = new ArrayList<>();
- tags.add(vspName);
- Map<String, String> map = createVendorSoftwareProduct.right;
- ResourceReqDetails resourceDetails = new ResourceReqDetails();
- resourceDetails.setCsarUUID(map.get("vspId"));
- resourceDetails.setCsarVersion("1.0");
- resourceDetails.setName(vspName);
- resourceDetails.setTags(tags);
- resourceDetails.setDescription(map.get("description"));
- resourceDetails.setResourceType(map.get("componentType"));
- resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_DATABASE.getCategory(), ResourceCategoryEnum.GENERIC_DATABASE.getSubCategory());
- resourceDetails.setVendorName(map.get("vendorName"));
- resourceDetails.setVendorRelease("1.0");
- resourceDetails.setResourceType("VF");
- resourceDetails.setResourceVendorModelNumber("666");
- resourceDetails.setContactId(map.get("attContact"));
- resourceDetails.setIcon("defaulticon");
- Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
-
- return resource;
- }*/
public static Resource createResourceFromVSP(ResourceReqDetails resourceDetails) throws Exception {
Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
return resource;
@@ -133,28 +79,6 @@ public class OnboardingUtillViaApis {
}
}
-// public static void convertPayloadToFile(String payload, File file, boolean isBased64, boolean isSdcFormat) throws IOException{
-//
-// Gson gson = new Gson();
-// byte[] byteArray = null;
-// Map<String, String> fromJson;
-// @SuppressWarnings("unchecked")
-// String string = null;// = fromJson.get("base64Contents").toString();
-// if(isSdcFormat){
-// fromJson = gson.fromJson(payload, Map.class);
-// string = fromJson.get("base64Contents").toString();
-// }else if (isBased64) {
-// byteArray = Base64.decode(string.getBytes(StandardCharsets.UTF_8));
-// }else{
-// byteArray = payload.getBytes(StandardCharsets.UTF_8);
-// }
-// File downloadedFile = new File(file.getAbsolutePath());
-// FileOutputStream fos = new FileOutputStream(downloadedFile);
-// fos.write(byteArray);
-// fos.flush();
-// fos.close();
-//
-// }
public static void convertPayloadToFile(String payload, File file) throws IOException{
@@ -180,49 +104,8 @@ public class OnboardingUtillViaApis {
fos.flush();
fos.close();
-
-// ZipOutputStream fos = null;
-//
-//
-// for (Charset charset : Charset.availableCharsets().values()) {
-// try{
-// // System.out.println("How to do it???");
-// File downloadedFile = new File(file.getAbsolutePath() + "_" + charset +".csar");
-// fos = new ZipOutputStream(new FileOutputStream(downloadedFile));
-// byte[] byteArray = payload.getBytes(charset);
-// fos.write(byteArray);
-// fos.flush();
-//
-// }
-// catch(Exception e){
-// fos.close();
-// }
-// }
System.out.println("");
-// ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(byteArray));
-// ZipEntry entry = null;
-// while ((entry = zipStream.getNextEntry()) != null) {
-//
-// String entryName = entry.getName();
-//
-// FileOutputStream out = new FileOutputStream(file+"/"+entryName);
-//
-// byte[] byteBuff = new byte[4096];
-// int bytesRead = 0;
-// while ((bytesRead = zipStream.read(byteBuff)) != -1)
-// {
-// out.write(byteBuff, 0, bytesRead);
-// }
-//
-// out.close();
-// zipStream.closeEntry();
-// }
-// zipStream.close();
-//
-
-
-
BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(payload.getBytes(StandardCharsets.ISO_8859_1)));
String filePath = file.toString();
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
@@ -232,7 +115,7 @@ public class OnboardingUtillViaApis {
bos.close();
}
- public static Either<String, RestResponse> getVendorSoftwareProduct(String vspId, User user, Boolean validateState) throws Exception {
+ public static Either<String, RestResponse> getVendorSoftwareProduct(String vspId, User user, Boolean validateState) throws IOException {
Config config = Utils.getConfig();
String url = String.format(Urls.GET_VENDOR_SOFTWARE_PRODUCT, config.getOnboardingBeHost(), config.getOnboardingBePort(), vspId);
@@ -257,19 +140,15 @@ public class OnboardingUtillViaApis {
List<String> tags = new ArrayList<>();
tags.add(vendorSoftwareProductObject.getName());
-// ResourceReqDetails resourceDetails = new ResourceReqDetails();
resourceDetails.setCsarUUID(vendorSoftwareProductObject.getVspId());
resourceDetails.setCsarVersion(vendorSoftwareProductObject.getVersion());
resourceDetails.setName(vendorSoftwareProductObject.getName());
resourceDetails.setTags(tags);
resourceDetails.setDescription(vendorSoftwareProductObject.getDescription());
-// resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_DATABASE.getCategory(), ResourceCategoryEnum.GENERIC_DATABASE.getSubCategory());
resourceDetails.setVendorName(vendorSoftwareProductObject.getVendorName());
-// resourceDetails.setVendorRelease("1.0");
resourceDetails.setResourceType("VF");
resourceDetails.setResourceVendorModelNumber("666");
resourceDetails.setContactId(vendorSoftwareProductObject.getAttContact());
-// resourceDetails.setIcon("defaulticon");
return resourceDetails;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java
index 6c3a3c4cd4..4f03767a85 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java
index 71038920ae..366962ef0a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/SnmpTypeEnum.java
@@ -20,56 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.general;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.nio.file.FileSystems;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.entity.mime.content.FileBody;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONValue;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
-
-import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
-
-import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.execute.devCI.ArtifactFromCsar;
-
-
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-
-import org.testng.Assert;
-
-import com.aventstack.extentreports.Status;
-import com.clearspring.analytics.util.Pair;
-
enum SnmpTypeEnum{
SNMP_POLL ("snmp"),
SNMP_TRAP ("snmp-trap");
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java
index 51e4923a1a..eca8921958 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/VendorSoftwareProductRestUtils.java
@@ -41,18 +41,18 @@ import static org.testng.AssertJUnit.assertEquals;
public class VendorSoftwareProductRestUtils {
- public static Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map<CvfcTypeEnum, String> cvfcArtifacts)
+ public static VendorSoftwareProductObject createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map<CvfcTypeEnum, String> cvfcArtifacts)
throws Exception {
- Pair<String, VendorSoftwareProductObject> pair = createVSP(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers);
+ VendorSoftwareProductObject vendorSoftwareProductObject = createVSP(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers);
if(cvfcArtifacts != null && ! cvfcArtifacts.isEmpty()){
- addCvfcArtifacts(cvfcArtifacts, user, pair.right);
+ addCvfcArtifacts(cvfcArtifacts, user, vendorSoftwareProductObject);
}
- prepareVspForUse(user, pair.right, true);
- return pair;
+ prepareVspForUse(user, vendorSoftwareProductObject, true);
+ return vendorSoftwareProductObject;
}
- public static Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers)
+ public static VendorSoftwareProductObject createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers)
throws Exception {
Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>();
@@ -83,14 +83,14 @@ public class VendorSoftwareProductRestUtils {
public static VendorSoftwareProductObject createAndFillVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filePath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map<CvfcTypeEnum, String> cvfcArtifacts)
throws Exception {
- Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = createVendorSoftwareProduct(resourceReqDetails, heatFileName, filePath, user, amdocsLicenseMembers, cvfcArtifacts);
+ VendorSoftwareProductObject createVendorSoftwareProduct = createVendorSoftwareProduct(resourceReqDetails, heatFileName, filePath, user, amdocsLicenseMembers, cvfcArtifacts);
VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(heatFileName, createVendorSoftwareProduct);
return vendorSoftwareProductObject;
}
- public static Pair<String, VendorSoftwareProductObject> createVSP(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception {
+ public static VendorSoftwareProductObject createVSP(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception {
String vspName = handleFilename(heatFileName);
if(ComponentBaseTest.getExtendTest() != null){
@@ -106,8 +106,7 @@ public class VendorSoftwareProductRestUtils {
RestResponse validateUpload = validateUpload(createNewVspPair.right, user);
assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue());
- Pair<String, VendorSoftwareProductObject> pair = new Pair<>(vspName, createNewVspPair.right);
- return pair;
+ return createNewVspPair.right;
}
public static void updateVspWithVfcArtifacts(String filepath, String updatedSnmpPoll, String updatedSnmpTrap, String componentInstanceId, User user, VendorSoftwareProductObject vendorSoftwareProductObject) throws Exception{
@@ -288,6 +287,19 @@ public class VendorSoftwareProductRestUtils {
return response;
}
+// TODO to check if for onboard API ACTION_ARCHIVE_RESTORE_COMPONENT format was added version parameter
+// if yes remove this method and use general actionOnComponent method
+ private static RestResponse actionOnComponent(String vspid, String body, String onboardComponent, User user) throws Exception {
+ Config config = Utils.getConfig();
+ String url = String.format(Urls.ACTION_ARCHIVE_RESTORE_COMPONENT, config.getCatalogBeHost(), config.getCatalogBePort(), onboardComponent, vspid);
+ String userId = user.getUserId();
+ Map<String, String> headersMap = OnboardingUtils.prepareHeadersMap(userId);
+
+ HttpRequest http = new HttpRequest();
+ RestResponse response = http.httpSendPut(url, body, headersMap);
+ return response;
+ }
+
public static Pair<RestResponse, VendorSoftwareProductObject> createNewVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String vspName, AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception {
Config config = Utils.getConfig();
@@ -317,6 +329,7 @@ public class VendorSoftwareProductRestUtils {
vendorSoftwareProductObject.setVspId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "itemId"));
vendorSoftwareProductObject.setComponentId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:id"));
+// vendorSoftwareProductObject.setVersion(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:name"));
vendorSoftwareProductObject.setAttContact(user.getUserId());
return new Pair<>(response, vendorSoftwareProductObject);
@@ -659,17 +672,16 @@ public class VendorSoftwareProductRestUtils {
// }
- public static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct) {
+ private static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, VendorSoftwareProductObject createVendorSoftwareProduct) {
VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject();
- VendorSoftwareProductObject map = createVendorSoftwareProduct.right;
- vendorSoftwareProductObject.setAttContact(map.getAttContact());
- vendorSoftwareProductObject.setCategory(map.getCategory());
- vendorSoftwareProductObject.setComponentId(map.getComponentId());
- vendorSoftwareProductObject.setDescription(map.getDescription());
- vendorSoftwareProductObject.setSubCategory(map.getSubCategory());
- vendorSoftwareProductObject.setVendorName(map.getVendorName());
- vendorSoftwareProductObject.setVspId(map.getVspId());
- vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left);
+ vendorSoftwareProductObject.setAttContact(createVendorSoftwareProduct.getAttContact());
+ vendorSoftwareProductObject.setCategory(createVendorSoftwareProduct.getCategory());
+ vendorSoftwareProductObject.setComponentId(createVendorSoftwareProduct.getComponentId());
+ vendorSoftwareProductObject.setDescription(createVendorSoftwareProduct.getDescription());
+ vendorSoftwareProductObject.setSubCategory(createVendorSoftwareProduct.getSubCategory());
+ vendorSoftwareProductObject.setVendorName(createVendorSoftwareProduct.getVendorName());
+ vendorSoftwareProductObject.setVspId(createVendorSoftwareProduct.getVspId());
+ vendorSoftwareProductObject.setName(createVendorSoftwareProduct.getName());
String[] arrFileNameAndExtension = vnfFile.split("\\.");
vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage");
vendorSoftwareProductObject.setNetworkPackageName(arrFileNameAndExtension[0]);
@@ -692,5 +704,14 @@ public class VendorSoftwareProductRestUtils {
prepareVspForUse(user,vendorSoftwareProductObject, true);
}
+ public static RestResponse archiveVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception {
+ String messageBody = "{\"action\":\"ARCHIVE\"}";
+ return actionOnComponent(vendorSoftwareProductObject.getVspId(), messageBody, "items", user);
+ }
+
+ public static RestResponse restoreVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception {
+ String messageBody = "{\"action\":\"RESTORE\"}";
+ return actionOnComponent(vendorSoftwareProductObject.getVspId(), messageBody, "items", user);
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java
index 448442e112..7daf1bd414 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java
@@ -20,23 +20,12 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
@@ -55,7 +44,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.AssertJUnit;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
public class ArtifactRestUtils extends BaseRestUtils {
private static Logger logger = LoggerFactory.getLogger(ArtifactRestUtils.class.getName());
@@ -344,10 +339,10 @@ public class ArtifactRestUtils extends BaseRestUtils {
- public static RestResponse downloadResourceInstanceArtifact(String serviceUniqueId,String resourceInstanceId, User user, String artifactUniqeId) throws Exception
+ public static RestResponse downloadResourceInstanceArtifact(String serviceUniqueId,String resourceInstanceId, User user, String artifactUniqueId) throws Exception
{
Config config = Utils.getConfig();
- String url = String.format(Urls.DOWNLOAD_COMPONENT_INSTANCE_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), serviceUniqueId, resourceInstanceId, artifactUniqeId);
+ String url = String.format(Urls.DOWNLOAD_COMPONENT_INSTANCE_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), serviceUniqueId, resourceInstanceId, artifactUniqueId);
RestResponse res = sendGet(url, user.getUserId(), null);
return res;
}
@@ -906,4 +901,18 @@ public class ArtifactRestUtils extends BaseRestUtils {
}
+ /**
+ * @param restResponse restResponse object
+ * @return readable content(converted from base64)
+ * @throws IOException ioexception
+ */
+ public static String getDecodedArtifactPayloadFromResponse(RestResponse restResponse) throws IOException {
+ Gson gson = new Gson();
+ Map<String, String> fromJson = gson.fromJson(restResponse.getResponse(), Map.class);
+ String payloadData = fromJson.get("base64Contents").toString();
+ String decodedPaypload = org.openecomp.sdc.ci.tests.utils.Decoder.decode(payloadData);
+ return decodedPaypload;
+ }
+
+
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java
index 13cfb8fb63..ad70c34628 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java
@@ -20,42 +20,21 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.*;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactAssetStructure;
-import org.openecomp.sdc.ci.tests.datatypes.AssetStructure;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceDetailedAssetStructure;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceInstanceAssetStructure;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceAssetStructure;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceDetailedAssetStructure;
+import org.openecomp.sdc.ci.tests.datatypes.*;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
@@ -66,11 +45,17 @@ import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
public class AssetRestUtils extends BaseRestUtils {
static Gson gson = new Gson();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java
index 65ab6c920a..8d39bd1c99 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java
@@ -20,15 +20,15 @@
package org.openecomp.sdc.ci.tests.utils.rest;
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.utils.Utils;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-
public class AutomationUtils extends BaseRestUtils {
@@ -63,24 +63,24 @@ public class AutomationUtils extends BaseRestUtils {
public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName) throws IOException {
File myFoo = new File(filepath);
- FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append
- String versions = ("onboardVersion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n");
- byte[] myBytes = versions.getBytes();
- fooStream.write(myBytes);
- fooStream.close();
+ try (FileOutputStream fooStream = new FileOutputStream(myFoo, false)) {
+ String versions = ("onboardVersion=\"" + onboardVersion + "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\"" + envData + "\"\n" + "suiteName=\"" + suiteName + "\"\n");
+ byte[] myBytes = versions.getBytes();
+ fooStream.write(myBytes);
+ }
}
public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName, String reportStartTime) throws IOException {
File myFoo = new File(filepath);
- FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append
- String versions = ("onboardVersion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n" + "reportStartTime=\""+ reportStartTime+ "\"\n");
- byte[] myBytes = versions.getBytes();
- fooStream.write(myBytes);
- fooStream.close();
+ try (FileOutputStream fooStream = new FileOutputStream(myFoo, false)) {
+ String versions = ("onboardVersion=\"" + onboardVersion + "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\"" + envData + "\"\n" + "suiteName=\"" + suiteName + "\"\n" + "reportStartTime=\"" + reportStartTime + "\"\n");
+ byte[] myBytes = versions.getBytes();
+ fooStream.write(myBytes);
+ }
}
public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData)
- throws FileNotFoundException, IOException {
+ throws IOException {
createVersionsInfoFile(filepath, onboardVersion, osVersion, envData, null);
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java
index 4ec0353abd..56859ff56a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -40,6 +33,13 @@ import org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class BaseRestUtils extends BaseValidationUtils {
public static final String contentTypeHeaderData = "application/json";
public static final String acceptHeaderData = "application/json";
@@ -84,7 +84,7 @@ public class BaseRestUtils extends BaseValidationUtils {
// ************* PRIVATE METHODS ************************
- protected static Map<String, String> prepareHeadersMap(String userId) {
+ public static Map<String, String> prepareHeadersMap(String userId) {
return prepareHeadersMap(userId, acceptHeaderData);
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java
index b09ba10df1..304df86199 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java
@@ -20,10 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
@@ -31,6 +27,10 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
public class CatalogRestUtils extends BaseRestUtils {
public static RestResponse getAbstractResources() throws IOException {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CategoryRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CategoryRestUtils.java
index 460518b35f..3e1413a226 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CategoryRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CategoryRestUtils.java
@@ -20,10 +20,8 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
@@ -35,8 +33,9 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
public class CategoryRestUtils extends BaseRestUtils {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java
index 64b576e3e2..e59c13bf11 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java
@@ -20,19 +20,9 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
@@ -40,7 +30,12 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertTrue;
public class ComponentInstanceRestUtils extends BaseRestUtils {
// public static String acceptHeaderDate = "application/json";
@@ -272,5 +267,15 @@ public class ComponentInstanceRestUtils extends BaseRestUtils {
return changeResourceInstanceVersion;
}
+ public static CapReqDef getInstancesCapabilitiesRequirements(Component component, String userId) throws Exception {
+
+ String url = String.format(Urls.GET_INSTANCE_REQUIRMENTS_CAPABILITIES,
+ Utils.getConfig().getCatalogBeHost(), Utils.getConfig().getCatalogBePort(),
+ ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId());
+
+ RestResponse getComponentReqCap = sendGet(url, userId);
+ assertTrue(getComponentReqCap.getErrorCode() == STATUS_CODE_GET_SUCCESS);
+ return ResponseParser.parseToObject(getComponentReqCap.getResponse(), CapReqDef.class);
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentRestUtils.java
index dcebe4afa8..8fcc67925a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentRestUtils.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.CapReqDef;
import org.openecomp.sdc.be.model.User;
@@ -34,6 +32,8 @@ import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
+import java.io.IOException;
+
public class ComponentRestUtils extends BaseRestUtils {
public static RestResponse getComponentRequirmentsCapabilities(User sdncModifierDetails,
ComponentReqDetails componentReqDetails) throws IOException {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java
index 9fdab02bb1..949ab68961 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java
@@ -20,11 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.openecomp.portalsdk.core.restful.domain.EcompRole;
import org.openecomp.portalsdk.core.restful.domain.EcompUser;
import org.openecomp.sdc.ci.tests.api.Urls;
@@ -37,7 +33,10 @@ import org.openecomp.sdc.ci.tests.utils.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class EcompUserRestUtils extends BaseRestUtils {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java
index f55cdbd035..e491b3bd17 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java
@@ -20,10 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.User;
@@ -33,7 +30,9 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
public class GroupRestUtils extends BaseRestUtils {
static Config config = Config.instance();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java
index 40dc060993..0edc294693 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java
@@ -20,22 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
@@ -64,6 +48,14 @@ import org.openecomp.sdc.common.http.client.api.HttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.*;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.util.*;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+
public class ImportRestUtils extends BaseRestUtils {
private static Logger log = LoggerFactory.getLogger(ImportRestUtils.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/InputsRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/InputsRestUtils.java
index de7be077d1..521da28522 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/InputsRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/InputsRestUtils.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.rest;
+import com.google.gson.Gson;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstInputsMap;
@@ -33,8 +34,6 @@ import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-
/**
* RestUtils for inputs
*
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
index 9c0b7a89e0..44e7b56426 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
@@ -20,19 +20,10 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
import org.json.simple.JSONObject;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
@@ -48,6 +39,11 @@ import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
public class LifecycleRestUtils extends BaseRestUtils {
private static Logger logger = LoggerFactory.getLogger(LifecycleRestUtils.class.getName());
public static final String COMMENT = "comment";
@@ -78,10 +74,10 @@ public class LifecycleRestUtils extends BaseRestUtils {
return changeLifeCycleOfAsset(serviceUUID, AssetTypeEnum.SERVICES, LifeCycleStatesEnum.CERTIFICATIONREQUEST, sdncModifierDetails, comment);
}
- public static RestResponse certificationRequestResource(String resourceUUID, User sdncModifierDetails) throws IOException {
+ /*public static RestResponse certificationRequestResource(String resourceUUID, User sdncModifierDetails) throws IOException {
String comment = "Certification request resource: " + resourceUUID;
return changeLifeCycleOfAsset(resourceUUID, AssetTypeEnum.RESOURCES, LifeCycleStatesEnum.CERTIFICATIONREQUEST, sdncModifierDetails, comment);
- }
+ }*/
public static RestResponse startTestingService(String serviceUUID, User sdncModifierDetails) throws IOException {
String comment = "Start testing request service: " + serviceUUID;
@@ -277,10 +273,12 @@ public class LifecycleRestUtils extends BaseRestUtils {
}
public static RestResponse certifyResource(ResourceReqDetails resourceDetails) throws Exception {
+
+ User designer = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
RestResponse restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails,
ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKIN);
// if (restResponseResource.getErrorCode() == 200){
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails,
+/* restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails,
ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFICATIONREQUEST);
// }else
// return restResponseResource;
@@ -289,16 +287,16 @@ public class LifecycleRestUtils extends BaseRestUtils {
restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, testerDetails,
LifeCycleStatesEnum.STARTCERTIFICATION);
} else
- return restResponseResource;
+ return restResponseResource;*/
if (restResponseResource.getErrorCode() == 200) {
- restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, testerDetails,
+ restResponseResource = LifecycleRestUtils.changeResourceState(resourceDetails, designer,
LifeCycleStatesEnum.CERTIFY);
if (restResponseResource.getErrorCode() == 200) {
String newVersion = ResponseParser.getVersionFromResponse(restResponseResource);
resourceDetails.setVersion(newVersion);
resourceDetails.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- resourceDetails.setLastUpdaterUserId(testerDetails.getUserId());
- resourceDetails.setLastUpdaterFullName(testerDetails.getFullName());
+ resourceDetails.setLastUpdaterUserId(designer.getUserId());
+ resourceDetails.setLastUpdaterFullName(designer.getFullName());
String uniqueIdFromRresponse = ResponseParser.getUniqueIdFromResponse(restResponseResource);
resourceDetails.setUniqueId(uniqueIdFromRresponse);
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ProductRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ProductRestUtils.java
index 65bc2f5d92..1a59a31ddf 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ProductRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ProductRestUtils.java
@@ -20,8 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-
+import com.google.gson.Gson;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.Product;
@@ -37,7 +36,7 @@ import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
+import java.io.IOException;
public class ProductRestUtils extends BaseRestUtils {
private static Gson gson = new Gson();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
index d507c2cb23..d5ae0a47a1 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
@@ -27,14 +27,11 @@ import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.PropertyObject;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.common.util.GeneralUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.openecomp.sdc.ci.tests.datatypes.PropertyObject;
import java.util.ArrayList;
import java.util.HashMap;
@@ -43,322 +40,319 @@ import java.util.Map;
import static org.testng.AssertJUnit.*;
-import com.google.gson.Gson;
-
public class PropertyRestUtils extends BaseRestUtils {
- private static Logger logger = LoggerFactory.getLogger(PropertyRestUtils.class.getName());
-
- public static RestResponse createProperty(String resourceId, String body, User user) throws Exception {
- Config config = Config.instance();
- String url = String.format(Urls.CREATE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(),
- resourceId);
-
- return sendPost(url, body, user.getUserId(), acceptHeaderData);
- }
-
- public static RestResponse updateProperty(String resourceId, String propertyId, String body, User user)
- throws Exception {
- Config config = Config.instance();
-
- String url = String.format(Urls.UPDATE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(),
- resourceId, propertyId);
- return sendPut(url, body, user.getUserId(), acceptHeaderData);
- }
-
- public static RestResponse updateGroupProperty(Component component, String groupId, String body, User user)
- throws Exception {
- Config config = Config.instance();
-
- String url = String.format(Urls.RESOURCE_GROUP_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), groupId);
- return sendPut(url, body, user.getUserId(), acceptHeaderData);
- }
-
- public static RestResponse getProperty(String resourceId, String propertyId, User user) throws Exception {
- Config config = Config.instance();
- String url = String.format(Urls.GET_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId,
- propertyId);
- return sendGet(url, user.getUserId());
- }
-
- public static RestResponse deleteProperty(String resourceId, String propertyId, User user) throws Exception {
- Config config = Config.instance();
- String url = String.format(Urls.DELETE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(),
- resourceId, propertyId);
-
- return sendDelete(url, user.getUserId());
- }
-
- public static ComponentInstanceProperty getPropFromListByPropNameAndType(List<ComponentInstanceProperty> propList,
- String propNameToUpdate, String propTypeToUpdate) {
- for (ComponentInstanceProperty componentInstanceProperty : propList) {
- if (componentInstanceProperty.getName().equals(propNameToUpdate)
- && componentInstanceProperty.getType().equals(propTypeToUpdate)) {
- return componentInstanceProperty;
- }
- }
- return null;
- }
-
- public static ComponentInstanceProperty getPropFromListByPropNameTypeAndPath(
- List<ComponentInstanceProperty> propList, String propNameToUpdate, String propTypeToUpdate,
- List<String> path) {
- for (ComponentInstanceProperty componentInstanceProperty : propList) {
- if (componentInstanceProperty.getPath() == null) {
- return getPropFromListByPropNameAndType(propList, propNameToUpdate, propTypeToUpdate);
- }
- if (componentInstanceProperty.getName().equals(propNameToUpdate)
- && componentInstanceProperty.getType().equals(propTypeToUpdate)
- && path.containsAll(componentInstanceProperty.getPath())) {
- return componentInstanceProperty;
- }
- }
- return null;
- }
-
- public static ComponentInstanceProperty getPropFromListByPropIdAndPath(List<ComponentInstanceProperty> propList,
- String propId, List<String> path) {
-
- for (ComponentInstanceProperty componentInstanceProperty : propList) {
- if (path != null) {
- if (componentInstanceProperty.getUniqueId().equals(propId)
- && componentInstanceProperty.getPath().equals(path)) {
- return componentInstanceProperty;
- }
- } else {
- if (componentInstanceProperty.getUniqueId().equals(propId)) {
- return componentInstanceProperty;
- }
- }
- }
- return null;
- }
-
- public static void comparePropertyLists(List<ComponentInstanceProperty> expectedList,
- List<ComponentInstanceProperty> actualList, Boolean isUpdate) {
-
- assertTrue(
- "list size are not equals, expected size is: " + expectedList.size() + " ,actual: " + actualList.size(),
- expectedList.size() == actualList.size());
- Boolean flag = false;
- for (ComponentInstanceProperty expectedcompInstProp : expectedList) {
- for (ComponentInstanceProperty actualcompInstProp : actualList) {
- flag = comparePropertyObjects(expectedcompInstProp, actualcompInstProp, isUpdate);
- if (flag) {
- break;
- }
- }
- }
- // System.out.println("expected: " + expectedList + ", actual: " +
- // actualList);
- logger.debug("expected: {}, actual: {}",expectedList,actualList);
- assertTrue("actual lists does not contain all uniqeIds", flag);
- }
-
- public static Boolean comparePropertyObjects(ComponentInstanceProperty expectedCompInstProp,
- ComponentInstanceProperty actualCompInstProp, Boolean isUpdate) {
- String uniqueId = expectedCompInstProp.getUniqueId();
- String type = expectedCompInstProp.getType();
- String defaulValue = expectedCompInstProp.getDefaultValue();
- if (actualCompInstProp.getUniqueId().equals(uniqueId)
- && actualCompInstProp.getPath().equals(expectedCompInstProp.getPath())) {
- assertTrue("expected type is: " + type + " ,actual: " + actualCompInstProp.getType(),
- actualCompInstProp.getType().equals(type));
- if (defaulValue == null) {
- assertTrue(
- "expected defaulValue is: " + defaulValue + " ,actual: " + actualCompInstProp.getDefaultValue(),
- actualCompInstProp.getDefaultValue() == defaulValue);
- } else {
- assertTrue(
- "expected defaulValue is: " + defaulValue + " ,actual: " + actualCompInstProp.getDefaultValue(),
- actualCompInstProp.getDefaultValue().equals(defaulValue));
- }
- if (isUpdate) {
- assertTrue(
- "actual [Value] parameter " + actualCompInstProp.getName()
- + "should equal to expected [Value]: " + actualCompInstProp.getValue() + " ,Value: "
- + actualCompInstProp.getValue(),
- actualCompInstProp.getValue().equals(expectedCompInstProp.getValue()));
- assertNotNull("valueId is null", actualCompInstProp.getValueUniqueUid());
- } else {
- if (defaulValue == null) {
- assertTrue(
- "actual [Value] parameter " + actualCompInstProp.getName()
- + "should equal to expected [defaultValue]: " + actualCompInstProp.getValue()
- + " ,defaultValue: " + actualCompInstProp.getDefaultValue(),
- actualCompInstProp.getValue() == expectedCompInstProp.getDefaultValue());
- } else {
- assertTrue(
- "actual [Value] parameter " + actualCompInstProp.getName()
- + "should equal to expected [defaultValue]: " + actualCompInstProp.getValue()
- + " ,defaultValue: " + actualCompInstProp.getDefaultValue(),
- actualCompInstProp.getValue().equals(expectedCompInstProp.getDefaultValue()));
- }
- assertNull("valueId is not null", actualCompInstProp.getValueUniqueUid());
- }
- return true;
- }
- return false;
- }
-
- public static List<ComponentInstanceProperty> addResourcePropertiesToList(Resource resource,
- List<ComponentInstanceProperty> listToFill) {
- for (PropertyDefinition prop : resource.getProperties()) {
- listToFill.add(new ComponentInstanceProperty(prop, null, null));
- }
- return listToFill;
- }
-
- public static List<ComponentInstanceProperty> addComponentInstPropertiesToList(Component component,
- List<ComponentInstanceProperty> listToFill, String componentId) {
-
- if (componentId != null) {
- List<ComponentInstanceProperty> list = component.getComponentInstancesProperties().get(componentId);
- for (ComponentInstanceProperty prop : list) {
- ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(prop, null, null);
- componentInstanceProperty.setPath(prop.getPath());
- componentInstanceProperty.setValueUniqueUid(prop.getValueUniqueUid());
- componentInstanceProperty.setValue(prop.getValue());
- listToFill.add(componentInstanceProperty);
- }
- } else {
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = component
- .getComponentInstancesProperties();
- for (Map.Entry<String, List<ComponentInstanceProperty>> componentInstanceProperties : componentInstancesProperties
- .entrySet()) {
- for (ComponentInstanceProperty prop : componentInstanceProperties.getValue()) {
- ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(prop, null,
- null);
- componentInstanceProperty.setPath(prop.getPath());
- componentInstanceProperty.setValueUniqueUid(prop.getValueUniqueUid());
- componentInstanceProperty.setValue(prop.getValue());
- listToFill.add(componentInstanceProperty);
- }
- }
- }
-
- if (component.getComponentType().getValue().equals("Resource")) {
- for (PropertyDefinition prop : ((Resource) component).getProperties()) {
- listToFill.add(new ComponentInstanceProperty(prop, null, null));
- }
- }
- return listToFill;
- }
-
- public static ComponentInstanceProperty getCompPropInstListByInstIdAndPropName(Component component,
- ComponentInstance componentInstanceDetails, String name, String type) {
- List<ComponentInstanceProperty> propList = component.getComponentInstancesProperties()
- .get(componentInstanceDetails.getUniqueId());
- if (propList != null) {
- return getPropFromListByPropNameAndType(propList, name, type);
- }
- return null;
- }
-
- private static void updatePropertyListWithPathParameter(Resource resource, List<String> path,
- List<ComponentInstanceProperty> expectedPropertyList) {
- List<PropertyDefinition> propertyList = resource.getProperties();
- for (PropertyDefinition propertyDefinition : propertyList) {
- ComponentInstanceProperty propDetailsToRemove = PropertyRestUtils.getPropFromListByPropNameAndType(
- expectedPropertyList, propertyDefinition.getName(), propertyDefinition.getType());
- ComponentInstanceProperty propDetailsToAdd = propDetailsToRemove;
- propDetailsToAdd.setPath(path);
- expectedPropertyList.remove(propDetailsToRemove);
- expectedPropertyList.add(propDetailsToAdd);
- }
- }
-
- private static void updatePropertyListWithPathParameterOnCompInst(Service service, List<String> path,
- List<ComponentInstanceProperty> expectedPropertyList) {
- List<ComponentInstanceProperty> servicePropertyList = new ArrayList<>();
- servicePropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, servicePropertyList,
- path.get(0));
-
- for (ComponentInstanceProperty serviceCompInstProperty : servicePropertyList) {
- ComponentInstanceProperty propDetailsToRemove = PropertyRestUtils.getPropFromListByPropNameTypeAndPath(
- expectedPropertyList, serviceCompInstProperty.getName(), serviceCompInstProperty.getType(),
- serviceCompInstProperty.getPath());
- ComponentInstanceProperty propDetailsToAdd = propDetailsToRemove;
- List<String> tempPathList = new ArrayList<String>();
- for (String tempPath : path) {
- tempPathList.add(tempPath);
- }
- // path parameter can not contain the same service unique ID twice
- if (propDetailsToAdd.getPath() != null
- && !propDetailsToAdd.getPath().get(0).contains(service.getUniqueId())) {
- if (!propDetailsToAdd.getPath().containsAll(tempPathList)) {
- tempPathList.addAll(propDetailsToAdd.getPath());
- }
- }
- propDetailsToAdd.setPath(tempPathList);
- expectedPropertyList.remove(propDetailsToRemove);
- expectedPropertyList.add(propDetailsToAdd);
- }
- }
-
- public static void updatePropertyListWithPathOnResource(ComponentInstance componentInstDetails, Resource resource,
- List<ComponentInstanceProperty> list, Component container) {
- List<String> path = new ArrayList<>();
- if (container != null) {
- List<ComponentInstance> componentInstances = container.getComponentInstances();
- for (ComponentInstance componentInstance : componentInstances) {
- if (componentInstance.getNormalizedName().equals(componentInstDetails.getNormalizedName())) {
- path.add(componentInstance.getUniqueId());
- break;
- }
- }
-
- } else {
- path.add(componentInstDetails.getUniqueId());
- }
- updatePropertyListWithPathParameter(resource, path, list);
- }
-
- public static void updatePropertyListWithPathOnComponentInstance(ComponentInstance componentInstDetails,
- Service service, List<ComponentInstanceProperty> list) {
- List<String> path = new ArrayList<>();
- path.add(componentInstDetails.getUniqueId());
- updatePropertyListWithPathParameterOnCompInst(service, path, list);
- }
-
- public static RestResponse declareProporties(Component componentObject, Map<String, List<ComponentInstanceInput>> componentInstancesInputs, User sdncModifierDetails)
- throws Exception {
- Config config = Config.instance();
- String url = String.format(Urls.DECLARE_PROPERTIES, config.getCatalogBeHost(), config.getCatalogBePort(), ComponentTypeEnum.findParamByType(componentObject.getComponentType()), componentObject.getUniqueId());
- String userId = sdncModifierDetails.getUserId();
- Map<String, String> headersMap = prepareHeadersMap(userId);
- Map<String, Object> jsonBuilder = new HashMap<>();
- jsonBuilder.put("componentInstanceInputsMap", componentInstancesInputs);
- Gson gson = new Gson();
- String userBodyJson = gson.toJson(jsonBuilder);
- String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
- headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
- HttpRequest http = new HttpRequest();
- // System.out.println(url);
- // System.out.println(userBodyJson);
- RestResponse declareProportiesResponse = http.httpSendPost(url, userBodyJson, headersMap);
- if (declareProportiesResponse.getErrorCode() == STATUS_CODE_GET_SUCCESS) {
-
- }
- return declareProportiesResponse;
- }
-
- public static RestResponse updateInput(Component componentObject, PropertyObject componentInput, User sdncModifierDetails)
- throws Exception {
- Config config = Config.instance();
- String url = String.format(Urls.UPDATE_INPUT, config.getCatalogBeHost(), config.getCatalogBePort(), componentObject.getUniqueId());
- String userId = sdncModifierDetails.getUserId();
- Map<String, String> headersMap = prepareHeadersMap(userId);
- Gson gson = new Gson();
- String userBodyJson = gson.toJson(componentInput);
- String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
- headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
- HttpRequest http = new HttpRequest();
- // System.out.println(url);
- // System.out.println(userBodyJson);
- RestResponse declareProportiesResponse = http.httpSendPost(url, userBodyJson, headersMap);
- if (declareProportiesResponse.getErrorCode() == STATUS_CODE_GET_SUCCESS) {
-
- }
- return declareProportiesResponse;
- }
+ private static Logger logger = LoggerFactory.getLogger(PropertyRestUtils.class.getName());
+
+ public static RestResponse createProperty(String resourceId, String body, User user) throws Exception {
+ Config config = Config.instance();
+ String url = String.format(Urls.CREATE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId);
+
+ return sendPost(url, body, user.getUserId(), acceptHeaderData);
+ }
+
+ public static RestResponse updateProperty(String resourceId, String propertyId, String body, User user)
+ throws Exception {
+ Config config = Config.instance();
+
+ String url = String.format(Urls.UPDATE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(),
+ resourceId, propertyId);
+ return sendPut(url, body, user.getUserId(), acceptHeaderData);
+ }
+
+ public static RestResponse updateGroupProperty(Component component, String groupId, String body, User user)
+ throws Exception {
+ Config config = Config.instance();
+
+ String url = String.format(Urls.RESOURCE_GROUP_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), groupId);
+ return sendPut(url, body, user.getUserId(), acceptHeaderData);
+ }
+
+ public static RestResponse getProperty(String resourceId, String propertyId, User user) throws Exception {
+ Config config = Config.instance();
+ String url = String.format(Urls.GET_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId,
+ propertyId);
+ return sendGet(url, user.getUserId());
+ }
+
+ public static RestResponse deleteProperty(String resourceId, String propertyId, User user) throws Exception {
+ Config config = Config.instance();
+ String url = String.format(Urls.DELETE_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(),
+ resourceId, propertyId);
+
+ return sendDelete(url, user.getUserId());
+ }
+
+ public static ComponentInstanceProperty getPropFromListByPropNameAndType(List<ComponentInstanceProperty> propList,
+ String propNameToUpdate, String propTypeToUpdate) {
+ for (ComponentInstanceProperty componentInstanceProperty : propList) {
+ if (componentInstanceProperty.getName().equals(propNameToUpdate)
+ && componentInstanceProperty.getType().equals(propTypeToUpdate)) {
+ return componentInstanceProperty;
+ }
+ }
+ return null;
+ }
+
+ public static ComponentInstanceProperty getPropFromListByPropNameTypeAndPath(
+ List<ComponentInstanceProperty> propList, String propNameToUpdate, String propTypeToUpdate,
+ List<String> path) {
+ for (ComponentInstanceProperty componentInstanceProperty : propList) {
+ if (componentInstanceProperty.getPath() == null) {
+ return getPropFromListByPropNameAndType(propList, propNameToUpdate, propTypeToUpdate);
+ }
+ if (componentInstanceProperty.getName().equals(propNameToUpdate)
+ && componentInstanceProperty.getType().equals(propTypeToUpdate)
+ && path.containsAll(componentInstanceProperty.getPath())) {
+ return componentInstanceProperty;
+ }
+ }
+ return null;
+ }
+
+ public static ComponentInstanceProperty getPropFromListByPropIdAndPath(List<ComponentInstanceProperty> propList,
+ String propId, List<String> path) {
+
+ for (ComponentInstanceProperty componentInstanceProperty : propList) {
+ if (path != null) {
+ if (componentInstanceProperty.getUniqueId().equals(propId)
+ && componentInstanceProperty.getPath().equals(path)) {
+ return componentInstanceProperty;
+ }
+ } else {
+ if (componentInstanceProperty.getUniqueId().equals(propId)) {
+ return componentInstanceProperty;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static void comparePropertyLists(List<ComponentInstanceProperty> expectedList,
+ List<ComponentInstanceProperty> actualList, Boolean isUpdate) {
+
+ assertTrue(
+ "list size are not equals, expected size is: " + expectedList.size() + " ,actual: " + actualList.size(),
+ expectedList.size() == actualList.size());
+ Boolean flag = false;
+ for (ComponentInstanceProperty expectedcompInstProp : expectedList) {
+ for (ComponentInstanceProperty actualcompInstProp : actualList) {
+ flag = comparePropertyObjects(expectedcompInstProp, actualcompInstProp, isUpdate);
+ if (flag) {
+ break;
+ }
+ }
+ }
+ // System.out.println("expected: " + expectedList + ", actual: " +
+ // actualList);
+ logger.debug("expected: {}, actual: {}", expectedList, actualList);
+ assertTrue("actual lists does not contain all uniqeIds", flag);
+ }
+
+ public static Boolean comparePropertyObjects(ComponentInstanceProperty expectedCompInstProp,
+ ComponentInstanceProperty actualCompInstProp, Boolean isUpdate) {
+ String uniqueId = expectedCompInstProp.getUniqueId();
+ String type = expectedCompInstProp.getType();
+ String defaulValue = expectedCompInstProp.getDefaultValue();
+ if (actualCompInstProp.getUniqueId().equals(uniqueId)
+ && actualCompInstProp.getPath().equals(expectedCompInstProp.getPath())) {
+ assertTrue("expected type is: " + type + " ,actual: " + actualCompInstProp.getType(),
+ actualCompInstProp.getType().equals(type));
+ if (defaulValue == null) {
+ assertTrue(
+ "expected defaulValue is: " + defaulValue + " ,actual: " + actualCompInstProp.getDefaultValue(),
+ actualCompInstProp.getDefaultValue() == defaulValue);
+ } else {
+ assertTrue(
+ "expected defaulValue is: " + defaulValue + " ,actual: " + actualCompInstProp.getDefaultValue(),
+ actualCompInstProp.getDefaultValue().equals(defaulValue));
+ }
+ if (isUpdate) {
+ assertTrue(
+ "actual [Value] parameter " + actualCompInstProp.getName()
+ + "should equal to expected [Value]: " + actualCompInstProp.getValue() + " ,Value: "
+ + actualCompInstProp.getValue(),
+ actualCompInstProp.getValue().equals(expectedCompInstProp.getValue()));
+ assertNotNull("valueId is null", actualCompInstProp.getValueUniqueUid());
+ } else {
+ if (defaulValue == null) {
+ assertTrue(
+ "actual [Value] parameter " + actualCompInstProp.getName()
+ + "should equal to expected [defaultValue]: " + actualCompInstProp.getValue()
+ + " ,defaultValue: " + actualCompInstProp.getDefaultValue(),
+ actualCompInstProp.getValue() == expectedCompInstProp.getDefaultValue());
+ } else {
+ assertTrue(
+ "actual [Value] parameter " + actualCompInstProp.getName()
+ + "should equal to expected [defaultValue]: " + actualCompInstProp.getValue()
+ + " ,defaultValue: " + actualCompInstProp.getDefaultValue(),
+ actualCompInstProp.getValue().equals(expectedCompInstProp.getDefaultValue()));
+ }
+ assertNull("valueId is not null", actualCompInstProp.getValueUniqueUid());
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public static List<ComponentInstanceProperty> addResourcePropertiesToList(Resource resource,
+ List<ComponentInstanceProperty> listToFill) {
+ for (PropertyDefinition prop : resource.getProperties()) {
+ listToFill.add(new ComponentInstanceProperty(prop, null, null));
+ }
+ return listToFill;
+ }
+
+ public static List<ComponentInstanceProperty> addComponentInstPropertiesToList(Component component,
+ List<ComponentInstanceProperty> listToFill, String componentId) {
+
+ if (componentId != null) {
+ List<ComponentInstanceProperty> list = component.getComponentInstancesProperties().get(componentId);
+ for (ComponentInstanceProperty prop : list) {
+ ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(prop, null, null);
+ componentInstanceProperty.setPath(prop.getPath());
+ componentInstanceProperty.setValueUniqueUid(prop.getValueUniqueUid());
+ componentInstanceProperty.setValue(prop.getValue());
+ listToFill.add(componentInstanceProperty);
+ }
+ } else {
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = component
+ .getComponentInstancesProperties();
+ for (Map.Entry<String, List<ComponentInstanceProperty>> componentInstanceProperties : componentInstancesProperties
+ .entrySet()) {
+ for (ComponentInstanceProperty prop : componentInstanceProperties.getValue()) {
+ ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty(prop, null,
+ null);
+ componentInstanceProperty.setPath(prop.getPath());
+ componentInstanceProperty.setValueUniqueUid(prop.getValueUniqueUid());
+ componentInstanceProperty.setValue(prop.getValue());
+ listToFill.add(componentInstanceProperty);
+ }
+ }
+ }
+
+ if (component.getComponentType().getValue().equals("Resource")) {
+ for (PropertyDefinition prop : ((Resource) component).getProperties()) {
+ listToFill.add(new ComponentInstanceProperty(prop, null, null));
+ }
+ }
+ return listToFill;
+ }
+
+ public static ComponentInstanceProperty getCompPropInstListByInstIdAndPropName(Component component,
+ ComponentInstance componentInstanceDetails, String name, String type) {
+ List<ComponentInstanceProperty> propList = component.getComponentInstancesProperties()
+ .get(componentInstanceDetails.getUniqueId());
+ if (propList != null) {
+ return getPropFromListByPropNameAndType(propList, name, type);
+ }
+ return null;
+ }
+
+ private static void updatePropertyListWithPathParameter(Resource resource, List<String> path,
+ List<ComponentInstanceProperty> expectedPropertyList) {
+ List<PropertyDefinition> propertyList = resource.getProperties();
+ for (PropertyDefinition propertyDefinition : propertyList) {
+ ComponentInstanceProperty propDetailsToRemove = PropertyRestUtils.getPropFromListByPropNameAndType(
+ expectedPropertyList, propertyDefinition.getName(), propertyDefinition.getType());
+ ComponentInstanceProperty propDetailsToAdd = propDetailsToRemove;
+ propDetailsToAdd.setPath(path);
+ expectedPropertyList.remove(propDetailsToRemove);
+ expectedPropertyList.add(propDetailsToAdd);
+ }
+ }
+
+ private static void updatePropertyListWithPathParameterOnCompInst(Service service, List<String> path,
+ List<ComponentInstanceProperty> expectedPropertyList) {
+ List<ComponentInstanceProperty> servicePropertyList = new ArrayList<>();
+ servicePropertyList = PropertyRestUtils.addComponentInstPropertiesToList(service, servicePropertyList,
+ path.get(0));
+
+ for (ComponentInstanceProperty serviceCompInstProperty : servicePropertyList) {
+ ComponentInstanceProperty propDetailsToRemove = PropertyRestUtils.getPropFromListByPropNameTypeAndPath(
+ expectedPropertyList, serviceCompInstProperty.getName(), serviceCompInstProperty.getType(),
+ serviceCompInstProperty.getPath());
+ ComponentInstanceProperty propDetailsToAdd = propDetailsToRemove;
+ List<String> tempPathList = new ArrayList<String>();
+ for (String tempPath : path) {
+ tempPathList.add(tempPath);
+ }
+ // path parameter can not contain the same service unique ID twice
+ if (propDetailsToAdd.getPath() != null
+ && !propDetailsToAdd.getPath().get(0).contains(service.getUniqueId())) {
+ if (!propDetailsToAdd.getPath().containsAll(tempPathList)) {
+ tempPathList.addAll(propDetailsToAdd.getPath());
+ }
+ }
+ propDetailsToAdd.setPath(tempPathList);
+ expectedPropertyList.remove(propDetailsToRemove);
+ expectedPropertyList.add(propDetailsToAdd);
+ }
+ }
+
+ public static void updatePropertyListWithPathOnResource(ComponentInstance componentInstDetails, Resource resource,
+ List<ComponentInstanceProperty> list, Component container) {
+ List<String> path = new ArrayList<>();
+ if (container != null) {
+ List<ComponentInstance> componentInstances = container.getComponentInstances();
+ for (ComponentInstance componentInstance : componentInstances) {
+ if (componentInstance.getNormalizedName().equals(componentInstDetails.getNormalizedName())) {
+ path.add(componentInstance.getUniqueId());
+ break;
+ }
+ }
+
+ } else {
+ path.add(componentInstDetails.getUniqueId());
+ }
+ updatePropertyListWithPathParameter(resource, path, list);
+ }
+
+ public static void updatePropertyListWithPathOnComponentInstance(ComponentInstance componentInstDetails,
+ Service service, List<ComponentInstanceProperty> list) {
+ List<String> path = new ArrayList<>();
+ path.add(componentInstDetails.getUniqueId());
+ updatePropertyListWithPathParameterOnCompInst(service, path, list);
+ }
+
+ public static RestResponse declareProporties(Component componentObject, Map<String, List<ComponentInstanceInput>> componentInstancesInputs, User sdncModifierDetails)
+ throws Exception {
+ Config config = Config.instance();
+ String url = String.format(Urls.DECLARE_PROPERTIES, config.getCatalogBeHost(), config.getCatalogBePort(), ComponentTypeEnum.findParamByType(componentObject.getComponentType()), componentObject.getUniqueId());
+ String userId = sdncModifierDetails.getUserId();
+ Map<String, String> headersMap = prepareHeadersMap(userId);
+ Map<String, Object> jsonBuilder = new HashMap<>();
+ jsonBuilder.put("componentInstanceInputsMap", componentInstancesInputs);
+ Gson gson = new Gson();
+ String userBodyJson = gson.toJson(jsonBuilder);
+ String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
+ headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
+ HttpRequest http = new HttpRequest();
+ // System.out.println(url);
+ // System.out.println(userBodyJson);
+ RestResponse declareProportiesResponse = http.httpSendPost(url, userBodyJson, headersMap);
+ if (declareProportiesResponse.getErrorCode() == STATUS_CODE_GET_SUCCESS) {
+
+ }
+ return declareProportiesResponse;
+ }
+
+ public static RestResponse updateInput(Component componentObject, PropertyObject componentInput, User sdncModifierDetails)
+ throws Exception {
+ Config config = Config.instance();
+ String url = String.format(Urls.UPDATE_INPUT, config.getCatalogBeHost(), config.getCatalogBePort(), componentObject.getUniqueId());
+ String userId = sdncModifierDetails.getUserId();
+ Map<String, String> headersMap = prepareHeadersMap(userId);
+ Gson gson = new Gson();
+ String userBodyJson = gson.toJson(componentInput);
+ String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
+ headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
+ HttpRequest http = new HttpRequest();
+ // System.out.println(url);
+ // System.out.println(userBodyJson);
+ RestResponse declareProportiesResponse = http.httpSendPost(url, userBodyJson, headersMap);
+ if (declareProportiesResponse.getErrorCode() == STATUS_CODE_GET_SUCCESS) {
+
+ }
+ return declareProportiesResponse;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java
index 599ce006fa..656ece54f0 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java
@@ -20,26 +20,16 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.resources.data.RelationshipInstData;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
@@ -56,10 +46,14 @@ import org.openecomp.sdc.common.util.GeneralUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
public class ResourceRestUtils extends BaseRestUtils {
private static Logger logger = LoggerFactory.getLogger(ResourceRestUtils.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java
index 76d2ededfc..f09b14cc62 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java
@@ -20,8 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
@@ -32,7 +31,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.common.util.GeneralUtility;
-import com.google.gson.Gson;
+import java.util.Map;
public class ResourceRestUtilsExternalAPI extends BaseRestUtils {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
index cbfc84d1cb..ec2121475e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
@@ -20,48 +20,66 @@
package org.openecomp.sdc.ci.tests.utils.rest;
+//import com.fasterxml.jackson.databind.DeserializationFeature;
+//import com.fasterxml.jackson.databind.ObjectMapper;
+//import com.fasterxml.jackson.databind.module.SimpleModule;
+//import com.google.gson.*;
+//import org.apache.commons.codec.binary.Base64;
+//import org.apache.log4j.Logger;
+//import org.codehaus.jackson.JsonNode;
+//
+//import org.json.JSONArray;
+//import org.json.JSONException;
+//import org.json.simple.JSONObject;
+//import org.json.simple.JSONValue;
+//import org.openecomp.sdc.be.model.*;
+//import org.openecomp.sdc.be.model.category.CategoryDefinition;
+//import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserializer;;
+//import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
+//import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure;
+//import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
+//import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
+//import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+//import org.openecomp.sdc.ci.tests.tosca.datatypes.VfModuleDefinition;
+//import org.openecomp.sdc.ci.tests.utils.Utils;
+//import org.yaml.snakeyaml.Yaml;
+//
+//import java.io.ByteArrayInputStream;
+//import java.io.IOException;
+//import java.io.InputStream;
+//import java.text.ParseException;
+//import java.util.*;
+
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.fasterxml.jackson.databind.module.SimpleModule;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import com.google.gson.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.PropertyConstraint;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserializer;
+import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure;
import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.VfModuleDefinition;
import org.openecomp.sdc.ci.tests.utils.Utils;
+import org.yaml.snakeyaml.Yaml;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+
+//import org.codehaus.jackson.JsonNode;
public class ResponseParser {
@@ -180,7 +198,7 @@ public class ResponseParser {
private static ObjectMapper newObjectMapper() {
SimpleModule module = new SimpleModule("customDeserializationModule");
- module.addDeserializer(PropertyConstraint.class, new PropertyConstraintJacksonDeserializer());
+ module.addDeserializer(PropertyConstraint.class, new PropertyOperation.PropertyConstraintJacksonDeserializer());
return new ObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.registerModule(module);
@@ -294,7 +312,7 @@ public class ResponseParser {
return artifactReqDetails;
}
- public static Service convertServiceResponseToJavaObject(String response) {
+ /*public static Service convertServiceResponseToJavaObject(String response) {
ObjectMapper mapper = newObjectMapper();
Service service = null;
@@ -306,8 +324,27 @@ public class ResponseParser {
}
return service;
+ }*/
+ public static Service convertServiceResponseToJavaObject(String response) {
+
+ ObjectMapper mapper = newObjectMapper();
+ Service service = null;
+ try {
+ service = mapper.readValue(response, Service.class);
+ logger.debug(service.toString());
+ //Temporary catch until bug with distribution status fixed
+ } catch (InvalidFormatException e) {
+ System.out.println("broken service with invalid distribution status : " + response);
+ logger.debug("broken service with invalid distribution status : " + response);
+ return service;
+ } catch(IOException e){
+
+ e.printStackTrace();
}
+ return service;
+}
+
public static Product convertProductResponseToJavaObject(String response) {
ObjectMapper mapper = newObjectMapper();
@@ -446,6 +483,68 @@ public class ResponseParser {
}
}
+// /*public static Map<String, List<Component>> convertCatalogResponseToJavaObject(String response) {
+//
+// // Map<String, ArrayList<Component>> map = new HashMap<String,
+// // ArrayList<Component>>();
+// Map<String, List<Component>> map = new HashMap<>();
+//
+// JsonElement jElement = new JsonParser().parse(response);
+// JsonObject jObject = jElement.getAsJsonObject();
+// JsonArray jArrReousrces = jObject.getAsJsonArray("resources");
+// JsonArray jArrServices = jObject.getAsJsonArray("services");
+// //Product removed
+//// JsonArray jArrProducts = jObject.getAsJsonArray("products");
+// //Product removed
+// if (jArrReousrces != null && jArrServices != null /*&& jArrProducts != null*/){
+//
+//
+// //////// RESOURCE/////////////////////////////
+// ArrayList<Component> restResponseArray = new ArrayList<>();
+// Component component = null;
+// for (int i = 0; i < jArrReousrces.size(); i++) {
+// String resourceString = (String) jArrReousrces.get(i).toString();
+// component = ResponseParser.convertResourceResponseToJavaObject(resourceString);
+// restResponseArray.add(component);
+// }
+//
+// map.put("resources", restResponseArray);
+//
+// ///////// SERVICE/////////////////////////////
+//
+// restResponseArray = new ArrayList<>();
+// component = null;
+// for (int i = 0; i < jArrServices.size(); i++) {
+// String resourceString = (String) jArrServices.get(i).toString();
+// component = ResponseParser.convertServiceResponseToJavaObject(resourceString);
+// restResponseArray.add(component);
+// }
+//
+// map.put("services", restResponseArray);
+////Product removed
+// ///////// PRODUCT/////////////////////////////
+//// restResponseArray = new ArrayList<>();
+//// component = null;
+//// for (int i = 0; i < jArrProducts.size(); i++) {
+//// String resourceString = (String) jArrProducts.get(i).toString();
+//// component = ResponseParser.convertProductResponseToJavaObject(resourceString);
+//// restResponseArray.add(component);
+//// }
+////
+//// map.put("products", restResponseArray);
+////
+// }
+// else {
+// map.put("resources", new ArrayList<>());
+// map.put("services", new ArrayList<>());
+// //Product removed
+//// map.put("products", new ArrayList<>());
+// }
+//
+// return map;
+//
+// }*/
+
public static Map<String, List<Component>> convertCatalogResponseToJavaObject(String response) {
// Map<String, ArrayList<Component>> map = new HashMap<String,
@@ -456,57 +555,63 @@ public class ResponseParser {
JsonObject jObject = jElement.getAsJsonObject();
JsonArray jArrReousrces = jObject.getAsJsonArray("resources");
JsonArray jArrServices = jObject.getAsJsonArray("services");
- JsonArray jArrProducts = jObject.getAsJsonArray("products");
-
+ //Product removed
+// JsonArray jArrProducts = jObject.getAsJsonArray("products");
+ //Product removed
+ if (jArrReousrces != null && jArrServices != null /*&& jArrProducts != null*/){
- //////// RESOURCE/////////////////////////////
- ArrayList<Component> restResponseArray = new ArrayList<>();
- Component component = null;
- if (jArrReousrces != null) {
- for (int i = 0; i < jArrReousrces.size(); i++) {
+ //////// RESOURCE/////////////////////////////
+ ArrayList<Component> restResponseArray = new ArrayList<>();
+ Component component = null;
+ for (int i = 0; i < jArrReousrces.size(); i++) {
String resourceString = (String) jArrReousrces.get(i).toString();
component = ResponseParser.convertResourceResponseToJavaObject(resourceString);
restResponseArray.add(component);
- }
-
+ }
- } map.put("resources", restResponseArray);
+ map.put("resources", restResponseArray);
+ ///////// SERVICE/////////////////////////////
- ///////// SERVICE/////////////////////////////
- restResponseArray = new ArrayList<>();
- component = null;
- if (jArrServices != null ) {
- for (int i = 0; i < jArrServices.size(); i++) {
+ restResponseArray = new ArrayList<>();
+ component = null;
+ for (int i = 0; i < jArrServices.size(); i++) {
String resourceString = (String) jArrServices.get(i).toString();
component = ResponseParser.convertServiceResponseToJavaObject(resourceString);
restResponseArray.add(component);
- }
-
+ }
- } map.put("services", restResponseArray);
+ map.put("services", restResponseArray);
+//Product removed
+ ///////// PRODUCT/////////////////////////////
+// restResponseArray = new ArrayList<>();
+// component = null;
+// for (int i = 0; i < jArrProducts.size(); i++) {
+// String resourceString = (String) jArrProducts.get(i).toString();
+// component = ResponseParser.convertProductResponseToJavaObject(resourceString);
+// restResponseArray.add(component);
+// }
+//
- ///////// PRODUCT/////////////////////////////
- restResponseArray = new ArrayList<>();
- component = null;
- if ( jArrProducts != null){
- for (int i = 0; i < jArrProducts.size(); i++) {
- String resourceString = (String) jArrProducts.get(i).toString();
- component = ResponseParser.convertProductResponseToJavaObject(resourceString);
- restResponseArray.add(component);
- }
- } map.put("products", restResponseArray);
+// map.put("products", restResponseArray);
+//
+ }
+ else {
+ map.put("resources", new ArrayList<>());
+ map.put("services", new ArrayList<>());
+ //Product removed
+// map.put("products", new ArrayList<>());
+ }
return map;
}
-
public static Map<Long, ServiceDistributionStatus> convertServiceDistributionStatusToObject(String response) throws ParseException {
Map<Long, ServiceDistributionStatus> serviceDistributionStatusMap = new HashMap<>();
@@ -555,5 +660,24 @@ public class ResponseParser {
return null;
}
-
+
+ public static Map<String, VfModuleDefinition> convertVfModuleJsonResponseToJavaObject(String response) {
+
+ Yaml yaml = new Yaml();
+ InputStream inputStream = null;
+ inputStream = new ByteArrayInputStream(response.getBytes());
+ List<?> list = (List<?> )yaml.load(inputStream);
+ ObjectMapper mapper = new ObjectMapper();
+
+ VfModuleDefinition moduleDefinition;
+ Map<String, VfModuleDefinition> vfModulesMap = new HashMap<>();
+ for (Object obj : list) {
+// TODO Andrey L. uncomment line below in case to ignore on unknown properties, not recommended
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ moduleDefinition = mapper.convertValue(obj, VfModuleDefinition.class);
+ vfModulesMap.put(moduleDefinition.vfModuleModelName, moduleDefinition);
+ }
+ return vfModulesMap;
+ }
+
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
index 1d8aef6f04..88666cce11 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
@@ -20,10 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
@@ -41,7 +38,9 @@ import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
public class ServiceRestUtils extends BaseRestUtils {
private static Logger logger = LoggerFactory.getLogger(ServiceRestUtils.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java
index 5031391fe4..1a5136ef05 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java
@@ -20,10 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.Urls;
@@ -36,7 +33,9 @@ import org.openecomp.sdc.ci.tests.utils.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
public class UserRestUtils extends BaseRestUtils {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java
index 61d340094d..9bfcfcf962 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ArtifactValidationUtils.java
@@ -43,7 +43,6 @@ import java.util.Map;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.assertTrue;
public class ArtifactValidationUtils {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java
index 5f5afb2126..03d364a26f 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java
@@ -20,18 +20,8 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
+import com.datastax.driver.core.ColumnDefinitions;
+import com.datastax.driver.core.Row;
import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
@@ -53,15 +43,7 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.AuditEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.AuditJsonKeysEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ComponentType;
import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedAuthenticationAudit;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedCategoryAudit;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedDistDownloadAudit;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedEcomConsumerAudit;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedExternalAudit;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedGetUserListAudit;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedProductAudit;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaObject;
-import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedUserCRUDAudit;
+import org.openecomp.sdc.ci.tests.datatypes.expected.*;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.run.StartTest;
@@ -72,10 +54,14 @@ import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils.CategoryAuditJson
import org.openecomp.sdc.ci.tests.utils.rest.ConsumerRestUtils.EcompConsumerAuditJsonKeysEnum;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.Row;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.*;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
public class AuditValidationUtils {
protected static Logger logger = Logger.getLogger(AuditValidationUtils.class.getName());
@@ -164,7 +150,7 @@ public class AuditValidationUtils {
validateAtifactDataField(actualAuditRecords, AuditJsonKeysEnum.ARTIFACT_DATA.getAuditJsonKeyName(), resourceAuditJavaObject.getArtifactData(), checkAllFields);
}
- public static void validateExternalAudit(ExpectedExternalAudit externalAuditObject, String action, Map<AuditingFieldsKeysEnum, String> body) throws Exception {
+ public static void validateExternalAudit(ExpectedExternalAudit externalAuditObject, String action, Map<AuditingFieldsKey, String> body) throws Exception {
Map<String, Object> actualAuditRecord = parseAuditResourceByAction(action, body);
@@ -415,7 +401,7 @@ public class AuditValidationUtils {
validateField(map2, AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), expectedDistDownloadAudit.getResourceUrl());
}
- public static void validateAuditExternalSearchAPI(ExpectedExternalAudit expectedDistDownloadAudit, String action, Map<AuditingFieldsKeysEnum, String> body)
+ public static void validateAuditExternalSearchAPI(ExpectedExternalAudit expectedDistDownloadAudit, String action, Map<AuditingFieldsKey, String> body)
throws Exception {
Map<String, Object> map2 = parseAuditResourceByAction(action, body);
@@ -427,7 +413,7 @@ public class AuditValidationUtils {
validateField(map2, AuditJsonKeysEnum.RESOURCE_URL.getAuditJsonKeyName(), expectedDistDownloadAudit.getRESOURCE_URL());
}
- public static void validateAuditExternalCreateResource(ExpectedResourceAuditJavaObject expectedExternalAudit, String action, Map<AuditingFieldsKeysEnum, String> body) throws Exception {
+ public static void validateAuditExternalCreateResource(ExpectedResourceAuditJavaObject expectedExternalAudit, String action, Map<AuditingFieldsKey, String> body) throws Exception {
Map<String, Object> map2 = parseAuditResourceByAction(action, body);
validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action);
@@ -446,7 +432,7 @@ public class AuditValidationUtils {
validateField(map2, AuditJsonKeysEnum.DESCRIPTION.getAuditJsonKeyName(), expectedExternalAudit.getDesc());
}
- public static void validateAuditExternalChangeAssetLifeCycle(ExpectedResourceAuditJavaObject expectedExternalAudit, String action, Map<AuditingFieldsKeysEnum, String> body) throws Exception {
+ public static void validateAuditExternalChangeAssetLifeCycle(ExpectedResourceAuditJavaObject expectedExternalAudit, String action, Map<AuditingFieldsKey, String> body) throws Exception {
Map<String, Object> map2 = parseAuditResourceByAction(action, body);
validateField(map2, AuditJsonKeysEnum.ACTION.getAuditJsonKeyName(), action);
@@ -605,7 +591,7 @@ public class AuditValidationUtils {
//
// }
- public static Map<String, Object> parseAuditResourceByAction(String action, Map<AuditingFieldsKeysEnum, String> body) throws Exception {
+ public static Map<String, Object> parseAuditResourceByAction(String action, Map<AuditingFieldsKey, String> body) throws Exception {
Map auditingMessage = null;
auditingMessage = retrieveAuditMessagesByPattern(action, body, false);
@@ -614,7 +600,7 @@ public class AuditValidationUtils {
}
public static List<Map<String, Object>> parseAuditResourceByActionToList(String action,
- Map<AuditingFieldsKeysEnum, String> body) throws Exception {
+ Map<AuditingFieldsKey, String> body) throws Exception {
Map auditingMessage = null;
@@ -673,20 +659,20 @@ public class AuditValidationUtils {
return restResponse.getResponse();
}
- public static Map<String, String> retrieveAuditMessagesByPattern(String action, Map<AuditingFieldsKeysEnum, String> body, Boolean retryFlag)
+ public static Map<String, String> retrieveAuditMessagesByPattern(String action, Map<AuditingFieldsKey, String> body, Boolean retryFlag)
throws IOException {
// get cassandra table name by action
- String esType = AuditingActionEnum.getActionByName(action).getAuditingEsType();
+ String esType = AuditingActionEnum.fromName(action).getAuditingEsType();
Map<String, String> resultsMap = new HashMap<String, String>();
- List<Pair<AuditingFieldsKeysEnum, String>> myFields = new ArrayList<Pair<AuditingFieldsKeysEnum, String>>();
- Pair<AuditingFieldsKeysEnum, String> myPair = new Pair<AuditingFieldsKeysEnum, String>(
- AuditingFieldsKeysEnum.AUDIT_ACTION, action);
+ List<Pair<AuditingFieldsKey, String>> myFields = new ArrayList<Pair<AuditingFieldsKey, String>>();
+ Pair<AuditingFieldsKey, String> myPair = new Pair<AuditingFieldsKey, String>(
+ AuditingFieldsKey.AUDIT_ACTION, action);
myFields.add(0, myPair);
if (body != null && !body.isEmpty()) {
- for (Map.Entry<AuditingFieldsKeysEnum, String> mapElement : body.entrySet()) {
- myFields.add(new Pair<AuditingFieldsKeysEnum, String>(mapElement.getKey(), mapElement.getValue()));
+ for (Map.Entry<AuditingFieldsKey, String> mapElement : body.entrySet()) {
+ myFields.add(new Pair<AuditingFieldsKey, String>(mapElement.getKey(), mapElement.getValue()));
}
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/BaseValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/BaseValidationUtils.java
index eb3ee331ed..b29fab4c57 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/BaseValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/BaseValidationUtils.java
@@ -20,11 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.io.FileNotFoundException;
-import java.util.Arrays;
-
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
@@ -32,6 +27,11 @@ import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.openecomp.sdc.exception.ResponseFormat;
import org.testng.Assert;
+import java.io.FileNotFoundException;
+import java.util.Arrays;
+
+import static org.testng.AssertJUnit.assertEquals;
+
public class BaseValidationUtils {
public static final int STATUS_CODE_SUCCESS = 200;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CategoryValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CategoryValidationUtils.java
index cd2297fd19..71a19eaa06 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CategoryValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CategoryValidationUtils.java
@@ -20,10 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
import org.json.JSONObject;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.GroupingDefinition;
@@ -31,6 +27,8 @@ import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils;
+import static org.testng.AssertJUnit.*;
+
public class CategoryValidationUtils {
public static void verifyCategoryExistInGetResponse(RestResponse getAllCategoryRest,
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java
index 12a5ab8082..d85e093c17 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/CsarValidationUtils.java
@@ -20,17 +20,17 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition;
import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition;
import org.openecomp.sdc.ci.tests.utils.CsarParserUtils;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.AssertJUnit.assertTrue;
+
public class CsarValidationUtils {
public static void validateCsarVfArtifact(String csarUUID, Resource resource) throws Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/DistributionValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/DistributionValidationUtils.java
index 46948d8f5b..b6b809a4a3 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/DistributionValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/DistributionValidationUtils.java
@@ -20,7 +20,10 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertNotNull;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.ci.tests.utils.DistributionUtils;
+import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
import java.io.IOException;
import java.text.ParseException;
@@ -29,10 +32,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.ci.tests.utils.DistributionUtils;
-import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
+import static org.testng.AssertJUnit.assertNotNull;
public class DistributionValidationUtils {
@@ -46,10 +46,10 @@ public class DistributionValidationUtils {
}
for (String distributionStatusList : distributionStatusEnumList){
for (Entry<String, String> url : expectedArtifactsMapOfDistributedService.entrySet()){
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_ID, distributionID);
- body.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL, url.getValue());
- body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, distributionStatusList);
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID, distributionID);
+ body.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL, url.getValue());
+ body.put(AuditingFieldsKey.AUDIT_STATUS, distributionStatusList);
Map<String, String> actualAuditRecord = new HashMap<String, String>();
actualAuditRecord = AuditValidationUtils.retrieveAuditMessagesByPattern(action, body, true);
while (timer != 0) {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ErrorValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ErrorValidationUtils.java
index ccddc30d6a..4c5533945b 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ErrorValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ErrorValidationUtils.java
@@ -20,15 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.openecomp.sdc.ci.tests.config.Config;
@@ -39,6 +30,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
+
public class ErrorValidationUtils {
static Logger logger = LoggerFactory.getLogger(ErrorValidationUtils.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ProductValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ProductValidationUtils.java
index ba5114c1bc..18c9f9f4c0 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ProductValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ProductValidationUtils.java
@@ -20,15 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
import org.apache.log4j.Logger;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -43,6 +34,13 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.testng.AssertJUnit.*;
+
public class ProductValidationUtils {
static Logger logger = Logger.getLogger(ProductValidationUtils.class.getName());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ResourceValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ResourceValidationUtils.java
index 07f2ef8188..de6d32beed 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ResourceValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ResourceValidationUtils.java
@@ -20,17 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.gson.Gson;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Operation;
@@ -42,7 +32,10 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.RespJsonKeysEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import com.google.gson.Gson;
+import java.util.*;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
public class ResourceValidationUtils {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ServiceValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ServiceValidationUtils.java
index 2f8a0dffc4..6c9b839150 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ServiceValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/ServiceValidationUtils.java
@@ -20,13 +20,6 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
import org.openecomp.sdc.be.model.DistributionStatusEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.Service;
@@ -36,6 +29,13 @@ import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedResourceAuditJavaOb
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+
public class ServiceValidationUtils {
public static void validateServiceResponseMetaData(ServiceReqDetails serviceDetails, Service service, User user,
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/UserValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/UserValidationUtils.java
index a75434edcf..58fd4f05d3 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/UserValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/UserValidationUtils.java
@@ -20,11 +20,7 @@
package org.openecomp.sdc.ci.tests.utils.validation;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.List;
-
+import com.google.gson.*;
import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
import org.openecomp.sdc.be.model.User;
@@ -36,11 +32,10 @@ import org.openecomp.sdc.ci.tests.users.UserAuditJavaObject;
import org.openecomp.sdc.ci.tests.utils.DbUtils;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import java.util.List;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
public class UserValidationUtils {
public static void compareExpectedAndActualUsers(User expected, User actual) {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java
index 91effad4c4..2cea226c4b 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/AssetLifeCycle.java
@@ -47,8 +47,9 @@ import org.testng.SkipException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-public class AssetLifeCycle extends ComponentBaseTest {
+import java.io.FileNotFoundException;
+public class AssetLifeCycle extends ComponentBaseTest {
private static Logger log = LoggerFactory.getLogger(CRUDExternalAPI.class.getName());
protected static final String UPLOAD_ARTIFACT_PAYLOAD = "UHVUVFktVXNlci1LZXktRmlsZS0yOiBzc2gtcnNhDQpFbmNyeXB0aW9uOiBhZXMyNTYtY2JjDQpDb21tZW5wOA0K";
protected static final String UPLOAD_ARTIFACT_NAME = "TLV_prv.ppk";
@@ -67,34 +68,33 @@ public class AssetLifeCycle extends ComponentBaseTest {
protected User sdncUserDetails;
protected ServiceReqDetails serviceDetails;
- public static final int STATUS_CODE_SUCCESS = 200;
- public static final int STATUS_CODE_CREATED = 201;
- public static final int STATUS_CODE_DELETE = 204;
- public static final int STATUS_CODE_NOT_FOUND = 404;
- public static final int STATUS_CODE_SUCCESS_NO_CONTENT = 204;
- public static final int STATUS_CODE_SUCCESS_DELETE = 204;
- public static final int STATUS_CODE_INVALID_CONTENT = 400;
- public static final int STATUS_CODE_MISSING_DATA = 400;
- public static final int STATUS_CODE_MISSING_INFORMATION = 403;
- public static final int STATUS_CODE_RESTRICTED_ACCESS = 403;
- public static final int STATUS_CODE_ALREADY_EXISTS = 409;
- public static final int STATUS_CODE_RESTRICTED_OPERATION = 409;
- public static final int STATUS_CODE_COMPONENT_NAME_EXCEEDS_LIMIT = 400;
- public static final int STATUS_CODE_MISSING_COMPONENT_NAME = 400;
- public static final int STATUS_CODE_UNSUPPORTED_ERROR = 400;
- public static final int STATUS_CODE_IMPORT_SUCCESS = 201;
- public static final int STATUS_CODE_UPDATE_SUCCESS = 200;
- public static final int RESTRICTED_OPERATION = 409;
- public static final int STATUS_CODE_GET_SUCCESS = 200;
- public static final int COMPONENT_IN_CHECKOUT_STATE = 403;
- public static final int COMPONENT_ALREADY_CHECKED_IN = 409;
- public static final int COMPONENT_NOT_READY_FOR_CERTIFICATION = 403;
- public static final int COMPONENT_SENT_FOR_CERTIFICATION = 403;
- public static final int COMPONENT_IN_CERT_IN_PROGRESS_STATE = 403;
- public static final int COMPONENT_ALREADY_CERTIFIED = 403;
-
+ public static final int STATUS_CODE_SUCCESS = getResponseCodeByAction(ActionStatus.OK);
+ public static final int STATUS_CODE_CREATED = getResponseCodeByAction(ActionStatus.CREATED);
+ public static final int STATUS_CODE_NOT_FOUND = getResponseCodeByAction(ActionStatus.RESOURCE_NOT_FOUND);
+ public static final int STATUS_CODE_INVALID_CONTENT = getResponseCodeByAction(ActionStatus.INVALID_CONTENT);
+ public static final int STATUS_CODE_MISSING_INFORMATION = getResponseCodeByAction(ActionStatus.MISSING_INFORMATION);
+ public static final int STATUS_CODE_ALREADY_EXISTS = getResponseCodeByAction(ActionStatus.RESOURCE_ALREADY_EXISTS);
+ public static final Integer RESTRICTED_OPERATION = getResponseCodeByAction(ActionStatus.RESTRICTED_OPERATION);
+ public static final int COMPONENT_IN_CHECKOUT_STATE = getResponseCodeByAction(ActionStatus.COMPONENT_IN_CHECKOUT_STATE);
+ public static final int COMPONENT_ALREADY_CHECKED_IN = getResponseCodeByAction(ActionStatus.COMPONENT_ALREADY_CHECKED_IN);
+ public static final int COMPONENT_NOT_READY_FOR_CERTIFICATION = getResponseCodeByAction(ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION);
+ public static final int COMPONENT_SENT_FOR_CERTIFICATION = getResponseCodeByAction(ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION);
+ public static final int COMPONENT_IN_CERT_IN_PROGRESS_STATE = getResponseCodeByAction(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE);
+ public static final int COMPONENT_ALREADY_CERTIFIED = getResponseCodeByAction(ActionStatus.COMPONENT_ALREADY_CERTIFIED);
+
+ public static int getResponseCodeByAction(ActionStatus actionStatus ){
+ ErrorInfo errorInfo;
+ try {
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(actionStatus.name());
+ return errorInfo.getCode();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ return 100500;
+ }
+
@Rule
public static TestName name = new TestName();
@@ -196,10 +196,10 @@ public class AssetLifeCycle extends ComponentBaseTest {
{AssetTypeEnum.RESOURCES, LifeCycleStatesEnum.CHECKOUT},
{AssetTypeEnum.SERVICES, LifeCycleStatesEnum.CERTIFICATIONREQUEST},
- {AssetTypeEnum.RESOURCES, LifeCycleStatesEnum.CERTIFICATIONREQUEST},
+ /*{AssetTypeEnum.RESOURCES, LifeCycleStatesEnum.CERTIFICATIONREQUEST},*/
{AssetTypeEnum.SERVICES, LifeCycleStatesEnum.STARTCERTIFICATION},
- {AssetTypeEnum.RESOURCES, LifeCycleStatesEnum.STARTCERTIFICATION},
+ /*{AssetTypeEnum.RESOURCES, LifeCycleStatesEnum.STARTCERTIFICATION},*/
};
}
@@ -230,10 +230,10 @@ public class AssetLifeCycle extends ComponentBaseTest {
restResponse = LifecycleRestUtils.checkInResource(assetUUID, defaultUser);
} else if(lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CHECKOUT)) {
restResponse = LifecycleRestUtils.checkOutResource(assetUUID, defaultUser);
- } else if(lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CERTIFICATIONREQUEST)) {
+ /*} else if(lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CERTIFICATIONREQUEST)) {
restResponse = LifecycleRestUtils.certificationRequestResource(assetUUID, defaultUser);
} else if(lifeCycleStatesEnum.equals(LifeCycleStatesEnum.STARTCERTIFICATION)) {
- restResponse = LifecycleRestUtils.startTestingResource(assetUUID, defaultUser);
+ restResponse = LifecycleRestUtils.startTestingResource(assetUUID, defaultUser);*/
}
errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name());
@@ -241,16 +241,6 @@ public class AssetLifeCycle extends ComponentBaseTest {
}
Assert.assertEquals(restResponse.getErrorCode(), (Integer)STATUS_CODE_NOT_FOUND, "Asset found.");
- /* // auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", assetTypeEnum.getValue().toLowerCase(), assetUUID, lifeCycleStatesEnum.getState()));
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultInvalidChangeAssetLifeCycleExternalAPI(assetUUID, defaultUser, lifeCycleStatesEnum, assetTypeEnum);
-
- List<String> variables = asList(assetUUID);
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
-
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -272,21 +262,9 @@ public class AssetLifeCycle extends ComponentBaseTest {
@Test(dataProvider="invalidUserCheckinForCheckedOutService")
public void invalidUserCheckinForCheckedOutService(User defaultUser) throws Exception {
Component resourceDetails = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
-
RestResponse restResponse = LifecycleRestUtils.checkInService(resourceDetails.getUUID(), defaultUser);
- Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation.");
+ Assert.assertEquals(restResponse.getErrorCode(), RESTRICTED_OPERATION, "Expected for restricted operation.");
- /*// auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.SERVICES);
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
- expectedResourceAuditJavaObject.setStatus("409");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList("");
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@DataProvider(name="invalidUserCheckinForCheckedInService")
@@ -309,22 +287,9 @@ public class AssetLifeCycle extends ComponentBaseTest {
Either<Service, RestResponse> createdComponent = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true);
resourceDetails = createdComponent.left().value();
resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
-
RestResponse restResponse = LifecycleRestUtils.checkInService(resourceDetails.getUUID(), defaultUser);
- Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation.");
+ Assert.assertEquals(restResponse.getErrorCode(), RESTRICTED_OPERATION, "Expected for restricted operation.");
- /*// auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.SERVICES);
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setStatus("409");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList("");
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@DataProvider(name="invalidUserCheckoutForCheckedOutService")
@@ -346,19 +311,8 @@ public class AssetLifeCycle extends ComponentBaseTest {
Component resourceDetails = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
RestResponse restResponse = LifecycleRestUtils.checkOutService(resourceDetails.getUUID(), defaultUser);
- Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation.");
+ Assert.assertEquals(restResponse.getErrorCode(), RESTRICTED_OPERATION, "Expected for restricted operation.");
- /* // auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKOUT, AssetTypeEnum.SERVICES);
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
- expectedResourceAuditJavaObject.setStatus("409");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList("");
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@DataProvider(name="invalidUserCheckoutForCheckedInService")
@@ -379,22 +333,9 @@ public class AssetLifeCycle extends ComponentBaseTest {
public void invalidUserCheckoutForCheckedInService(User defaultUser) throws Exception {
Component resourceDetails = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
-
RestResponse restResponse = LifecycleRestUtils.checkOutService(resourceDetails.getUUID(), defaultUser);
- Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation.");
+ Assert.assertEquals(restResponse.getErrorCode(), RESTRICTED_OPERATION, "Expected for restricted operation.");
- /* // auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKOUT, AssetTypeEnum.SERVICES);
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setStatus("409");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList("");
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@DataProvider(name="invalidUserCheckinForCheckedOutResource")
@@ -416,19 +357,8 @@ public class AssetLifeCycle extends ComponentBaseTest {
Component resourceDetails = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true).left().value();
RestResponse restResponse = LifecycleRestUtils.checkInResource(resourceDetails.getUUID(), defaultUser);
- Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation.");
+ Assert.assertEquals(restResponse.getErrorCode(), RESTRICTED_OPERATION, "Expected for restricted operation.");
- /*// auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
- expectedResourceAuditJavaObject.setStatus("409");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList("");
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@DataProvider(name="invalidUserCheckinForCheckedInResource")
@@ -453,20 +383,7 @@ public class AssetLifeCycle extends ComponentBaseTest {
resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
RestResponse restResponse = LifecycleRestUtils.checkInResource(resourceDetails.getUUID(), defaultUser);
- Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation.");
-
- /*// auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setStatus("409");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList("");
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
+ Assert.assertEquals(restResponse.getErrorCode(), RESTRICTED_OPERATION, "Expected for restricted operation.");
}
@DataProvider(name="invalidUserCheckoutForCheckedOutResource")
@@ -488,19 +405,8 @@ public class AssetLifeCycle extends ComponentBaseTest {
Component resourceDetails = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true).left().value();
RestResponse restResponse = LifecycleRestUtils.checkOutResource(resourceDetails.getUUID(), defaultUser);
- Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation.");
+ Assert.assertEquals(restResponse.getErrorCode(), RESTRICTED_OPERATION, "Expected for restricted operation.");
- /*// auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKOUT, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
- expectedResourceAuditJavaObject.setStatus("409");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList("");
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@DataProvider(name="invalidUserCheckoutForCheckedInResource")
@@ -524,20 +430,8 @@ public class AssetLifeCycle extends ComponentBaseTest {
resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
RestResponse restResponse = LifecycleRestUtils.checkOutResource(resourceDetails.getUUID(), defaultUser);
- Assert.assertEquals(restResponse.getErrorCode(), (Integer)RESTRICTED_OPERATION, "Expected for restricted operation.");
+ Assert.assertEquals(restResponse.getErrorCode(), RESTRICTED_OPERATION, "Expected for restricted operation.");
- /*// auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CHECKOUT, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setStatus("409");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList("");
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -589,91 +483,50 @@ public class AssetLifeCycle extends ComponentBaseTest {
Either<Service, RestResponse> createdComponent = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true);
- Component resourceDetails = createdComponent.left().value();
+ Component service = createdComponent.left().value();
- resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, UserRoleEnum.DESIGNER, initState, true).getLeft();
+ service = AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, initState, true).getLeft();
RestResponse restResponse = null;
if(targetState.equals(LifeCycleStatesEnum.CHECKOUT)) {
- restResponse = LifecycleRestUtils.checkOutService(resourceDetails.getUUID(), user);
+ restResponse = LifecycleRestUtils.checkOutService(service.getUUID(), user);
} else if(targetState.equals(LifeCycleStatesEnum.CHECKIN)) {
- restResponse = LifecycleRestUtils.checkInService(resourceDetails.getUUID(), user);
+ restResponse = LifecycleRestUtils.checkInService(service.getUUID(), user);
} else if(targetState.equals(LifeCycleStatesEnum.CERTIFICATIONREQUEST)) {
- restResponse = LifecycleRestUtils.certificationRequestService(resourceDetails.getUUID(), user);
+ restResponse = LifecycleRestUtils.certificationRequestService(service.getUUID(), user);
} else if(targetState.equals(LifeCycleStatesEnum.STARTCERTIFICATION)) {
- restResponse = LifecycleRestUtils.startTestingService(resourceDetails.getUUID(), user);
+ restResponse = LifecycleRestUtils.startTestingService(service.getUUID(), user);
} else if(targetState.equals(LifeCycleStatesEnum.CERTIFY)) {
- restResponse = LifecycleRestUtils.certifyService(resourceDetails.getUUID(), user);
+ restResponse = LifecycleRestUtils.certifyService(service.getUUID(), user);
}
Assert.assertEquals(restResponse.getErrorCode(), (Integer)errorCode, "Expected that response code will be equal.");
- /*// auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, user, targetState, AssetTypeEnum.SERVICES);
- if(initState.equals(LifeCycleStatesEnum.CERTIFY)) {
- expectedResourceAuditJavaObject.setCurrVersion("1.0");
- expectedResourceAuditJavaObject.setPrevVersion("1.0");
- }
- expectedResourceAuditJavaObject.setPrevState(preState.toString());
- expectedResourceAuditJavaObject.setCurrState(currState.toString());
- expectedResourceAuditJavaObject.setStatus(status);
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(actionStatus.name());
- List<String> variables = null;
- if(ActionStatus.RESTRICTED_OPERATION.equals(actionStatus)) {
- variables = asList("");
- } else if(ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION.equals(actionStatus)) {
- variables = asList(resourceDetails.getName(), AssetTypeEnum.SERVICES.getCorrespondingComponent().toLowerCase());
- } else {
- if(operationUser == null) {
- variables = asList(resourceDetails.getName(), AssetTypeEnum.SERVICES.getCorrespondingComponent().toLowerCase(), user.getFirstName(), user.getLastName(), user.getUserId());
- } else {
- variables = asList(resourceDetails.getName(), AssetTypeEnum.SERVICES.getCorrespondingComponent().toLowerCase(), operationUser.getFirstName(), operationUser.getLastName(), operationUser.getUserId());
- }
-
- }
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@DataProvider(name="invalidStatesForResource")
public static Object[][] dataProviderInvalidStatesForResource() {
return new Object[][] {
{LifeCycleStatesEnum.CHECKIN, LifeCycleStatesEnum.CHECKIN, COMPONENT_ALREADY_CHECKED_IN, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, "409", ActionStatus.COMPONENT_ALREADY_CHECKED_IN, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), null},
- {LifeCycleStatesEnum.CHECKIN, LifeCycleStatesEnum.STARTCERTIFICATION, COMPONENT_NOT_READY_FOR_CERTIFICATION, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, "403", ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},
+ /* {LifeCycleStatesEnum.CHECKIN, LifeCycleStatesEnum.STARTCERTIFICATION, COMPONENT_NOT_READY_FOR_CERTIFICATION, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, "403", ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},*/
{LifeCycleStatesEnum.CHECKIN, LifeCycleStatesEnum.CERTIFY, COMPONENT_NOT_READY_FOR_CERTIFICATION, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, "403", ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},
{LifeCycleStatesEnum.CHECKOUT, LifeCycleStatesEnum.CHECKOUT, COMPONENT_IN_CHECKOUT_STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, "403", ActionStatus.COMPONENT_IN_CHECKOUT_STATE, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), null},
- {LifeCycleStatesEnum.CHECKOUT, LifeCycleStatesEnum.STARTCERTIFICATION, COMPONENT_NOT_READY_FOR_CERTIFICATION, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, "403", ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},
+ /* {LifeCycleStatesEnum.CHECKOUT, LifeCycleStatesEnum.STARTCERTIFICATION, COMPONENT_NOT_READY_FOR_CERTIFICATION, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, "403", ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},*/
{LifeCycleStatesEnum.CHECKOUT, LifeCycleStatesEnum.CERTIFY, COMPONENT_NOT_READY_FOR_CERTIFICATION, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, "403", ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, LifeCycleStatesEnum.CERTIFICATIONREQUEST, COMPONENT_SENT_FOR_CERTIFICATION, LifecycleStateEnum.READY_FOR_CERTIFICATION, LifecycleStateEnum.READY_FOR_CERTIFICATION, "403", ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), null},
+ /*{LifeCycleStatesEnum.CERTIFICATIONREQUEST, LifeCycleStatesEnum.CERTIFICATIONREQUEST, COMPONENT_SENT_FOR_CERTIFICATION, LifecycleStateEnum.READY_FOR_CERTIFICATION, LifecycleStateEnum.READY_FOR_CERTIFICATION, "403", ActionStatus.COMPONENT_SENT_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), null},
{LifeCycleStatesEnum.CERTIFICATIONREQUEST, LifeCycleStatesEnum.CERTIFY, RESTRICTED_OPERATION, LifecycleStateEnum.READY_FOR_CERTIFICATION, LifecycleStateEnum.READY_FOR_CERTIFICATION, "409", ActionStatus.RESTRICTED_OPERATION, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), null},
{LifeCycleStatesEnum.STARTCERTIFICATION, LifeCycleStatesEnum.CHECKIN, COMPONENT_IN_CERT_IN_PROGRESS_STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, "403", ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)},
{LifeCycleStatesEnum.STARTCERTIFICATION, LifeCycleStatesEnum.CHECKOUT, COMPONENT_IN_CERT_IN_PROGRESS_STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, "403", ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)},
{LifeCycleStatesEnum.STARTCERTIFICATION, LifeCycleStatesEnum.CERTIFICATIONREQUEST, COMPONENT_IN_CERT_IN_PROGRESS_STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, "403", ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)},
- {LifeCycleStatesEnum.STARTCERTIFICATION, LifeCycleStatesEnum.STARTCERTIFICATION, COMPONENT_IN_CERT_IN_PROGRESS_STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, "403", ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},
+ {LifeCycleStatesEnum.STARTCERTIFICATION, LifeCycleStatesEnum.STARTCERTIFICATION, COMPONENT_IN_CERT_IN_PROGRESS_STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, "403", ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},*/
{LifeCycleStatesEnum.CERTIFY, LifeCycleStatesEnum.CHECKIN, COMPONENT_ALREADY_CERTIFIED, LifecycleStateEnum.CERTIFIED, LifecycleStateEnum.CERTIFIED, "403", ActionStatus.COMPONENT_ALREADY_CERTIFIED, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)},
- {LifeCycleStatesEnum.CERTIFY, LifeCycleStatesEnum.CERTIFICATIONREQUEST, COMPONENT_ALREADY_CERTIFIED, LifecycleStateEnum.CERTIFIED, LifecycleStateEnum.CERTIFIED, "403", ActionStatus.COMPONENT_ALREADY_CERTIFIED, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)},
- {LifeCycleStatesEnum.CERTIFY, LifeCycleStatesEnum.STARTCERTIFICATION, COMPONENT_ALREADY_CERTIFIED, LifecycleStateEnum.CERTIFIED, LifecycleStateEnum.CERTIFIED, "403", ActionStatus.COMPONENT_ALREADY_CERTIFIED, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},
+ /*{LifeCycleStatesEnum.CERTIFY, LifeCycleStatesEnum.CERTIFICATIONREQUEST, COMPONENT_ALREADY_CERTIFIED, LifecycleStateEnum.CERTIFIED, LifecycleStateEnum.CERTIFIED, "403", ActionStatus.COMPONENT_ALREADY_CERTIFIED, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ElementFactory.getDefaultUser(UserRoleEnum.TESTER)},
+ {LifeCycleStatesEnum.CERTIFY, LifeCycleStatesEnum.STARTCERTIFICATION, COMPONENT_ALREADY_CERTIFIED, LifecycleStateEnum.CERTIFIED, LifecycleStateEnum.CERTIFIED, "403", ActionStatus.COMPONENT_ALREADY_CERTIFIED, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},*/
{LifeCycleStatesEnum.CERTIFY, LifeCycleStatesEnum.CERTIFY, COMPONENT_NOT_READY_FOR_CERTIFICATION, LifecycleStateEnum.CERTIFIED, LifecycleStateEnum.CERTIFIED, "403", ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), null},
};
}
@@ -683,6 +536,7 @@ public class AssetLifeCycle extends ComponentBaseTest {
public void invalidStatesForResource(LifeCycleStatesEnum initState, LifeCycleStatesEnum targetState, int errorCode,
LifecycleStateEnum preState, LifecycleStateEnum currState, String status,
ActionStatus actionStatus, User user, User operationUser) throws Exception {
+
getExtendTest().log(Status.INFO, String.format("initState: %s, targetState: %s, errorCode: %s,"
+ " preState: %s, currState: %s, status: %s, actionStatus: %s, user: %s, operationUser: %s", initState, targetState, errorCode, preState,
currState, status, actionStatus, user, operationUser));
@@ -702,44 +556,16 @@ public class AssetLifeCycle extends ComponentBaseTest {
restResponse = LifecycleRestUtils.checkOutResource(resourceDetails.getUUID(), user);
} else if(targetState.equals(LifeCycleStatesEnum.CHECKIN)) {
restResponse = LifecycleRestUtils.checkInResource(resourceDetails.getUUID(), user);
- } else if(targetState.equals(LifeCycleStatesEnum.CERTIFICATIONREQUEST)) {
+ /*} else if(targetState.equals(LifeCycleStatesEnum.CERTIFICATIONREQUEST)) {
restResponse = LifecycleRestUtils.certificationRequestResource(resourceDetails.getUUID(), user);
} else if(targetState.equals(LifeCycleStatesEnum.STARTCERTIFICATION)) {
- restResponse = LifecycleRestUtils.startTestingResource(resourceDetails.getUUID(), user);
+ restResponse = LifecycleRestUtils.startTestingResource(resourceDetails.getUUID(), user);*/
} else if(targetState.equals(LifeCycleStatesEnum.CERTIFY)) {
restResponse = LifecycleRestUtils.certifyResource(resourceDetails.getUUID(), user);
}
Assert.assertEquals(restResponse.getErrorCode(), (Integer)errorCode, "Expected that response code will be equal.");
- /*// auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, user, targetState, AssetTypeEnum.RESOURCES);
- if(initState.equals(LifeCycleStatesEnum.CERTIFY)) {
- expectedResourceAuditJavaObject.setCurrVersion("1.0");
- expectedResourceAuditJavaObject.setPrevVersion("1.0");
- }
- expectedResourceAuditJavaObject.setPrevState(preState.toString());
- expectedResourceAuditJavaObject.setCurrState(currState.toString());
- expectedResourceAuditJavaObject.setStatus(status);
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(actionStatus.name());
- List<String> variables = null;
- if(ActionStatus.RESTRICTED_OPERATION.equals(actionStatus)) {
- variables = asList("");
- } else if(ActionStatus.COMPONENT_NOT_READY_FOR_CERTIFICATION.equals(actionStatus)) {
- variables = asList(resourceDetails.getName(), AssetTypeEnum.RESOURCES.getCorrespondingComponent().toLowerCase());
- } else {
- if(operationUser == null) {
- variables = asList(resourceDetails.getName(), AssetTypeEnum.RESOURCES.getCorrespondingComponent().toLowerCase(), user.getFirstName(), user.getLastName(), user.getUserId());
- } else {
- variables = asList(resourceDetails.getName(), AssetTypeEnum.RESOURCES.getCorrespondingComponent().toLowerCase(), operationUser.getFirstName(), operationUser.getLastName(), operationUser.getUserId());
- }
-
- }
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@@ -749,7 +575,7 @@ public class AssetLifeCycle extends ComponentBaseTest {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing
+/* // US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing
@Test
public void BasicFlowForResourceSubmitForTestingStartTesting() throws Exception {
Either<Resource, RestResponse> createdComponent = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true);
@@ -758,29 +584,7 @@ public class AssetLifeCycle extends ComponentBaseTest {
// Certification request
restResponse = LifecycleRestUtils.certificationRequestResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-
- /*// Auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.CERTIFICATIONREQUEST.getState()));
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.READY_FOR_CERTIFICATION.toString());
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
-
- // Start testing
- restResponse = LifecycleRestUtils.startTestingResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER));
-
- /* // Auditing verification
- body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.STARTCERTIFICATION.getState()));
- expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.READY_FOR_CERTIFICATION.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.toString());
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
- }
+ }*/
// US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing
@Test
@@ -792,30 +596,12 @@ public class AssetLifeCycle extends ComponentBaseTest {
// Certification request
restResponse = LifecycleRestUtils.certificationRequestService(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- /*// Auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.SERVICES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.CERTIFICATIONREQUEST.getState()));
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST, AssetTypeEnum.SERVICES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.READY_FOR_CERTIFICATION.toString());
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
-
// Start testing
restResponse = LifecycleRestUtils.startTestingService(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER));
- /* // Auditing verification
- body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.SERVICES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.STARTCERTIFICATION.getState()));
- expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION, AssetTypeEnum.SERVICES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.READY_FOR_CERTIFICATION.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.toString());
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
- // US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing
+ /*// US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing
@Test
public void specialCaseInvalidFlowForVfcmtSubmitForTesting() throws Exception {
Either<Resource, RestResponse> createdComponent = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum.VFCMT, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, UserRoleEnum.DESIGNER, true);
@@ -824,23 +610,7 @@ public class AssetLifeCycle extends ComponentBaseTest {
// Certification request
restResponse = LifecycleRestUtils.certificationRequestResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
-
- /*// Auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.CERTIFICATIONREQUEST.getState()));
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, defaultUser, LifeCycleStatesEnum.CERTIFICATIONREQUEST, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setStatus("400");
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_VFCMT_LIFECYCLE_STATE_NOT_VALID.name());
- List<String> variables = asList(LifeCycleStatesEnum.CERTIFICATIONREQUEST.getState());
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
-
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
- }
+ }*/
// US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing
@Test
@@ -852,21 +622,6 @@ public class AssetLifeCycle extends ComponentBaseTest {
// Certification request
restResponse = LifecycleRestUtils.startTestingResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER));
- /*// Auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.STARTCERTIFICATION.getState()));
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.STARTCERTIFICATION, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setStatus("400");
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_VFCMT_LIFECYCLE_STATE_NOT_VALID.name());
- List<String> variables = asList(LifeCycleStatesEnum.STARTCERTIFICATION.getState());
- expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
-
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@@ -885,26 +640,14 @@ public class AssetLifeCycle extends ComponentBaseTest {
Component resourceDetails = createdComponent.left().value();
RestResponse restResponse = LifecycleRestUtils.checkInResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
- // Certification request
+ /*// Certification request
restResponse = LifecycleRestUtils.certificationRequestResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
// Start testing
- restResponse = LifecycleRestUtils.startTestingResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER));
+ restResponse = LifecycleRestUtils.startTestingResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER));*/
// Certify
- restResponse = LifecycleRestUtils.certifyResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER));
-
- /*// Auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.CERTIFY.getState()));
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFIED.toString());
- expectedResourceAuditJavaObject.setCurrVersion("1.0");
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
-
+ restResponse = LifecycleRestUtils.certifyResource(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
}
// US824692 - Story [BE]: External API for asset lifecycle - submit for test / start testing
@@ -923,16 +666,6 @@ public class AssetLifeCycle extends ComponentBaseTest {
// Certify
restResponse = LifecycleRestUtils.certifyService(resourceDetails.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER));
- /*// Auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.SERVICES.getValue().toLowerCase(), resourceDetails.getUUID(), LifeCycleStatesEnum.CERTIFY.getState()));
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.TESTER), LifeCycleStatesEnum.CERTIFY, AssetTypeEnum.SERVICES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFIED.toString());
- expectedResourceAuditJavaObject.setCurrVersion("1.0");
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
}
@@ -991,14 +724,6 @@ public class AssetLifeCycle extends ComponentBaseTest {
Assert.assertEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will not change.");
Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change.");
- /* // Auditing verification
- AuditingActionEnum action = AuditingActionEnum.CHANGE_LIFECYCLE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CHECKIN.getState()));
- ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(initComponentVersion, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.RESOURCES);
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
-
// 7. Then checkout the VFCMT via external API.
RestResponse checkOutRestResponse = LifecycleRestUtils.checkOutResource(initComponentVersion.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
BaseRestUtils.checkCreateResponse(checkOutRestResponse);
@@ -1007,16 +732,6 @@ public class AssetLifeCycle extends ComponentBaseTest {
Assert.assertEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will not change.");
Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change.");
- /*// Auditing verification
- body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CHECKOUT.getState()));
- expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(initComponentVersion, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKOUT, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
- expectedResourceAuditJavaObject.setCurrVersion("0.2");
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
-
// 8. The minor version must be incremented, the invariantUUID, and UUID must stay the same, the uniqueId should be changed, the artifacts from first version exists on the new version.
Component newComponentVersion = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, parsedCreatedResponse.getName(), String.format("%.1f", Double.parseDouble(parsedCreatedResponse.getVersion())));
Assert.assertEquals(newComponentVersion.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change.");
@@ -1036,17 +751,6 @@ public class AssetLifeCycle extends ComponentBaseTest {
Assert.assertEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will not change.");
Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change.");
- /*// Auditing verification
- body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CHECKIN.getState()));
- expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(initComponentVersion, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKIN, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setCurrVersion("0.2");
- expectedResourceAuditJavaObject.setPrevVersion("0.2");
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
-
// 11. Certify via external API.
RestResponse certifyRestResponse = LifecycleRestUtils.certifyResource(initComponentVersion.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
BaseRestUtils.checkCreateResponse(certifyRestResponse);
@@ -1055,17 +759,6 @@ public class AssetLifeCycle extends ComponentBaseTest {
Assert.assertEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will not change.");
Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change.");
- /*// Auditing verification
- body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CERTIFY.getState()));
- expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(initComponentVersion, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CERTIFY, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.CERTIFIED.toString());
- expectedResourceAuditJavaObject.setCurrVersion("1.0");
- expectedResourceAuditJavaObject.setPrevVersion("0.2");
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
-
// 12. Check out via external API.
checkOutRestResponse = LifecycleRestUtils.checkOutResource(initComponentVersion.getUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
BaseRestUtils.checkCreateResponse(checkOutRestResponse);
@@ -1074,31 +767,6 @@ public class AssetLifeCycle extends ComponentBaseTest {
Assert.assertNotEquals(parsedCreatedResponse.getUuid(), initComponentVersion.getUUID(), "Expect that UUID will change.");
Assert.assertEquals(parsedCreatedResponse.getInvariantUUID(), initComponentVersion.getInvariantUUID(), "Expected that invariantUUID will not change.");
- /*// Auditing verification
- body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, initComponentVersion.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, String.format("/sdc/v1/catalog/%s/%s/lifecycleState/%s", AssetTypeEnum.RESOURCES.getValue().toLowerCase(), initComponentVersion.getUUID(), LifeCycleStatesEnum.CHECKOUT.getState()));
- expectedResourceAuditJavaObject = ElementFactory.getDefaultChangeAssetLifeCycleExternalAPI(initComponentVersion, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), LifeCycleStatesEnum.CHECKOUT, AssetTypeEnum.RESOURCES);
- expectedResourceAuditJavaObject.setPrevState(LifecycleStateEnum.CERTIFIED.toString());
- expectedResourceAuditJavaObject.setCurrState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.toString());
- expectedResourceAuditJavaObject.setCurrVersion("1.1");
- expectedResourceAuditJavaObject.setPrevVersion("1.0");
- AuditValidationUtils.validateAuditExternalChangeAssetLifeCycle(expectedResourceAuditJavaObject, action.getName(), body);*/
-
-
}
-
-
-
-
-
-
-
-
-
-
-
-
-
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
index 318316e5ad..3b7d2dbb8b 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
@@ -42,10 +42,7 @@ import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.common.util.ValidationUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.testng.Assert;
-import org.testng.SkipException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -57,1862 +54,1421 @@ import static java.util.Arrays.asList;
public class CRUDExternalAPI extends ComponentBaseTest {
- private static Logger log = LoggerFactory.getLogger(CRUDExternalAPI.class.getName());
- protected static final String UPLOAD_ARTIFACT_PAYLOAD = "UHVUVFktVXNlci1LZXktRmlsZS0yOiBzc2gtcnNhDQpFbmNyeXB0aW9uOiBhZXMyNTYtY2JjDQpDb21tZW5wOA0K";
- protected static final String UPLOAD_ARTIFACT_NAME = "TLV_prv.ppk";
-
- protected Config config = Config.instance();
-
- protected String serviceVersion;
- protected ResourceReqDetails resourceDetails;
- protected User sdncUserDetails;
- protected ServiceReqDetails serviceDetails;
-
- @Rule
- public static TestName name = new TestName();
-
- public CRUDExternalAPI() {
- super(name, CRUDExternalAPI.class.getName());
- }
-
- @DataProvider(name="uploadArtifactOnVfcVlCpViaExternalAPI" , parallel=true)
- public static Object[][] dataProviderUploadArtifactOnVfcVlCpViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP}
- };
- }
-
- // External API
- // Upload artifact on VFC, VL, CP via external API - happy flow
- @Test(dataProvider="uploadArtifactOnVfcVlCpViaExternalAPI")
- public void uploadArtifactOnVfcVlCpViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s, resourceTypeEnum: %s", chosenLifeCycleState, artifactType, resourceTypeEnum));
- uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, chosenLifeCycleState, artifactType, resourceTypeEnum);
- }
-
- @DataProvider(name="uploadArtifactOnVFViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUploadArtifactOnVFViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()}
- };
- }
-
- // External API
- // Upload artifact on VF via external API - happy flow
- @Test(dataProvider="uploadArtifactOnVFViaExternalAPI")
- public void uploadArtifactOnVFViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, chosenLifeCycleState, artifactType, null);
- }
-
-
- @DataProvider(name="uploadArtifactOnServiceViaExternalAPI" , parallel=true)
- public static Object[][] dataProviderUploadArtifactOnServiceViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()}
- };
- }
-
-
- @Test(dataProvider="uploadArtifactOnServiceViaExternalAPI")
- public void uploadArtifactOnServiceViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.SERVICE, chosenLifeCycleState, artifactType, null);
- }
-
-
-/* @DataProvider(name="uploadArtifactOnServiceViaExternalAPIIncludingDistribution", parallel=true)
- public static Object[][] dataProviderUploadArtifactOnServiceViaExternalAPIIncludingDistribution() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
- };
- }
-
- @Test(dataProvider="uploadArtifactOnServiceViaExternalAPIIncludingDistribution")
- public void uploadArtifactOnServiceViaExternalAPIIncludingDistribution(LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
- if(true){
- throw new SkipException("Automated TC need repair.");
- }
-
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.SERVICE, chosenLifeCycleState, artifactType, null);
-
- component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
-
- if(config.getIsDistributionClientRunning()){
- List<String> distributionStatusList = Arrays.asList(DistributionNotificationStatusEnum.DOWNLOAD_OK.toString(), DistributionNotificationStatusEnum.DEPLOY_OK.toString(), DistributionNotificationStatusEnum.NOTIFIED.toString());
- DistributionValidationUtils.validateDistributedArtifactsByAudit((Service)component, distributionStatusList);
- }
- }*/
-
-
- // Happy flow - get chosen life cycle state, artifact type and asset type
- // Create asset, upload artifact via external API + check audit & response code
- // Download artifact via external API + check audit & response code
- protected Component uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- Component component = null;
- RestResponse restResponse;
- int numberOfArtifact = 0;
-
- // get artifact data
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, false);
-
- // create component/s & upload artifact via external api
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- component = getComponentWithResourceInstanceInTargetLifeCycleState(chosenLifeCycleState, resourceTypeEnum);
- restResponse = uploadArtifactOfRIIncludingValiditionOfAuditAndResponseCode(component, component.getComponentInstances().get(0), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
- component = getNewerVersionOfComponent(component, chosenLifeCycleState);
- numberOfArtifact = (component.getComponentInstances().get(0).getDeploymentArtifacts() == null ? 0 : component.getComponentInstances().get(0).getDeploymentArtifacts().size());
- } else {
- component = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, chosenLifeCycleState, resourceTypeEnum);
- restResponse = uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
- component = updateComponentDetailsByLifeCycleState(chosenLifeCycleState, component);
- numberOfArtifact = component.getDeploymentArtifacts().size();
- }
-
- ArtifactDefinition responseArtifact = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse());
- // Get list of deployment artifact + download them via external API
- Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
- Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifacts will be increase by one.");
-
- // Download the uploaded artifact via external API
- downloadResourceDeploymentArtifactExternalAPI(component, deploymentArtifacts.get(responseArtifact.getArtifactLabel()), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentTypeEnum);
- return component;
- }
-
- /**
- * according lifecycle state of component get updated component details
- * @param chosenLifeCycleState
- * @param component
- * @return
- * @throws Exception
- */
- public Component updateComponentDetailsByLifeCycleState(LifeCycleStatesEnum chosenLifeCycleState, Component component) throws Exception {
- if(LifeCycleStatesEnum.CHECKOUT.equals(chosenLifeCycleState)){
- component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
- }else{
- component = getNewerVersionOfComponent(component, chosenLifeCycleState);
- }
- return component;
- }
-
- // Upload artifact via external API + Check auditing for upload operation + Check response of external API
- public RestResponse uploadArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, component.getComponentInstances().get(0));
-
- // Check response of external API
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
-
-
- /*// Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API;
-
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, componentInstance.getNormalizedName());
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
- expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts");
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);*/
-
- return restResponse;
- }
-
-
- protected Component getComponentWithResourceInstanceInTargetLifeCycleState(LifeCycleStatesEnum lifeCycleStatesEnum, ResourceTypeEnum resourceTypeEnum) throws Exception {
- Component component;
- if(resourceTypeEnum == ResourceTypeEnum.VF) {
- component = getComponentInTargetLifeCycleState(ComponentTypeEnum.SERVICE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
-
- Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, null);
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
-
- // Add artifact to service if asked for certification request - must be at least one artifact for the flow
+ /*private static Logger log = LoggerFactory.getLogger(CRUDExternalAPI.class.getName());
+ protected static final String UPLOAD_ARTIFACT_PAYLOAD = "UHVUVFktVXNlci1LZXktRmlsZS0yOiBzc2gtcnNhDQpFbmNyeXB0aW9uOiBhZXMyNTYtY2JjDQpDb21tZW5wOA0K";
+ protected static final String UPLOAD_ARTIFACT_NAME = "TLV_prv.ppk";*/
+
+ protected Config config = Config.instance();
+
+ protected String serviceVersion;
+ protected ResourceReqDetails resourceDetails;
+ protected User sdncUserDetails;
+ protected ServiceReqDetails serviceDetails;
+
+ @Rule
+ public static TestName name = new TestName();
+
+ public CRUDExternalAPI() {
+ super(name, CRUDExternalAPI.class.getName());
+ }
+
+ @DataProvider(name = "uploadArtifactOnVfcVlCpViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUploadArtifactOnVfcVlCpViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+ };
+ }
+
+ // External API
+ // Upload artifact on VFC, VL, CP via external API - happy flow
+ @Test(dataProvider = "uploadArtifactOnVfcVlCpViaExternalAPI")
+ public void uploadArtifactOnVfcVlCpViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s, resourceTypeEnum: %s", chosenLifeCycleState, artifactType, resourceTypeEnum));
+ uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, chosenLifeCycleState, artifactType, resourceTypeEnum);
+ }
+
+ @DataProvider(name = "uploadArtifactOnVFViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUploadArtifactOnVFViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_JSON.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_POLICY.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_EVENT.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.APPC_CONFIG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_DOC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_TOSCA.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_JSON.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_POLICY.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_EVENT.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.APPC_CONFIG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_DOC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_TOSCA.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ };
+ }
+
+ // External API
+ // Upload artifact on VF via external API - happy flow
+ @Test(dataProvider = "uploadArtifactOnVFViaExternalAPI")
+ public void uploadArtifactOnVFViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
+ uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, chosenLifeCycleState, artifactType, null);
+ }
+
+
+ @DataProvider(name = "uploadArtifactOnServiceViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUploadArtifactOnServiceViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()}
+ };
+ }
+
+
+ @Test(dataProvider = "uploadArtifactOnServiceViaExternalAPI")
+ public void uploadArtifactOnServiceViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
+ uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.SERVICE, chosenLifeCycleState, artifactType, null);
+ }
+
+ // Happy flow - get chosen life cycle state, artifact type and asset type
+ // Create asset, upload artifact via external API + check audit & response code
+ // Download artifact via external API + check audit & response code
+ protected Component uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ Component component = null;
+ RestResponse restResponse;
+ int numberOfArtifact = 0;
+
+ // get artifact data
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, false);
+
+ // create component/s & upload artifact via external api
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ component = getComponentWithResourceInstanceInTargetLifeCycleState(chosenLifeCycleState, resourceTypeEnum);
+ restResponse = uploadArtifactOfRIIncludingValiditionOfAuditAndResponseCode(component, component.getComponentInstances().get(0), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
+ component = getNewerVersionOfComponent(component, chosenLifeCycleState);
+ numberOfArtifact = (component.getComponentInstances().get(0).getDeploymentArtifacts() == null ? 0 : component.getComponentInstances().get(0).getDeploymentArtifacts().size());
+ } else {
+ component = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, chosenLifeCycleState, resourceTypeEnum);
+ restResponse = uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
+ component = updateComponentDetailsByLifeCycleState(chosenLifeCycleState, component);
+ numberOfArtifact = component.getDeploymentArtifacts().size();
+ }
+
+ ArtifactDefinition responseArtifact = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse());
+ // Get list of deployment artifact + download them via external API
+ Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+ Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifacts will be increase by one.");
+
+ // Download the uploaded artifact via external API
+ downloadResourceDeploymentArtifactExternalAPI(component, deploymentArtifacts.get(responseArtifact.getArtifactLabel()), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentTypeEnum);
+ return component;
+ }
+
+ /**
+ * according lifecycle state of component get updated component details
+ *
+ * @param chosenLifeCycleState
+ * @param component
+ * @return
+ * @throws Exception
+ */
+ public Component updateComponentDetailsByLifeCycleState(LifeCycleStatesEnum chosenLifeCycleState, Component component) throws Exception {
+ if (LifeCycleStatesEnum.CHECKOUT.equals(chosenLifeCycleState)) {
+ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
+ } else {
+ component = getNewerVersionOfComponent(component, chosenLifeCycleState);
+ }
+ return component;
+ }
+
+ // Upload artifact via external API + Check auditing for upload operation + Check response of external API
+ public RestResponse uploadArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, component.getComponentInstances().get(0));
+
+ // Check response of external API
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
+ return restResponse;
+ }
+
+
+ protected Component getComponentWithResourceInstanceInTargetLifeCycleState(LifeCycleStatesEnum lifeCycleStatesEnum, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ Component component;
+ if (resourceTypeEnum == ResourceTypeEnum.VF) {
+ component = getComponentInTargetLifeCycleState(ComponentTypeEnum.SERVICE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
+
+ Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, null);
+ AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
+
+ // Add artifact to service if asked for certification request - must be at least one artifact for the flow
// if((LifeCycleStatesEnum.CERTIFICATIONREQUEST == lifeCycleStatesEnum) || (LifeCycleStatesEnum.STARTCERTIFICATION == lifeCycleStatesEnum)) {
// }
- AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.OTHER, component, UserRoleEnum.DESIGNER, true, true).left().value();
- component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, lifeCycleStatesEnum, true).getLeft();
- } else {
- component = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
- Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, resourceTypeEnum);
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
- component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, lifeCycleStatesEnum, true).getLeft();
- }
-
-
- return component;
- }
-
-
-
-
- // Upload artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails);
-
- // Check response of external API
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
-
-
- /*// Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API;
-
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);*/
-
- return restResponse;
- }
-
-
-
- // Check Component version (increase by one if not in checkout)
- // Input: component, componentLifeCycleState
- // for any LifeCycleState != checkout
- // find component of version +0.1
- // check that this version different for input version
- // check that this component uniqueID different from input uniqueID
- // Return: that version
- protected synchronized Component getNewerVersionOfComponent(Component component, LifeCycleStatesEnum lifeCycleStatesEnum) throws Exception {
- Component resourceDetails = null;
-
- if((!lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CHECKOUT)) && (!lifeCycleStatesEnum.equals(LifeCycleStatesEnum.STARTCERTIFICATION))) {
-
-
- String resourceVersion = component.getVersion();
- String resourceUniqueID = component.getUniqueId();
-
- if(component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
- resourceDetails = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), String.format("%.1f", Double.parseDouble(component.getVersion()) + 0.1));
- } else {
- resourceDetails = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), String.format("%.1f", Double.parseDouble(component.getVersion()) + 0.1));
- }
-
- String resourceNewVersion = resourceDetails.getVersion();
- String resourceNewUniqueID = resourceDetails.getUniqueId();
-
- System.out.println(resourceNewVersion);
- System.out.println("Service UUID: " + resourceDetails.getUUID());
- System.out.println("Service UniqueID: " + resourceDetails.getUniqueId());
-
- // Checking that new version exist + different from old one by unique id
- Assert.assertNotEquals(resourceVersion, resourceNewVersion, "Expected for different resource version.");
- Assert.assertNotEquals(resourceUniqueID, resourceNewUniqueID, "Expected that resource will have new unique ID.");
- } else {
- if(component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
- resourceDetails = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
- } else {
- resourceDetails = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
- }
- }
- return resourceDetails;
- }
-
-
-
-
-
- // download deployment via external api + check response code for success (200) + get artifactReqDetails and verify payload + verify audit
- protected RestResponse downloadResourceDeploymentArtifactExternalAPI(Component component, ArtifactDefinition artifactDefinition, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, ComponentTypeEnum componentTypeEnum) throws Exception {
- RestResponse restResponse;
-
- if(componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) {
- restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(component.getUUID(), component.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
- } else {
- restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(component.getUUID(), artifactDefinition.getArtifactUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
- }
-
- Integer responseCode = restResponse.getErrorCode();
- Integer expectedCode = 200;
- Assert.assertEquals(responseCode,expectedCode, "Response code is not correct.");
-
-
- // For known artifact/payload - verify payload of downloaded artifact
- if (artifactReqDetails != null) {
- String response = restResponse.getResponse();
- String payloadData = artifactReqDetails.getPayload();
- String decodedPaypload = org.openecomp.sdc.ci.tests.utils.Decoder.decode(payloadData);
- Assert.assertEquals(response, decodedPaypload, "Response artifact payload not correct.");
- }
-
- //TODO - including body - resourceDetails.getName()
-// // Verify audit
-// String auditAction = "DownloadArtifact";
-//
-// Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
-// body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
-// body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
-//
-// ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
-// expectedResourceAuditJavaObject.setAction(auditAction);
-// expectedResourceAuditJavaObject.setResourceType(resourceDetails.getComponentType().getValue());
-// expectedResourceAuditJavaObject.setStatus("200");
-// expectedResourceAuditJavaObject.setDesc("OK");
-// expectedResourceAuditJavaObject.setCONSUMER_ID("ci");
-//
-// if(componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) {
-// expectedResourceAuditJavaObject.setResourceName(resourceDetails.getComponentInstances().get(0).getName());
-// String resource_url = String.format("/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceDetails.getUUID(), resourceDetails.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID());
-// expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url);
-//
-// AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false);
-// } else {
-// expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName());
-// String resource_url = String.format("/sdc/v1/catalog/services/%s/artifacts/%s", resourceDetails.getUUID(), artifactDefinition.getArtifactUUID());
-// expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url);
-// }
-//
-// AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false);
-
- return restResponse;
-
- }
-
- // download deployment via external api + check response code for success (200) + verify audit
- protected void downloadResourceDeploymentArtifactExternalAPI(Component component, ArtifactDefinition artifactDefinition, User sdncModifierDetails) throws Exception {
- downloadResourceDeploymentArtifactExternalAPI(component, artifactDefinition, sdncModifierDetails, null, component.getComponentType());
- }
-
-
-
-
-
-
-
-
-
- @DataProvider(name="uploadArtifactOnRIViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUploadArtifactOnRIViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType()},
-
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType()},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType()}
-
- };
- }
-
-
-
-
-
- @Test(dataProvider="uploadArtifactOnRIViaExternalAPI")
- public void uploadArtifactOnRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState, artifactType, null);
- }
-
-
-
- @DataProvider(name="uploadArtifactOnVfcVlCpRIViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUploadArtifactOnVfcVlCpRIViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP}
-
- };
- }
-
-
-
-
-
- @Test(dataProvider="uploadArtifactOnVfcVlCpRIViaExternalAPI")
- public void uploadArtifactOnVfcVlCpRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState, artifactType, resourceTypeEnum);
- }
-
-
-
-
- @DataProvider(name="uploadInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUploadInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI() {
- return new Object[][] {
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeToLong"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeEmpty"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameToLong"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameEmpty"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelToLong"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelEmpty"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionToLong"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionEmpty"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithSameLabel"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
-// 322151 {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithSameLabel"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
-// 322151 {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithSameLabel"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
-// 322151 {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidCheckSum"},
- };
- }
-
-
-
-
- // InvalidArtifact + check audit & response code function
- @Test(dataProvider="uploadInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI")
- public void uploadInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState,
- ComponentTypeEnum componentTypeEnum, String uploadArtifactTestType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, componentTypeEnum: %s, uploadArtifactTestType: %s", chosenLifeCycleState, componentTypeEnum, uploadArtifactTestType));
- Component resourceDetails;
- ComponentInstance componentResourceInstanceDetails = null;
- ArtifactReqDetails artifactReqDetails;
-
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString(), true, false);
-
- resourceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.SERVICE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
- resourceDetails = getComponentWithResourceInstanceInTargetLifeCycleState(chosenLifeCycleState, null);
- componentResourceInstanceDetails = resourceDetails.getComponentInstances().get(0);
- } else {
- artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.OTHER.toString(), true, false);
- resourceDetails = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, chosenLifeCycleState, null);
- }
-
-
- switch (uploadArtifactTestType) {
- case "uploadArtifactWithInvalidTypeToLong":
- uploadArtifactWithInvalidTypeToLong(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithInvalidTypeEmpty":
- uploadArtifactWithInvalidTypeEmpty(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithInvalidCheckSum":
- uploadArtifactWithInvalidCheckSum(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithInvalidNameToLong":
- uploadArtifactWithInvalidNameToLong(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithInvalidNameEmpty":
- uploadArtifactWithInvalidNameEmpty(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithInvalidLabelToLong":
- uploadArtifactWithInvalidLabelToLong(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithInvalidLabelEmpty":
- uploadArtifactWithInvalidLabelEmpty(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithInvalidDescriptionToLong":
- uploadArtifactWithInvalidDescriptionToLong(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithInvalidDescriptionEmpty":
- uploadArtifactWithInvalidDescriptionEmpty(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- case "uploadArtifactWithSameLabel":
- default:
- uploadArtifactWithSameLabel(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- break;
- }
- }
-
- // Upload artifact with invalid type via external API - to long type
- protected void uploadArtifactWithInvalidTypeToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
- artifactReqDetails.setArtifactType("dsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfds");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
- List<String> variables = asList(artifactReqDetails.getArtifactType());
-
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
- // Upload artifact with invalid type via external API - empty type
- protected void uploadArtifactWithInvalidTypeEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
- artifactReqDetails.setArtifactType("");
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
- List<String> variables = asList(artifactReqDetails.getArtifactType());
-
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
- // Upload artifact with invalid checksum via external API
- protected void uploadArtifactWithInvalidCheckSum(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_INVALID_MD5.name());
- List<String> variables = asList();
- uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables);
- }
-
-
- // Upload artifact with valid type & invalid name via external API - name to long
- protected void uploadArtifactWithInvalidNameToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
- List<String> variables = asList("artifact name", "255");
- artifactReqDetails.setArtifactName("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
-
- // Upload artifact with valid type & invalid name via external API - name is empty
- protected void uploadArtifactWithInvalidNameEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_ARTIFACT_NAME.name());
- List<String> variables = asList();
-
- artifactReqDetails.setArtifactName("");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
-
- // Upload artifact with valid type & invalid label via external API - label to long
- protected void uploadArtifactWithInvalidLabelToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
- List<String> variables = asList("artifact label", "255");
- artifactReqDetails.setArtifactLabel("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
-
- // Upload artifact with valid type & invalid label via external API - label is empty
- protected void uploadArtifactWithInvalidLabelEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- List<String> variables = asList("artifact label");
- artifactReqDetails.setArtifactLabel("");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
-
- // Upload artifact with invalid description via external API - to long description
- protected void uploadArtifactWithInvalidDescriptionToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
- List<String> variables = asList("artifact description", "256");
- artifactReqDetails.setDescription("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
-
- // Upload artifact with invalid description via external API - empty description
- protected void uploadArtifactWithInvalidDescriptionEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- List<String> variables = asList("artifact description");
- artifactReqDetails.setDescription("");
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
-
-
-
- // Upload artifact with same label via external API
- protected void uploadArtifactWithSameLabel(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails) throws Exception {
-
- RestResponse restResponse = null;
- if(componentResourceInstanceDetails != null) {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- } else {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails);
-
- }
-
- ArtifactDefinition artifactDefinition = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse());
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_EXIST.name());
-
- List<String> variables = asList(artifactDefinition.getArtifactDisplayName());
- ArtifactReqDetails artifactReqDetailsSameLabel = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_EVENT.toString(), true, false);
- artifactReqDetailsSameLabel.setArtifactLabel(artifactReqDetails.getArtifactLabel());
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetailsSameLabel, componentResourceInstanceDetails, errorInfo, variables, null, false);
- }
-
- protected RestResponse uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean includeResourceNameInAudit) throws Exception {
- RestResponse restResponse;
-
- if(componentResourceInstanceDetails != null) {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, artifactReqDetails, componentResourceInstanceDetails);
- } else {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails);
-
- }
-
- // validate response code
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct.");
-
- /*// Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API;
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
-// ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
-
- responseArtifact.setUpdaterFullName("");
- responseArtifact.setUserIdLastUpdater(sdncModifierDetails.getUserId());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, component.getUUID(), errorInfo, variables);
- expectedExternalAudit.setRESOURCE_NAME(component.getName());
- expectedExternalAudit.setRESOURCE_TYPE(component.getComponentType().getValue());
- expectedExternalAudit.setARTIFACT_DATA(null);
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
- if(componentResourceInstanceDetails != null) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getComponentInstances().get(0).getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + component.getComponentInstances().get(0).getNormalizedName() + "/artifacts");
- expectedExternalAudit.setRESOURCE_NAME(component.getComponentInstances().get(0).getNormalizedName());
- } else {
- if(includeResourceNameInAudit) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- } else {
- if((lifeCycleStatesEnum == LifeCycleStatesEnum.CHECKIN) || (lifeCycleStatesEnum == LifeCycleStatesEnum.STARTCERTIFICATION)) {
- expectedExternalAudit.setRESOURCE_NAME("");
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "");
- } else {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- }
- }
- }
-
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);*/
-
- return restResponse;
-
- }
-
-
- protected RestResponse uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
- ComponentInstance componentResourceInstanceDetails, ErrorInfo errorInfo, List<String> variables) throws Exception {
- RestResponse restResponse;
-
- if(componentResourceInstanceDetails != null) {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactWithInvalidCheckSumOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
- } else {
- restResponse = ArtifactRestUtils.externalAPIUploadArtifactWithInvalidCheckSumOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails);
-
- }
-
- // validate response code
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct.");
-
- // Check auditing for upload operation
-// ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS.name());
-// = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
-// List<String> variables = asList("artifact name", "255");
-
- /*ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPLOAD_BY_API;
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
-// ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
-
- responseArtifact.setUpdaterFullName("");
- responseArtifact.setUserIdLastUpdater(sdncModifierDetails.getUserId());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, component.getUUID(), errorInfo, variables);
- expectedExternalAudit.setRESOURCE_NAME(component.getName());
- expectedExternalAudit.setRESOURCE_TYPE(component.getComponentType().getValue());
- expectedExternalAudit.setARTIFACT_DATA(null);
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
- if(componentResourceInstanceDetails != null) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getComponentInstances().get(0).getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + component.getComponentInstances().get(0).getNormalizedName() + "/artifacts");
- expectedExternalAudit.setRESOURCE_NAME(component.getComponentInstances().get(0).getNormalizedName());
- } else {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- }
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPLOAD_BY_API.getName(), body);*/
-
- return restResponse;
-
- }
-
-
- @DataProvider(name="uploadArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset", parallel=true)
- public static Object[][] dataProviderUploadArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset() {
- return new Object[][] {
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT},
-
- /*due to those roles are not exists in the system {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT},*/
- };
- }
-
-
- // External API
- // Upload artifact by diffrent user then creator of asset - Fail
- @Test(dataProvider="uploadArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset")
- public void uploadArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset(ComponentTypeEnum componentTypeEnum, UserRoleEnum userRoleEnum, LifeCycleStatesEnum lifeCycleStatesEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, userRoleEnum: %s, lifeCycleStatesEnum: %s", componentTypeEnum, userRoleEnum, lifeCycleStatesEnum));
- Component resourceDetails;
- ComponentInstance componentResourceInstanceDetails = null;
- ArtifactReqDetails artifactReqDetails;
-
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString(), true, false);
-
- resourceDetails = getComponentWithResourceInstanceInTargetLifeCycleState(lifeCycleStatesEnum, null);
- componentResourceInstanceDetails = resourceDetails.getComponentInstances().get(0);
- } else {
- artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.OTHER.toString(), true, false);
-
- resourceDetails = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, lifeCycleStatesEnum, null);
- }
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList();
-
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(userRoleEnum),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, lifeCycleStatesEnum, true);
-
-// if(lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CHECKIN)) {
-// performeClean();
-// }
- }
-
-
- @DataProvider(name="uploadArtifactOnAssetWhichNotExist", parallel=false)
- public static Object[][] dataProviderUploadArtifactOnAssetWhichNotExist() {
- return new Object[][] {
- {ComponentTypeEnum.SERVICE},
- {ComponentTypeEnum.RESOURCE},
- {ComponentTypeEnum.RESOURCE_INSTANCE},
- };
- }
-
-
- // External API
- // Upload artifact on VF via external API - happy flow
- @Test(dataProvider="uploadArtifactOnAssetWhichNotExist")
- public void uploadArtifactOnAssetWhichNotExist(ComponentTypeEnum componentTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s", componentTypeEnum));
- Component resourceDetails;
- ComponentInstance componentResourceInstanceDetails = null;
- ArtifactReqDetails artifactReqDetails;
-
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString(), true, false);
-
- resourceDetails = getComponentWithResourceInstanceInTargetLifeCycleState(LifeCycleStatesEnum.CHECKIN, null);
- componentResourceInstanceDetails = resourceDetails.getComponentInstances().get(0);
-
- resourceDetails.setUUID("12345");
- componentResourceInstanceDetails.setNormalizedName("12345");
- } else {
- artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.OTHER.getType(), true, false);
-
- resourceDetails = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, null);
-
- resourceDetails.setUUID("12345");
- }
-
- String componentTypeError = ActionStatus.RESOURCE_NOT_FOUND.name();
- if (ComponentTypeEnum.SERVICE == componentTypeEnum){
- componentTypeError = ActionStatus.SERVICE_NOT_FOUND.name();
- }
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(componentTypeError);
- List<String> variables = asList(resourceDetails.getUUID());
-
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, false);
-
-// performeClean();
-
- }
-
-
- @DataProvider(name="uploadArtifactOnAssetWhichInInvalidStateForUploading", parallel=true)
- public static Object[][] dataProviderUploadArtifactOnAssetWhichInInvalidStateForUploading() {
- return new Object[][] {
- {ComponentTypeEnum.SERVICE},
- {ComponentTypeEnum.RESOURCE},
- {ComponentTypeEnum.RESOURCE_INSTANCE},
- };
- }
-
-
- @Test(dataProvider="uploadArtifactOnAssetWhichInInvalidStateForUploading")
- public void uploadArtifactOnAssetWhichInInvalidStateForUploading(ComponentTypeEnum componentTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s", componentTypeEnum));
- Component resourceDetails;
- ComponentInstance componentResourceInstanceDetails = null;
- ArtifactReqDetails artifactReqDetails;
-
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString(), true, false);
-
- resourceDetails = getComponentWithResourceInstanceInTargetLifeCycleState(LifeCycleStatesEnum.STARTCERTIFICATION, null);
- componentResourceInstanceDetails = resourceDetails.getComponentInstances().get(0);
- } else {
- artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.OTHER.toString(), true, false);
-
- resourceDetails = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.STARTCERTIFICATION, null);
- }
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
- List<String> variables = asList(resourceDetails.getName(), resourceDetails.getComponentType().toString().toLowerCase(), resourceDetails.getLastUpdaterFullName().split(" ")[0],
- resourceDetails.getLastUpdaterFullName().split(" ")[1], resourceDetails.getLastUpdaterUserId());
-
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, LifeCycleStatesEnum.STARTCERTIFICATION, true);
- }
-
-
- ////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- // Update External API //
- ////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
-
- @DataProvider(name="updateArtifactForServiceViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUpdateArtifactForServiceViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.OTHER.getType()}
- };
- }
-
-
- // Update artifact for Service - Success
- @Test(dataProvider="updateArtifactForServiceViaExternalAPI")
- public void updateArtifactForServiceViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s", lifeCycleStatesEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.SERVICE, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
- updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.SERVICE, lifeCycleStatesEnum, artifactType);
-
- // for certify version check that previous version exist, and that it artifact can be download + checksum
- if(lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CERTIFY)) {
- // Download the uploaded artifact via external API
- downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.SERVICE);
- }
- }
-
- @DataProvider(name="updateArtifactForVFViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUpdateArtifactForVFViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()}
- };
- }
-
-
- // Update artifact for VF - Success
- @Test(dataProvider="updateArtifactForVFViaExternalAPI")
- public void updateArtifactForVFViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s", lifeCycleStatesEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
- updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE, lifeCycleStatesEnum, artifactType);
-
- // for certify version check that previous version exist, and that it artifact can be download + checksum
- if(lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CERTIFY)) {
- // Download the uploaded artifact via external API
- downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE);
- }
- }
-
- @DataProvider(name="updateArtifactForVfcVlCpViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUpdateArtifactForVfcVlCpViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP}
- };
- }
-
-
- // Update artifact for VFC/VL/CP - Success
- @Test(dataProvider="updateArtifactForVfcVlCpViaExternalAPI")
- public void updateArtifactForVfcVlCpViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s, resourceTypeEnum: %s", lifeCycleStatesEnum, artifactType, resourceTypeEnum));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
- updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE, lifeCycleStatesEnum, artifactType);
-
- // for certify version check that previous version exist, and that it artifact can be download + checksum
- if(lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CERTIFY)) {
- // Download the uploaded artifact via external API
- downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE);
- }
- }
-
- @DataProvider(name="updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUpdateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI() {
- return new Object[][] {
- {ResourceTypeEnum.VFC},
- {ResourceTypeEnum.VL},
- {ResourceTypeEnum.CP}
- };
- }
-
- // Verify that it cannot update VFC/VL/CP artifact on VFCi/VLi/CPi - Failure flow
- @Test(dataProvider="updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI")
- public void updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI(ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("resourceTypeEnum: %s", resourceTypeEnum));
-
- Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, resourceTypeEnum);
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", ArtifactTypeEnum.SNMP_TRAP.getType(), true, false);
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceInstanceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
- resourceInstanceDetails = AtomicOperationUtils.changeComponentState(resourceInstanceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
- Component component = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
- component = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name());
- Map<String, ArtifactDefinition> deploymentArtifacts;
- deploymentArtifacts = getDeploymentArtifactsOfAsset(component, ComponentTypeEnum.RESOURCE_INSTANCE);
- String artifactUUID = null;
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci") && StringUtils.isNotEmpty(deploymentArtifacts.get(key).getArtifactUUID())) {
- artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
- break;
- }
- }
- List<String> variables = asList(artifactUUID);
- updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), errorInfo, variables, UserRoleEnum.DESIGNER);
-
- }
-
- @DataProvider(name="updateArtifactOnRIViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUpdateArtifactOnRIViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), null},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), null},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VF}
-
- };
- }
-
- @Test(dataProvider="updateArtifactOnRIViaExternalAPI")
- public void updateArtifactOnRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
- updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState, artifactType);
-
- // for certify version check that previous version exist, and that it artifact can be download + checksum
- if(chosenLifeCycleState.equals(LifeCycleStatesEnum.CERTIFY)) {
- // Download the uploaded artifact via external API
- downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE_INSTANCE);
- }
- }
-
- @DataProvider(name="updateArtifactOnVfcVlCpRIViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUpdateArtifactOnVfcVlCpRIViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP}
-
- };
- }
-
- @Test(dataProvider="updateArtifactOnVfcVlCpRIViaExternalAPI")
- public void updateArtifactOnVfcVlCpRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
- updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState, artifactType);
-
-
- // for certify version check that previous version exist, and that it artifact can be download + checksum
- if(chosenLifeCycleState.equals(LifeCycleStatesEnum.CERTIFY)) {
- // Download the uploaded artifact via external API
- downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE_INSTANCE);
- }
- }
-
- @DataProvider(name="updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset", parallel=true)
- public static Object[][] dataProviderUpdateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset() {
- return new Object[][] {
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- /*due to those roles are not exists in the system {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},*/
- };
- }
-
- // External API
- // Update artifact by diffrent user then creator of asset - Fail
- @Test(dataProvider="updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset")
- public void updateArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset(ComponentTypeEnum componentTypeEnum, UserRoleEnum userRoleEnum, LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
- if(true){
- throw new SkipException("Open bug 321612");
- }
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, userRoleEnum: %s, lifeCycleStatesEnum: %s, artifactType: %s", componentTypeEnum, userRoleEnum, lifeCycleStatesEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null);
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList();
- updateArtifactOnAssetViaExternalAPI(component, componentTypeEnum, lifeCycleStatesEnum, artifactType, errorInfo, variables, userRoleEnum);
- }
-
-
- @DataProvider(name="updateArtifactOnAssetWhichNotExist", parallel=true)
- public static Object[][] dataProviderUpdateArtifactOnAssetWhichNotExist() {
- return new Object[][] {
- {ComponentTypeEnum.SERVICE, ArtifactTypeEnum.OTHER.getType(), null},
- {ComponentTypeEnum.RESOURCE, ArtifactTypeEnum.OTHER.getType(), null},
- {ComponentTypeEnum.RESOURCE_INSTANCE, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VF},
- };
- }
-
- // External API
- // Upload artifact on VF via external API - happy flow
- @Test(dataProvider="updateArtifactOnAssetWhichNotExist")
- public void updateArtifactOnAssetWhichNotExist(ComponentTypeEnum componentTypeEnum, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, resourceTypeEnum);
-
- // get updated artifact data
- Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
- ArtifactReqDetails artifactReqDetails = getUpdatedArtifact(deploymentArtifacts, artifactType);
- String artifactUUID = deploymentArtifacts.get(artifactReqDetails.getArtifactLabel()).getArtifactUUID();
-
- // Invalid artifactUUID
- String invalidArtifactUUID = "12341234-1234-1234-1234-123412341234";
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_NOT_FOUND.name());
- List<String> variables = asList(invalidArtifactUUID);
-
- if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactReqDetails, invalidArtifactUUID, errorInfo, variables, null, true);
- } else {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactReqDetails, invalidArtifactUUID, errorInfo, variables, null, true);
-
- }
-
- // Invalid componentUUID
+ AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.OTHER, component, UserRoleEnum.DESIGNER, true, true).left().value();
+ component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, lifeCycleStatesEnum, true).getLeft();
+ } else {
+ component = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
+ Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, resourceTypeEnum);
+ AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
+ component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, lifeCycleStatesEnum, true).getLeft();
+ }
+ return component;
+ }
+
+ // Upload artifact via external API + Check auditing for upload operation + Check response of external API
+ protected RestResponse uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails);
+
+ // Check response of external API
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
+ return restResponse;
+ }
+
+ // Check Component version (increase by one if not in checkout)
+ // Input: component, componentLifeCycleState
+ // for any LifeCycleState != checkout
+ // find component of version +0.1
+ // check that this version different for input version
+ // check that this component uniqueID different from input uniqueID
+ // Return: that version
+ protected synchronized Component getNewerVersionOfComponent(Component component, LifeCycleStatesEnum lifeCycleStatesEnum) throws Exception {
+ Component resourceDetails = null;
+
+ if ((!lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CHECKOUT)) && (!lifeCycleStatesEnum.equals(LifeCycleStatesEnum.STARTCERTIFICATION))) {
+
+
+ String resourceVersion = component.getVersion();
+ String resourceUniqueID = component.getUniqueId();
+
+ if (component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
+ resourceDetails = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), String.format("%.1f", Double.parseDouble(component.getVersion()) + 0.1));
+ } else {
+ resourceDetails = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), String.format("%.1f", Double.parseDouble(component.getVersion()) + 0.1));
+ }
+
+ String resourceNewVersion = resourceDetails.getVersion();
+ String resourceNewUniqueID = resourceDetails.getUniqueId();
+
+ System.out.println(resourceNewVersion);
+ System.out.println("Service UUID: " + resourceDetails.getUUID());
+ System.out.println("Service UniqueID: " + resourceDetails.getUniqueId());
+
+ // Checking that new version exist + different from old one by unique id
+ Assert.assertNotEquals(resourceVersion, resourceNewVersion, "Expected for different resource version.");
+ Assert.assertNotEquals(resourceUniqueID, resourceNewUniqueID, "Expected that resource will have new unique ID.");
+ } else {
+ if (component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
+ resourceDetails = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
+ } else {
+ resourceDetails = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
+ }
+ }
+ return resourceDetails;
+ }
+
+
+ // download deployment via external api + check response code for success (200) + get artifactReqDetails and verify payload + verify audit
+ protected RestResponse downloadResourceDeploymentArtifactExternalAPI(Component component, ArtifactDefinition artifactDefinition, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, ComponentTypeEnum componentTypeEnum) throws Exception {
+ RestResponse restResponse;
+
+ if (componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) {
+ restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(component.getUUID(), component.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
+ } else {
+ restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(component.getUUID(), artifactDefinition.getArtifactUUID(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
+ }
+
+ Integer responseCode = restResponse.getErrorCode();
+ Integer expectedCode = 200;
+ Assert.assertEquals(responseCode, expectedCode, "Response code is not correct.");
+
+ // For known artifact/payload - verify payload of downloaded artifact
+ if (artifactReqDetails != null) {
+ String response = restResponse.getResponse();
+ String payloadData = artifactReqDetails.getPayload();
+ String decodedPaypload = org.openecomp.sdc.ci.tests.utils.Decoder.decode(payloadData);
+ Assert.assertEquals(response, decodedPaypload, "Response artifact payload not correct.");
+ }
+ return restResponse;
+ }
+
+ // download deployment via external api + check response code for success (200) + verify audit
+ protected void downloadResourceDeploymentArtifactExternalAPI(Component component, ArtifactDefinition artifactDefinition, User sdncModifierDetails) throws Exception {
+ downloadResourceDeploymentArtifactExternalAPI(component, artifactDefinition, sdncModifierDetails, null, component.getComponentType());
+ }
+
+
+ @DataProvider(name = "uploadArtifactOnRIViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUploadArtifactOnRIViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType()},
+
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType()},
+ };
+ }
+
+
+ @Test(dataProvider = "uploadArtifactOnRIViaExternalAPI")
+ public void uploadArtifactOnRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
+ uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState, artifactType, null);
+ }
+
+
+ @DataProvider(name = "uploadArtifactOnVfcVlCpRIViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUploadArtifactOnVfcVlCpRIViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+ };
+ }
+
+
+ @Test(dataProvider = "uploadArtifactOnVfcVlCpRIViaExternalAPI")
+ public void uploadArtifactOnVfcVlCpRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
+ uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState, artifactType, resourceTypeEnum);
+ }
+
+
+ @DataProvider(name = "uploadInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI", parallel = false)
+ public static Object[][] dataProviderUploadInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI() {
+ return new Object[][]{
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeToLong"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidTypeEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidTypeEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidTypeEmpty"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameToLong"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidNameEmpty"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelToLong"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidLabelEmpty"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionToLong"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidDescriptionEmpty"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithSameLabel"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithSameLabel"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "uploadArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "uploadArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "uploadArtifactWithInvalidCheckSum"},
+ };
+ }
+
+
+ // InvalidArtifact + check audit & response code function
+ @Test(dataProvider = "uploadInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI")
+ public void uploadInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState,
+ ComponentTypeEnum componentTypeEnum, String uploadArtifactTestType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, componentTypeEnum: %s, uploadArtifactTestType: %s", chosenLifeCycleState, componentTypeEnum, uploadArtifactTestType));
+ Component resourceDetails;
+ ComponentInstance componentResourceInstanceDetails = null;
+ ArtifactReqDetails artifactReqDetails;
+
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString(), true, false);
+
+ resourceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.SERVICE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
+ resourceDetails = getComponentWithResourceInstanceInTargetLifeCycleState(chosenLifeCycleState, null);
+ componentResourceInstanceDetails = resourceDetails.getComponentInstances().get(0);
+ } else {
+ artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.OTHER.toString(), true, false);
+ resourceDetails = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, chosenLifeCycleState, null);
+ }
+
+
+ switch (uploadArtifactTestType) {
+ case "uploadArtifactWithInvalidTypeToLong":
+ uploadArtifactWithInvalidTypeToLong(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithInvalidTypeEmpty":
+ uploadArtifactWithInvalidTypeEmpty(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithInvalidCheckSum":
+ uploadArtifactWithInvalidCheckSum(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithInvalidNameToLong":
+ uploadArtifactWithInvalidNameToLong(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithInvalidNameEmpty":
+ uploadArtifactWithInvalidNameEmpty(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithInvalidLabelToLong":
+ uploadArtifactWithInvalidLabelToLong(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithInvalidLabelEmpty":
+ uploadArtifactWithInvalidLabelEmpty(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithInvalidDescriptionToLong":
+ uploadArtifactWithInvalidDescriptionToLong(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithInvalidDescriptionEmpty":
+ uploadArtifactWithInvalidDescriptionEmpty(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ case "uploadArtifactWithSameLabel":
+ default:
+ uploadArtifactWithSameLabel(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ break;
+ }
+ }
+
+ // Upload artifact with invalid type via external API - to long type
+ protected void uploadArtifactWithInvalidTypeToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+ artifactReqDetails.setArtifactType("dsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfdsdsfdsfds");
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
+ List<String> variables = asList(artifactReqDetails.getArtifactType());
+
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+ // Upload artifact with invalid type via external API - empty type
+ protected void uploadArtifactWithInvalidTypeEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+ artifactReqDetails.setArtifactType("");
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED.name());
+ List<String> variables = asList(artifactReqDetails.getArtifactType());
+
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+ // Upload artifact with invalid checksum via external API
+ protected void uploadArtifactWithInvalidCheckSum(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_INVALID_MD5.name());
+ List<String> variables = asList();
+ uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables);
+ }
+
+ // Upload artifact with valid type & invalid name via external API - name to long
+ protected void uploadArtifactWithInvalidNameToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
+ List<String> variables = asList("artifact name", "255");
+ artifactReqDetails.setArtifactName("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+ // Upload artifact with valid type & invalid name via external API - name is empty
+ protected void uploadArtifactWithInvalidNameEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_ARTIFACT_NAME.name());
+ List<String> variables = asList();
+
+ artifactReqDetails.setArtifactName("");
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+
+ // Upload artifact with valid type & invalid label via external API - label to long
+ protected void uploadArtifactWithInvalidLabelToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
+ List<String> variables = asList("artifact label", "255");
+ artifactReqDetails.setArtifactLabel("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+ // Upload artifact with valid type & invalid label via external API - label is empty
+ protected void uploadArtifactWithInvalidLabelEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
+ List<String> variables = asList("artifact label");
+ artifactReqDetails.setArtifactLabel("");
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+ // Upload artifact with invalid description via external API - to long description
+ protected void uploadArtifactWithInvalidDescriptionToLong(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
+ List<String> variables = asList("artifact description", "256");
+ artifactReqDetails.setDescription("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+
+ // Upload artifact with invalid description via external API - empty description
+ protected void uploadArtifactWithInvalidDescriptionEmpty(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
+ List<String> variables = asList("artifact description");
+ artifactReqDetails.setDescription("");
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+ // Upload artifact with same label via external API
+ protected void uploadArtifactWithSameLabel(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails) throws Exception {
+
+ RestResponse restResponse = null;
+ if (componentResourceInstanceDetails != null) {
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ } else {
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails);
+
+ }
+
+ ArtifactDefinition artifactDefinition = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse());
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_EXIST.name());
+
+ List<String> variables = asList(artifactDefinition.getArtifactDisplayName());
+ ArtifactReqDetails artifactReqDetailsSameLabel = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_EVENT.toString(), true, false);
+ artifactReqDetailsSameLabel.setArtifactLabel(artifactReqDetails.getArtifactLabel());
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetailsSameLabel, componentResourceInstanceDetails, errorInfo, variables, null, false);
+ }
+
+ protected RestResponse uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean includeResourceNameInAudit) throws Exception {
+ RestResponse restResponse;
+ if (componentResourceInstanceDetails != null) {
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, artifactReqDetails, componentResourceInstanceDetails);
+ } else {
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails);
+
+ }
+ // validate response code
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct.");
+ return restResponse;
+ }
+
+
+ protected RestResponse uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails,
+ ComponentInstance componentResourceInstanceDetails, ErrorInfo errorInfo, List<String> variables) throws Exception {
+ RestResponse restResponse;
+ if (componentResourceInstanceDetails != null) {
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactWithInvalidCheckSumOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
+ } else {
+ restResponse = ArtifactRestUtils.externalAPIUploadArtifactWithInvalidCheckSumOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails);
+
+ }
+ // validate response code
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct.");
+ return restResponse;
+
+ }
+
+ @DataProvider(name = "uploadArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset", parallel = true)
+ public static Object[][] dataProviderUploadArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset() {
+ return new Object[][]{
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT},
+ };
+ }
+
+ // External API
+ // Upload artifact by diffrent user then creator of asset - Fail
+ @Test(dataProvider = "uploadArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset")
+ public void uploadArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset(ComponentTypeEnum componentTypeEnum, UserRoleEnum userRoleEnum, LifeCycleStatesEnum lifeCycleStatesEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, userRoleEnum: %s, lifeCycleStatesEnum: %s", componentTypeEnum, userRoleEnum, lifeCycleStatesEnum));
+ Component resourceDetails;
+ ComponentInstance componentResourceInstanceDetails = null;
+ ArtifactReqDetails artifactReqDetails;
+
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString(), true, false);
+
+ resourceDetails = getComponentWithResourceInstanceInTargetLifeCycleState(lifeCycleStatesEnum, null);
+ componentResourceInstanceDetails = resourceDetails.getComponentInstances().get(0);
+ } else {
+ artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.OTHER.toString(), true, false);
+
+ resourceDetails = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, lifeCycleStatesEnum, null);
+ }
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
+ List<String> variables = asList();
+
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(userRoleEnum),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, lifeCycleStatesEnum, true);
+
+ }
+
+ @DataProvider(name = "uploadArtifactOnAssetWhichNotExist", parallel = true)
+ public static Object[][] dataProviderUploadArtifactOnAssetWhichNotExist() {
+ return new Object[][]{
+ {ComponentTypeEnum.SERVICE},
+ {ComponentTypeEnum.RESOURCE},
+ {ComponentTypeEnum.RESOURCE_INSTANCE},
+ };
+ }
+
+ // External API
+ // Upload artifact on VF via external API - happy flow
+ @Test(dataProvider = "uploadArtifactOnAssetWhichNotExist")
+ public void uploadArtifactOnAssetWhichNotExist(ComponentTypeEnum componentTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s", componentTypeEnum));
+ Component resourceDetails;
+ ComponentInstance componentResourceInstanceDetails = null;
+ ArtifactReqDetails artifactReqDetails;
+
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString(), true, false);
+
+ resourceDetails = getComponentWithResourceInstanceInTargetLifeCycleState(LifeCycleStatesEnum.CHECKIN, null);
+ componentResourceInstanceDetails = resourceDetails.getComponentInstances().get(0);
+
+ resourceDetails.setUUID("12345");
+ componentResourceInstanceDetails.setNormalizedName("12345");
+ } else {
+ artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.OTHER.getType(), true, false);
+
+ resourceDetails = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, null);
+
+ resourceDetails.setUUID("12345");
+ }
+
+ String componentTypeError = ActionStatus.RESOURCE_NOT_FOUND.name();
+ if (ComponentTypeEnum.SERVICE == componentTypeEnum) {
+ componentTypeError = ActionStatus.SERVICE_NOT_FOUND.name();
+ }
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(componentTypeError);
+ List<String> variables = asList(resourceDetails.getUUID());
+
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, false);
+ }
+
+ @DataProvider(name = "uploadArtifactOnAssetWhichInInvalidStateForUploading", parallel = true)
+ public static Object[][] dataProviderUploadArtifactOnAssetWhichInInvalidStateForUploading() {
+ return new Object[][]{
+ {ComponentTypeEnum.SERVICE},
+ };
+ }
+
+ @Test(dataProvider = "uploadArtifactOnAssetWhichInInvalidStateForUploading")
+ public void uploadArtifactOnAssetWhichInInvalidStateForUploading(ComponentTypeEnum componentTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s", componentTypeEnum));
+ ComponentInstance componentResourceInstanceDetails = null;
+
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("Abcd", ArtifactTypeEnum.OTHER.toString(), true, false);
+ Component resourceDetails = getComponentInTargetLifeCycleState(componentTypeEnum.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.STARTCERTIFICATION, null);
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
+ List<String> variables = asList(resourceDetails.getName(), resourceDetails.getComponentType().toString().toLowerCase(), resourceDetails.getLastUpdaterFullName().split(" ")[0],
+ resourceDetails.getLastUpdaterFullName().split(" ")[1], resourceDetails.getLastUpdaterUserId());
+
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables, LifeCycleStatesEnum.STARTCERTIFICATION, true);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+ // Update External API //
+ ////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+
+ @DataProvider(name = "updateArtifactForServiceViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUpdateArtifactForServiceViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.OTHER.getType()}
+ };
+ }
+
+ // Update artifact for Service - Success
+ @Test(dataProvider = "updateArtifactForServiceViaExternalAPI")
+ public void updateArtifactForServiceViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s", lifeCycleStatesEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.SERVICE, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
+ updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.SERVICE, lifeCycleStatesEnum, artifactType);
+
+ // for certify version check that previous version exist, and that it artifact can be download + checksum
+ if (lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CERTIFY)) {
+ // Download the uploaded artifact via external API
+ downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.SERVICE);
+ }
+ }
+
+ @DataProvider(name = "updateArtifactForVFViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUpdateArtifactForVFViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_JSON.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_POLICY.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_EVENT.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.APPC_CONFIG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_DOC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_TOSCA.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_JSON.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_POLICY.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_EVENT.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.APPC_CONFIG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_DOC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_TOSCA.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ };
+ }
+
+ // Update artifact for VF - Success
+ @Test(dataProvider = "updateArtifactForVFViaExternalAPI")
+ public void updateArtifactForVFViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s", lifeCycleStatesEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
+ updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE, lifeCycleStatesEnum, artifactType);
+
+ // for certify version check that previous version exist, and that it artifact can be download + checksum
+ if (lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CERTIFY)) {
+ // Download the uploaded artifact via external API
+ downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE);
+ }
+ }
+
+ @DataProvider(name = "updateArtifactForVfcVlCpViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUpdateArtifactForVfcVlCpViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+ };
+ }
+
+ // Update artifact for VFC/VL/CP - Success
+ @Test(dataProvider = "updateArtifactForVfcVlCpViaExternalAPI")
+ public void updateArtifactForVfcVlCpViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s, resourceTypeEnum: %s", lifeCycleStatesEnum, artifactType, resourceTypeEnum));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
+ updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE, lifeCycleStatesEnum, artifactType);
+
+ // for certify version check that previous version exist, and that it artifact can be download + checksum
+ if (lifeCycleStatesEnum.equals(LifeCycleStatesEnum.CERTIFY)) {
+ // Download the uploaded artifact via external API
+ downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE);
+ }
+ }
+
+ @DataProvider(name = "updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUpdateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI() {
+ return new Object[][]{
+ {ResourceTypeEnum.VFC},
+ {ResourceTypeEnum.VL},
+ {ResourceTypeEnum.CP}
+ };
+ }
+
+ // Verify that it cannot update VFC/VL/CP artifact on VFCi/VLi/CPi - Failure flow
+ @Test(dataProvider = "updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI")
+ public void updateArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI(ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("resourceTypeEnum: %s", resourceTypeEnum));
+
+ Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, resourceTypeEnum);
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", ArtifactTypeEnum.SNMP_TRAP.getType(), true, false);
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceInstanceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
+ resourceInstanceDetails = AtomicOperationUtils.changeComponentState(resourceInstanceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
+ Component component = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
+ AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
+ component = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name());
+ Map<String, ArtifactDefinition> deploymentArtifacts;
+ deploymentArtifacts = getDeploymentArtifactsOfAsset(component, ComponentTypeEnum.RESOURCE_INSTANCE);
+ String artifactUUID = null;
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci") && StringUtils.isNotEmpty(deploymentArtifacts.get(key).getArtifactUUID())) {
+ artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
+ break;
+ }
+ }
+ List<String> variables = asList(artifactUUID);
+ updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), errorInfo, variables, UserRoleEnum.DESIGNER);
+
+ }
+
+ @DataProvider(name = "updateArtifactOnRIViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUpdateArtifactOnRIViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), null},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), null},
+
+ };
+ }
+
+ @Test(dataProvider = "updateArtifactOnRIViaExternalAPI")
+ public void updateArtifactOnRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
+ updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState, artifactType);
+
+ // for certify version check that previous version exist, and that it artifact can be download + checksum
+ if (chosenLifeCycleState.equals(LifeCycleStatesEnum.CERTIFY)) {
+ // Download the uploaded artifact via external API
+ downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE_INSTANCE);
+ }
+ }
+
+ @DataProvider(name = "updateArtifactOnVfcVlCpRIViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUpdateArtifactOnVfcVlCpRIViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+ };
+ }
+
+ @Test(dataProvider = "updateArtifactOnVfcVlCpRIViaExternalAPI")
+ public void updateArtifactOnVfcVlCpRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
+ updateArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState, artifactType);
+
+
+ // for certify version check that previous version exist, and that it artifact can be download + checksum
+ if (chosenLifeCycleState.equals(LifeCycleStatesEnum.CERTIFY)) {
+ // Download the uploaded artifact via external API
+ downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(component, artifactType, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE_INSTANCE);
+ }
+ }
+
+ @DataProvider(name = "updateArtifactOnVFViaExternalAPIByDifferentUserThenCreatorOfAsset", parallel = true)
+ public static Object[][] dataProviderUpdateArtifactOnVFViaExternalAPIByDifferentUserThenCreatorOfAsset() {
+ return new Object[][]{
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ };
+ }
+
+ // External API
+ // Update artifact by different user then creator of asset - Fail
+ @Test(dataProvider = "updateArtifactOnVFViaExternalAPIByDifferentUserThenCreatorOfAsset")
+ public void updateArtifactOnVFViaExternalAPIByDifferentUserThenCreatorOfAsset(ComponentTypeEnum componentTypeEnum, UserRoleEnum userRoleEnum, LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, userRoleEnum: %s, lifeCycleStatesEnum: %s, artifactType: %s", componentTypeEnum, userRoleEnum, lifeCycleStatesEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null);
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
+ List<String> variables = asList();
+ updateArtifactOnAssetViaExternalAPI(component, componentTypeEnum, lifeCycleStatesEnum, artifactType, errorInfo, variables, userRoleEnum);
+ }
+
+ @DataProvider(name = "updateArtifactOnAssetWhichNotExist", parallel = true)
+ public static Object[][] dataProviderUpdateArtifactOnAssetWhichNotExist() {
+ return new Object[][]{
+ {ComponentTypeEnum.SERVICE, ArtifactTypeEnum.OTHER.getType(), null},
+ {ComponentTypeEnum.RESOURCE, ArtifactTypeEnum.OTHER.getType(), null},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VF},
+ };
+ }
+
+ // External API
+ // Upload artifact on VF via external API - happy flow
+ @Test(dataProvider = "updateArtifactOnAssetWhichNotExist")
+ public void updateArtifactOnAssetWhichNotExist(ComponentTypeEnum componentTypeEnum, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, resourceTypeEnum);
+
+ // get updated artifact data
+ Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+ ArtifactReqDetails artifactReqDetails = getUpdatedArtifact(deploymentArtifacts, artifactType);
+ String artifactUUID = deploymentArtifacts.get(artifactReqDetails.getArtifactLabel()).getArtifactUUID();
+
+ // Invalid artifactUUID
+ String invalidArtifactUUID = "12341234-1234-1234-1234-123412341234";
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_NOT_FOUND.name());
+ List<String> variables = asList(invalidArtifactUUID);
+
+ if (componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactReqDetails, invalidArtifactUUID, errorInfo, variables, null, true);
+ } else {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactReqDetails, invalidArtifactUUID, errorInfo, variables, null, true);
+
+ }
+
+ // Invalid componentUUID
// errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name());
// variables = asList("null");
-
- if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
- component.getComponentInstances().get(0).setNormalizedName("invalidNormalizedName");
-
- errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER.name());
-
- variables = asList("invalidNormalizedName", ComponentTypeEnum.RESOURCE_INSTANCE.getValue().toLowerCase(), ComponentTypeEnum.SERVICE.getValue(), component.getName());
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, true);
- } else {
- component.setUUID("invalidComponentUUID");
-
- errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name());
- variables = asList("null");
-
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactReqDetails, artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, false);
- }
-
- performClean();
- }
-
-
- @DataProvider(name="updateArtifactOnAssetWhichInInvalidStateForUploading", parallel=true)
- public static Object[][] dataProviderUpdateProviderDeleteArtifactOnAssetWhichInInvalidStateForUploading() {
- return new Object[][] {
- {ComponentTypeEnum.SERVICE, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- };
- }
-
- @Test(dataProvider="updateArtifactOnAssetWhichInInvalidStateForUploading")
- public void updateArtifactOnAssetWhichInInvalidStateForUploading(ComponentTypeEnum componentTypeEnum, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null);
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
- List<String> variables = asList(component.getName(), component.getComponentType().toString().toLowerCase(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getFirstName(),
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getLastName(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getUserId());
- updateArtifactOnAssetViaExternalAPI(component, componentTypeEnum, LifeCycleStatesEnum.STARTCERTIFICATION, artifactType, errorInfo, variables, UserRoleEnum.DESIGNER);
-
- }
-
-
-
-
-
- @DataProvider(name="updateInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI", parallel=true)
- public static Object[][] dataProviderUpdateInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidCheckSum"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidCheckSum"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameToLong"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameEmpty"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelToLong"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelEmpty"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionToLong"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionToLong"},
-
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionEmpty"},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionEmpty"},
- };
- }
-
-
- // InvalidArtifact + check audit & response code function
- @Test(dataProvider="updateInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI")
- public void updateInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState,
- ComponentTypeEnum componentTypeEnum, String uploadArtifactTestType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, componentTypeEnum: %s, uploadArtifactTestType: %s", chosenLifeCycleState, componentTypeEnum, uploadArtifactTestType));
- Component component;
- ComponentInstance componentInstance = null;
- String artifactType;
-
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- artifactType = ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString();
- component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null);
- componentInstance = component.getComponentInstances().get(0);
- } else {
- artifactType = ArtifactTypeEnum.OTHER.toString();
- component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null);
- }
-
- component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
-
- switch (uploadArtifactTestType) {
- case "updateArtifactWithInvalidCheckSum":
- updateArtifactWithInvalidCheckSum(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
- break;
- case "updateArtifactWithInvalidNameToLong":
- updateArtifactWithInvalidNameToLong(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
- break;
- case "updateArtifactWithInvalidNameEmpty":
- updateArtifactWithInvalidNameEmpty(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
- break;
- case "updateArtifactWithInvalidLabelToLong":
- updateArtifactWithInvalidLabelToLong(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
- break;
- case "updateArtifactWithInvalidLabelEmpty":
- updateArtifactWithInvalidLabelEmpty(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
- break;
- case "updateArtifactWithInvalidDescriptionToLong":
- updateArtifactWithInvalidDescriptionToLong(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
- break;
- case "updateArtifactWithInvalidDescriptionEmpty":
- default:
- updateArtifactWithInvalidDescriptionEmpty(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
- break;
- }
-
+
+ if (componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
+ component.getComponentInstances().get(0).setNormalizedName("invalidNormalizedName");
+
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER.name());
+
+ variables = asList("invalidNormalizedName", ComponentTypeEnum.RESOURCE_INSTANCE.getValue().toLowerCase(), ComponentTypeEnum.SERVICE.getValue(), component.getName());
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, true);
+ } else {
+ component.setUUID("invalidComponentUUID");
+
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name());
+ variables = asList("null");
+
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactReqDetails, artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, false);
+ }
+ performClean();
+ }
+
+ @DataProvider(name = "updateArtifactOnAssetWhichInInvalidStateForUploading", parallel = true)
+ public static Object[][] dataProviderUpdateProviderDeleteArtifactOnAssetWhichInInvalidStateForUploading() {
+ return new Object[][]{
+ {ComponentTypeEnum.SERVICE, ArtifactTypeEnum.OTHER.getType()},
+ };
+ }
+
+ @Test(dataProvider = "updateArtifactOnAssetWhichInInvalidStateForUploading")
+ public void updateArtifactOnAssetWhichInInvalidStateForUploading(ComponentTypeEnum componentTypeEnum, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null);
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
+ List<String> variables = asList(component.getName(), component.getComponentType().toString().toLowerCase(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getFirstName(),
+ ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getLastName(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getUserId());
+ updateArtifactOnAssetViaExternalAPI(component, componentTypeEnum, LifeCycleStatesEnum.STARTCERTIFICATION, artifactType, errorInfo, variables, UserRoleEnum.DESIGNER);
+
+ }
+
+ @DataProvider(name = "updateInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderUpdateInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidCheckSum"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidCheckSum"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameToLong"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidNameEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidNameEmpty"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelToLong"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidLabelEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidLabelEmpty"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionToLong"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionToLong"},
+
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKOUT, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE, "updateArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CHECKIN, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.SERVICE, "updateArtifactWithInvalidDescriptionEmpty"},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ComponentTypeEnum.RESOURCE_INSTANCE, "updateArtifactWithInvalidDescriptionEmpty"},
+ };
+ }
+
+ // InvalidArtifact + check audit & response code function
+ @Test(dataProvider = "updateInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI")
+ public void updateInvalidArtifactTypeExtensionLabelDescriptionCheckSumDuplicateLabelViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState,
+ ComponentTypeEnum componentTypeEnum, String uploadArtifactTestType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, componentTypeEnum: %s, uploadArtifactTestType: %s", chosenLifeCycleState, componentTypeEnum, uploadArtifactTestType));
+ Component component;
+ ComponentInstance componentInstance = null;
+ String artifactType;
+
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ artifactType = ArtifactTypeEnum.DCAE_INVENTORY_DOC.toString();
+ component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null);
+ componentInstance = component.getComponentInstances().get(0);
+ } else {
+ artifactType = ArtifactTypeEnum.OTHER.toString();
+ component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, null);
+ }
+
+ component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
+
+ switch (uploadArtifactTestType) {
+ case "updateArtifactWithInvalidCheckSum":
+ updateArtifactWithInvalidCheckSum(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
+ break;
+ case "updateArtifactWithInvalidNameToLong":
+ updateArtifactWithInvalidNameToLong(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
+ break;
+ case "updateArtifactWithInvalidNameEmpty":
+ updateArtifactWithInvalidNameEmpty(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
+ break;
+ case "updateArtifactWithInvalidLabelToLong":
+ updateArtifactWithInvalidLabelToLong(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
+ break;
+ case "updateArtifactWithInvalidLabelEmpty":
+ updateArtifactWithInvalidLabelEmpty(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
+ break;
+ case "updateArtifactWithInvalidDescriptionToLong":
+ updateArtifactWithInvalidDescriptionToLong(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
+ break;
+ case "updateArtifactWithInvalidDescriptionEmpty":
+ default:
+ updateArtifactWithInvalidDescriptionEmpty(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactType, componentInstance);
+ break;
+ }
+
///////////////////////////////////////////////////////////////////////////////
// // TODO: there is defect when checking invalid type
//// // Upload artifact with invalid type via external API
@@ -1925,1285 +1481,962 @@ public class CRUDExternalAPI extends ComponentBaseTest {
//// restResponse = uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentResourceInstanceDetails);
//// artifactReqDetails.setArtifactType(artifactType);
///////////////////////////////////////////////////////////////////////////////
- }
-
- // TODO
- // Update artifact with invalid checksum via external API
- protected void updateArtifactWithInvalidCheckSum(Component component, User sdncModifierDetails, String artifactType, ComponentInstance componentInstance) throws Exception {
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_INVALID_MD5.name());
- List<String> variables = asList();
-// uploadArtifactWithInvalidCheckSumOfAssetIncludingValiditionOfAuditAndResponseCode(resourceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
-// artifactReqDetails, componentResourceInstanceDetails, errorInfo, variables);
- }
-
-
- // Update artifact with valid type & invalid name via external API - name to long
- protected void updateArtifactWithInvalidNameToLong(Component component, User sdncModifierDetails, String artifactType,
- ComponentInstance componentInstance) throws Exception {
-
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
- String artifactUUID = getFirstArtifactUuidFromComponent(component);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
- List<String> variables = asList("artifact name", "255");
- artifactReqDetails.setArtifactName("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
-
- if(componentInstance != null) {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
- } else {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
-
- }
- }
-
-
- // Update artifact with valid type & invalid name via external API - name is empty
- protected void updateArtifactWithInvalidNameEmpty(Component component, User sdncModifierDetails, String artifactType,
- ComponentInstance componentInstance) throws Exception {
-
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
- String artifactUUID = getFirstArtifactUuidFromComponent(component);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_ARTIFACT_NAME.name());
- List<String> variables = asList();
- artifactReqDetails.setArtifactName("");
-
- if(componentInstance != null) {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
- } else {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
-
- }
- }
-
-
- // Update artifact with valid type & invalid label via external API - label to long -
+ }
+
+ // TODO
+ // Update artifact with invalid checksum via external API
+ protected void updateArtifactWithInvalidCheckSum(Component component, User sdncModifierDetails, String artifactType, ComponentInstance componentInstance) throws Exception {
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_INVALID_MD5.name());
+ List<String> variables = asList();
+ }
+
+
+ // Update artifact with valid type & invalid name via external API - name to long
+ protected void updateArtifactWithInvalidNameToLong(Component component, User sdncModifierDetails, String artifactType,
+ ComponentInstance componentInstance) throws Exception {
+
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
+ String artifactUUID = getFirstArtifactUuidFromComponent(component);
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
+ List<String> variables = asList("artifact name", "255");
+ artifactReqDetails.setArtifactName("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
+
+ if (componentInstance != null) {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ } else {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+
+ }
+ }
+
+ // Update artifact with valid type & invalid name via external API - name is empty
+ protected void updateArtifactWithInvalidNameEmpty(Component component, User sdncModifierDetails, String artifactType,
+ ComponentInstance componentInstance) throws Exception {
+
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
+ String artifactUUID = getFirstArtifactUuidFromComponent(component);
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_ARTIFACT_NAME.name());
+ List<String> variables = asList();
+ artifactReqDetails.setArtifactName("");
+
+ if (componentInstance != null) {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ } else {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+
+ }
+ }
+
+ // Update artifact with valid type & invalid label via external API - label to long -
// according to the newest AID doc artifactLabel, artifactType, artifactGroupType parameters should be ignored
- protected void updateArtifactWithInvalidLabelToLong(Component component, User sdncModifierDetails, String artifactType,
- ComponentInstance componentInstance) throws Exception {
-
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
- String artifactUUID = getFirstArtifactUuidFromComponent(component);
-
-// ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED.name());
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name());
-// List<String> variables = asList();
- artifactReqDetails.setArtifactLabel("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
-
- if(componentInstance != null) {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, null, null, true);
- } else {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactReqDetails, artifactUUID, errorInfo, null, null, true);
-
- }
- }
-
-
- // Update artifact with valid type & invalid label via external API - label is empty
+ protected void updateArtifactWithInvalidLabelToLong(Component component, User sdncModifierDetails, String artifactType,
+ ComponentInstance componentInstance) throws Exception {
+
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
+ String artifactUUID = getFirstArtifactUuidFromComponent(component);
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name());
+ artifactReqDetails.setArtifactLabel("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
+
+ if (componentInstance != null) {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, null, null, true);
+ } else {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactReqDetails, artifactUUID, errorInfo, null, null, true);
+
+ }
+ }
+
+ // Update artifact with valid type & invalid label via external API - label is empty
// according to the newest AID doc artifactLabel, artifactType, artifactGroupType parameters should be ignored
- protected void updateArtifactWithInvalidLabelEmpty(Component component, User sdncModifierDetails, String artifactType,
- ComponentInstance componentInstance) throws Exception {
-
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
- String artifactUUID = getFirstArtifactUuidFromComponent(component);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name());
- artifactReqDetails.setArtifactLabel("");
-
- if(componentInstance != null) {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, null, null, true);
- } else {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactReqDetails, artifactUUID, errorInfo, null, null, true);
-
- }
- }
-
-
- // Update artifact with invalid description via external API - to long description
- protected void updateArtifactWithInvalidDescriptionToLong(Component component, User sdncModifierDetails, String artifactType,
- ComponentInstance componentInstance) throws Exception {
-
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
- String artifactUUID = getFirstArtifactUuidFromComponent(component);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
- List<String> variables = asList("artifact description", ValidationUtils.ARTIFACT_DESCRIPTION_MAX_LENGTH.toString());
- artifactReqDetails.setDescription("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
-
- if(componentInstance != null) {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
- } else {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
-
- }
- }
-
- public String getFirstArtifactUuidFromComponent(Component component) {
- String artifactUUID = null;
- Map<String, ArtifactDefinition> deploymentArtifacts;
- if(component.getComponentInstances() != null) {
- deploymentArtifacts = component.getComponentInstances().get(0).getDeploymentArtifacts();
- } else {
- deploymentArtifacts = component.getDeploymentArtifacts();
- }
-
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci")) {
- artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
- break;
- }
- }
- return artifactUUID;
- }
-
-
- // Update artifact with invalid description via external API - empty description
- protected void updateArtifactWithInvalidDescriptionEmpty(Component component, User sdncModifierDetails, String artifactType,
- ComponentInstance componentInstance) throws Exception {
-
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
- String artifactUUID = getFirstArtifactUuidFromComponent(component);
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
- List<String> variables = asList("artifact description");
- artifactReqDetails.setDescription("");
-
- if(componentInstance != null) {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
- } else {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
-
- }
- }
-
-
- // Unhappy flow - get chosen life cycle state, artifact type and asset type
- // update artifact via external API + check audit & response code
- // Download artifact via external API + check audit & response code
- // Check artifact version, uuid & checksusm
- protected Component updateArtifactOnAssetViaExternalAPI(Component component, ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ErrorInfo errorInfo, List<String> variables, UserRoleEnum userRoleEnum) throws Exception {
- String componentVersionBeforeUpdate = null;
-
- // get updated artifact data
- component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
- componentVersionBeforeUpdate = component.getVersion();
-
- Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
- ArtifactReqDetails artifactReqDetails = getUpdatedArtifact(deploymentArtifacts, artifactType);
-
- String artifactName = artifactReqDetails.getArtifactLabel();
- String artifactUUID = deploymentArtifacts.get(artifactName).getArtifactUUID();
- String artifactVersionBeforeUpdate = deploymentArtifacts.get(artifactName).getArtifactVersion();
- int numberOfArtifact = deploymentArtifacts.size();
-
- ArtifactReqDetails updateArtifactReqDetails = ElementFactory.getArtifactByType(ArtifactTypeEnum.SNMP_POLL.name(), ArtifactTypeEnum.SNMP_POLL.name(), true, true);
- updateArtifactReqDetails.setPayload("dGVzdA==");
-
- // create component/s & upload artifact via external api
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
- component.getComponentInstances().get(0), updateArtifactReqDetails, artifactUUID, errorInfo, variables, chosenLifeCycleState, true);
- } else {
- updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
- null, updateArtifactReqDetails, artifactUUID, errorInfo, variables, chosenLifeCycleState, true);
- }
-
- if(component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
- component = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
- } else {
- component = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
- }
-
- // Get list of deployment artifact + download them via external API
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- deploymentArtifacts = component.getComponentInstances().get(0).getDeploymentArtifacts();
- } else {
- deploymentArtifacts = component.getDeploymentArtifacts();
- }
- Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will be same as before.");
- Assert.assertEquals(componentVersionBeforeUpdate, component.getVersion(), "Expected that check-out component will not change version number.");
- if (errorInfo.getCode().equals(200)) {
- Assert.assertNotEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate))), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Artifact version should be changed.");
- Assert.assertNotEquals(artifactUUID, deploymentArtifacts.get(artifactName).getArtifactUUID(), "Artifact UUID should be changed.");
- }else{
- Assert.assertEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate))), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Artifact version should not be changed.");
- Assert.assertEquals(artifactUUID, deploymentArtifacts.get(artifactName).getArtifactUUID(), "Artifact UUID should not be changed.");
- }
-
-
- return component;
- }
-
- protected RestResponse updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails,
- ComponentInstance componentInstance, ArtifactReqDetails artifactReqDetails, String artifactUUID, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean resourceNameInAudit) throws Exception {
- RestResponse restResponse;
-
- if(componentInstance != null) {
- restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, artifactReqDetails, componentInstance, artifactUUID);
- } else {
- restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails, artifactUUID);
-
- }
- // validate response code
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct.");
- component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
-
- /* //TODO
- // Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPDATE_BY_API;
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
-// ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
-
- responseArtifact.setUpdaterFullName("");
- responseArtifact.setUserIdLastUpdater(sdncModifierDetails.getUserId());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, component.getUUID(), errorInfo, variables);
- expectedExternalAudit.setRESOURCE_NAME(component.getName());
- expectedExternalAudit.setRESOURCE_TYPE(component.getComponentType().getValue());
- expectedExternalAudit.setARTIFACT_DATA("");
- if(errorInfo.getCode()==200){
- expectedExternalAudit.setCURR_ARTIFACT_UUID(responseArtifact.getArtifactUUID());
- expectedExternalAudit.setARTIFACT_DATA(AuditValidationUtils.buildArtifactDataAudit(responseArtifact));
- }else{
- expectedExternalAudit.setCURR_ARTIFACT_UUID(artifactUUID);
- }
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
- if(componentInstance != null) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getComponentInstances().get(0).getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + component.getComponentInstances().get(0).getNormalizedName() + "/artifacts/" + artifactUUID);
- expectedExternalAudit.setRESOURCE_NAME(component.getComponentInstances().get(0).getNormalizedName());
- } else {
- expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL() + "/" + artifactUUID);
- if((lifeCycleStatesEnum == LifeCycleStatesEnum.CHECKIN) || (lifeCycleStatesEnum == LifeCycleStatesEnum.STARTCERTIFICATION)) {
- if(resourceNameInAudit) {
- expectedExternalAudit.setRESOURCE_NAME(component.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- } else {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
-// body.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
- expectedExternalAudit.setRESOURCE_NAME("");
- }
- } else {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- }
- }
-
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body);*/
- return restResponse;
- }
-
-
- // This function get component, user & if updatedPayload or not
- // It will create default payload / updated payload of artifact
- // And download artifact of component which starts with ci
- protected RestResponse downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(Component component, String artifactType, User sdncModifierDetails, ComponentTypeEnum componentTypeEnum) throws IOException, Exception {
- // Download the uploaded artifact via external API
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("abcd", artifactType, true, false);
- String artifactName = null;
- for (String key : component.getDeploymentArtifacts().keySet()) {
- if (key.startsWith("ci")) {
- artifactName = key;
- break;
- }
- }
- return downloadResourceDeploymentArtifactExternalAPI(component, component.getDeploymentArtifacts().get(artifactName), sdncModifierDetails, artifactReqDetails, componentTypeEnum);
- }
-
- // Get deployment artifact of RI
- protected Map<String, ArtifactDefinition> getDeploymentArtifactsOfAsset(Component component, ComponentTypeEnum componentTypeEnum) {
- Map<String, ArtifactDefinition> deploymentArtifacts = null;
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- for(ComponentInstance componentInstance: component.getComponentInstances()) {
- if(componentInstance.getNormalizedName().startsWith("ci")) {
- deploymentArtifacts = componentInstance.getDeploymentArtifacts();
- break;
- }
- }
- } else {
- deploymentArtifacts = component.getDeploymentArtifacts();
- }
- return deploymentArtifacts;
- }
-
- // get deploymentArtifact of asset and artifactType -> generate new artifact that can be updated on the asset
- protected ArtifactReqDetails getUpdatedArtifact(Map<String, ArtifactDefinition> deploymentArtifacts, String artifactType) throws IOException, Exception {
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
-
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci")) {
- artifactReqDetails.setArtifactDisplayName(deploymentArtifacts.get(key).getArtifactDisplayName());
- artifactReqDetails.setArtifactName(deploymentArtifacts.get(key).getArtifactName());
- artifactReqDetails.setArtifactLabel(deploymentArtifacts.get(key).getArtifactLabel());
- break;
- }
- }
-
- return artifactReqDetails;
- }
-
- // Happy flow - get chosen life cycle state, artifact type and asset type
- // update artifact via external API + check audit & response code
- // Download artifact via external API + check audit & response code
- // Check artifact version, uuid & checksusm
- protected Component updateArtifactOnAssetViaExternalAPI(Component component, ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
- RestResponse restResponse = null;
- int numberOfArtifact = 0;
- String artifactVersionBeforeUpdate = null;
- String artifactName = null;
- String componentVersionBeforeUpdate = null;
-
- // get updated artifact data
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
- String artifactUUID = null;
- Map<String, ArtifactDefinition> deploymentArtifacts;
- deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
-
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci")) {
- artifactName = key;
- artifactVersionBeforeUpdate = deploymentArtifacts.get(key).getArtifactVersion();
- artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
- artifactReqDetails.setArtifactDisplayName(deploymentArtifacts.get(key).getArtifactDisplayName());
- artifactReqDetails.setArtifactName(deploymentArtifacts.get(key).getArtifactName());
- artifactReqDetails.setArtifactLabel(deploymentArtifacts.get(key).getArtifactLabel());
- break;
- }
- }
-
- component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
- componentVersionBeforeUpdate = component.getVersion();
- deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
- numberOfArtifact = deploymentArtifacts.size();
-
- // create component/s & upload artifact via external api
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- restResponse = updateArtifactOfRIIncludingValiditionOfAuditAndResponseCode(component, component.getComponentInstances().get(0), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID, 200);
- } else {
- restResponse = updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID, 200);
- }
-
- ArtifactDefinition responseArtifact = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse());
- component = getNewerVersionOfComponent(component, chosenLifeCycleState);
-
- // Get list of deployment artifact + download them via external API
- deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
- Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will be same as before.");
- Assert.assertEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate) + 1)), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Expected that aftifact version will increase by one.");
-
- if(chosenLifeCycleState == LifeCycleStatesEnum.CHECKOUT) {
- Assert.assertEquals(componentVersionBeforeUpdate, component.getVersion(), "Expected that check-out component will not change version number.");
- } else {
- Assert.assertEquals(String.format("%.1f", (Double.parseDouble(componentVersionBeforeUpdate) + 0.1)), component.getVersion(), "Expected that non check-out component version will increase by 0.1.");
- }
-
- // Download the uploaded artifact via external API
- downloadResourceDeploymentArtifactExternalAPI(component, deploymentArtifacts.get(responseArtifact.getArtifactLabel()), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentTypeEnum);
-
- return component;
- }
-
-
- // Update artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse updateArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, component.getComponentInstances().get(0), artifactUUID);
-
- // Check response of external API
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
-
-
- /* // Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPDATE_BY_API;
-
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, componentInstance.getNormalizedName());
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
-// expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID);
- expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID);
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body);*/
-
- return restResponse;
- }
-
-
- // Update artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID);
-
- // Check response of external API
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
-
-
- /* // Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_UPDATE_BY_API;
-
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
- expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID);
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_UPDATE_BY_API.getName(), body);*/
-
- return restResponse;
- }
-
-
-
-
- ////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- // Delete External API //
- ////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- @DataProvider(name="deleteArtifactForServiceViaExternalAPI", parallel=true)
- public static Object[][] dataProviderDeleteArtifactForServiceViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.OTHER.getType()}
- };
- }
-
- // Delete artifact for Service - Success
- @Test(dataProvider="deleteArtifactForServiceViaExternalAPI")
- public void deleteArtifactForServiceViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s", lifeCycleStatesEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.SERVICE, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
- deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.SERVICE, lifeCycleStatesEnum);
- }
-
- @DataProvider(name="deleteArtifactForVFViaExternalAPI", parallel=true)
- public static Object[][] dataProviderDeleteArtifactForVFViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_JSON.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_POLICY.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_EVENT.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.APPC_CONFIG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_DOC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_TOSCA.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()},
- };
- }
-
-
- // Delete artifact for VF - Success
- @Test(dataProvider="deleteArtifactForVFViaExternalAPI")
- public void deleteArtifactForVFViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s", lifeCycleStatesEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
- deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE, lifeCycleStatesEnum);
- }
-
- @DataProvider(name="deleteArtifactForVfcVlCpViaExternalAPI", parallel=true)
- public static Object[][] dataProviderDeleteArtifactForVfcVlCpViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP}
- };
- }
-
-
- // Delete artifact for VFC, VL, CP - Success
- @Test(dataProvider="deleteArtifactForVfcVlCpViaExternalAPI")
- public void deleteArtifactForVfcVlCpViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s, resourceTypeEnum: %s", lifeCycleStatesEnum, artifactType, resourceTypeEnum));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
- deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE, lifeCycleStatesEnum);
- }
-
- @DataProvider(name="deleteArtifactOnRIViaExternalAPI", parallel=true)
- public static Object[][] dataProviderDeleteArtifactOnRIViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), null},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), null},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), null},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), null},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VF},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VF}
-
- };
- }
-
-
-
-
-
- @Test(dataProvider="deleteArtifactOnRIViaExternalAPI")
- public void deleteArtifactOnRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
- deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState);
- }
-
-
- @DataProvider(name="deleteArtifactOnVfcVlCpRIViaExternalAPI", parallel=true)
- public static Object[][] dataProviderDeleteArtifactOnVfcVlCpRIViaExternalAPI() {
- return new Object[][] {
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP,},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
-
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
- {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP}
-
- };
- }
-
-
-
-
-
- @Test(dataProvider="deleteArtifactOnVfcVlCpRIViaExternalAPI")
- public void deleteArtifactOnVfcVlCpRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
- deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState);
- }
-
-
- @DataProvider(name="deleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset", parallel=true)
- public static Object[][] dataProviderDeleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset() {
- return new Object[][] {
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.DESIGNER2, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-//
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- /*due to those roles are not exists in the system {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_STRATEGIST1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
-
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- {ComponentTypeEnum.RESOURCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.SERVICE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.PRODUCT_MANAGER1, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},*/
- };
- }
-
-
- // External API
- // Delete artifact by different user then creator of asset - Fail
- @Test(dataProvider="deleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset")
- public void deleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset(ComponentTypeEnum componentTypeEnum, UserRoleEnum userRoleEnum, LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, userRoleEnum %s, lifeCycleStatesEnum %s, artifactType: %s", componentTypeEnum, userRoleEnum, lifeCycleStatesEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, lifeCycleStatesEnum, artifactType, null);
- Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
-
- String artifactUUID = null;
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci")) {
- artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
- break;
- }
- }
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
- List<String> variables = asList();
-
- if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
- component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, lifeCycleStatesEnum, true);
- } else {
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
- null, artifactUUID, errorInfo, variables, lifeCycleStatesEnum, true);
- }
-
- //TODO
+ protected void updateArtifactWithInvalidLabelEmpty(Component component, User sdncModifierDetails, String artifactType,
+ ComponentInstance componentInstance) throws Exception {
+
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
+ String artifactUUID = getFirstArtifactUuidFromComponent(component);
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name());
+ artifactReqDetails.setArtifactLabel("");
+
+ if (componentInstance != null) {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, null, null, true);
+ } else {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactReqDetails, artifactUUID, errorInfo, null, null, true);
+
+ }
+ }
+
+ // Update artifact with invalid description via external API - to long description
+ protected void updateArtifactWithInvalidDescriptionToLong(Component component, User sdncModifierDetails, String artifactType,
+ ComponentInstance componentInstance) throws Exception {
+
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
+ String artifactUUID = getFirstArtifactUuidFromComponent(component);
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
+ List<String> variables = asList("artifact description", ValidationUtils.ARTIFACT_DESCRIPTION_MAX_LENGTH.toString());
+ artifactReqDetails.setDescription("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
+
+ if (componentInstance != null) {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ } else {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+
+ }
+ }
+
+ public String getFirstArtifactUuidFromComponent(Component component) {
+ String artifactUUID = null;
+ Map<String, ArtifactDefinition> deploymentArtifacts;
+ if (component.getComponentInstances() != null) {
+ deploymentArtifacts = component.getComponentInstances().get(0).getDeploymentArtifacts();
+ } else {
+ deploymentArtifacts = component.getDeploymentArtifacts();
+ }
+
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci")) {
+ artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
+ break;
+ }
+ }
+ return artifactUUID;
+ }
+
+ // Update artifact with invalid description via external API - empty description
+ protected void updateArtifactWithInvalidDescriptionEmpty(Component component, User sdncModifierDetails, String artifactType,
+ ComponentInstance componentInstance) throws Exception {
+
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
+ String artifactUUID = getFirstArtifactUuidFromComponent(component);
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
+ List<String> variables = asList("artifact description");
+ artifactReqDetails.setDescription("");
+
+ if (componentInstance != null) {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ } else {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactReqDetails, artifactUUID, errorInfo, variables, null, true);
+ }
+ }
+
+ // Unhappy flow - get chosen life cycle state, artifact type and asset type
+ // update artifact via external API + check audit & response code
+ // Download artifact via external API + check audit & response code
+ // Check artifact version, uuid & checksusm
+ protected Component updateArtifactOnAssetViaExternalAPI(Component component, ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ErrorInfo errorInfo, List<String> variables, UserRoleEnum userRoleEnum) throws Exception {
+ String componentVersionBeforeUpdate = null;
+
+ // get updated artifact data
+ component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
+ componentVersionBeforeUpdate = component.getVersion();
+
+ Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+ ArtifactReqDetails artifactReqDetails = getUpdatedArtifact(deploymentArtifacts, artifactType);
+
+ String artifactName = artifactReqDetails.getArtifactLabel();
+ String artifactUUID = deploymentArtifacts.get(artifactName).getArtifactUUID();
+ String artifactVersionBeforeUpdate = deploymentArtifacts.get(artifactName).getArtifactVersion();
+ int numberOfArtifact = deploymentArtifacts.size();
+
+ ArtifactReqDetails updateArtifactReqDetails = ElementFactory.getArtifactByType(ArtifactTypeEnum.SNMP_POLL.name(), ArtifactTypeEnum.SNMP_POLL.name(), true, true);
+ updateArtifactReqDetails.setPayload("dGVzdA==");
+
+ // create component/s & upload artifact via external api
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
+ component.getComponentInstances().get(0), updateArtifactReqDetails, artifactUUID, errorInfo, variables, chosenLifeCycleState, true);
+ } else {
+ updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
+ null, updateArtifactReqDetails, artifactUUID, errorInfo, variables, chosenLifeCycleState, true);
+ }
+
+ if (component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
+ component = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
+ } else {
+ component = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
+ }
+
+ // Get list of deployment artifact + download them via external API
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ deploymentArtifacts = component.getComponentInstances().get(0).getDeploymentArtifacts();
+ } else {
+ deploymentArtifacts = component.getDeploymentArtifacts();
+ }
+ Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will be same as before.");
+ Assert.assertEquals(componentVersionBeforeUpdate, component.getVersion(), "Expected that check-out component will not change version number.");
+ if (errorInfo.getCode().equals(200)) {
+ Assert.assertNotEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate))), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Artifact version should be changed.");
+ Assert.assertNotEquals(artifactUUID, deploymentArtifacts.get(artifactName).getArtifactUUID(), "Artifact UUID should be changed.");
+ } else {
+ Assert.assertEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate))), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Artifact version should not be changed.");
+ Assert.assertEquals(artifactUUID, deploymentArtifacts.get(artifactName).getArtifactUUID(), "Artifact UUID should not be changed.");
+ }
+ return component;
+ }
+
+ protected RestResponse updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails,
+ ComponentInstance componentInstance, ArtifactReqDetails artifactReqDetails, String artifactUUID, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean resourceNameInAudit) throws Exception {
+ RestResponse restResponse;
+
+ if (componentInstance != null) {
+ restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, artifactReqDetails, componentInstance, artifactUUID);
+ } else {
+ restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfTheAsset(component, sdncModifierDetails, artifactReqDetails, artifactUUID);
+
+ }
+ // validate response code
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct.");
+ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
+ return restResponse;
+ }
+
+
+ // This function get component, user & if updatedPayload or not
+ // It will create default payload / updated payload of artifact
+ // And download artifact of component which starts with ci
+ protected RestResponse downloadResourceDeploymentArtifactExternalAPIAndComparePayLoadOfArtifactType(Component component, String artifactType, User sdncModifierDetails, ComponentTypeEnum componentTypeEnum) throws IOException, Exception {
+ // Download the uploaded artifact via external API
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("abcd", artifactType, true, false);
+ String artifactName = null;
+ for (String key : component.getDeploymentArtifacts().keySet()) {
+ if (key.startsWith("ci")) {
+ artifactName = key;
+ break;
+ }
+ }
+ return downloadResourceDeploymentArtifactExternalAPI(component, component.getDeploymentArtifacts().get(artifactName), sdncModifierDetails, artifactReqDetails, componentTypeEnum);
+ }
+
+ // Get deployment artifact of RI
+ protected Map<String, ArtifactDefinition> getDeploymentArtifactsOfAsset(Component component, ComponentTypeEnum componentTypeEnum) {
+ Map<String, ArtifactDefinition> deploymentArtifacts = null;
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ for (ComponentInstance componentInstance : component.getComponentInstances()) {
+ if (componentInstance.getNormalizedName().startsWith("ci")) {
+ deploymentArtifacts = componentInstance.getDeploymentArtifacts();
+ break;
+ }
+ }
+ } else {
+ deploymentArtifacts = component.getDeploymentArtifacts();
+ }
+ return deploymentArtifacts;
+ }
+
+ // get deploymentArtifact of asset and artifactType -> generate new artifact that can be updated on the asset
+ protected ArtifactReqDetails getUpdatedArtifact(Map<String, ArtifactDefinition> deploymentArtifacts, String artifactType) throws IOException, Exception {
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
+
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci")) {
+ artifactReqDetails.setArtifactDisplayName(deploymentArtifacts.get(key).getArtifactDisplayName());
+ artifactReqDetails.setArtifactName(deploymentArtifacts.get(key).getArtifactName());
+ artifactReqDetails.setArtifactLabel(deploymentArtifacts.get(key).getArtifactLabel());
+ break;
+ }
+ }
+ return artifactReqDetails;
+ }
+
+ // Happy flow - get chosen life cycle state, artifact type and asset type
+ // update artifact via external API + check audit & response code
+ // Download artifact via external API + check audit & response code
+ // Check artifact version, uuid & checksusm
+ protected Component updateArtifactOnAssetViaExternalAPI(Component component, ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState, String artifactType) throws Exception {
+ RestResponse restResponse = null;
+ int numberOfArtifact = 0;
+ String artifactVersionBeforeUpdate = null;
+ String artifactName = null;
+ String componentVersionBeforeUpdate = null;
+
+ // get updated artifact data
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", artifactType, true, true);
+ String artifactUUID = null;
+ Map<String, ArtifactDefinition> deploymentArtifacts;
+ deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci")) {
+ artifactName = key;
+ artifactVersionBeforeUpdate = deploymentArtifacts.get(key).getArtifactVersion();
+ artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
+ artifactReqDetails.setArtifactDisplayName(deploymentArtifacts.get(key).getArtifactDisplayName());
+ artifactReqDetails.setArtifactName(deploymentArtifacts.get(key).getArtifactName());
+ artifactReqDetails.setArtifactLabel(deploymentArtifacts.get(key).getArtifactLabel());
+ break;
+ }
+ }
+
+ component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
+ componentVersionBeforeUpdate = component.getVersion();
+ deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+ numberOfArtifact = deploymentArtifacts.size();
+
+ // create component/s & upload artifact via external api
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ restResponse = updateArtifactOfRIIncludingValiditionOfAuditAndResponseCode(component, component.getComponentInstances().get(0), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID, 200);
+ } else {
+ restResponse = updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID, 200);
+ }
+
+ ArtifactDefinition responseArtifact = ResponseParser.convertArtifactDefinitionResponseToJavaObject(restResponse.getResponse());
+ component = getNewerVersionOfComponent(component, chosenLifeCycleState);
+
+ // Get list of deployment artifact + download them via external API
+ deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+ Assert.assertEquals(numberOfArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will be same as before.");
+ Assert.assertEquals(String.valueOf((Integer.parseInt(artifactVersionBeforeUpdate) + 1)), deploymentArtifacts.get(artifactName).getArtifactVersion(), "Expected that aftifact version will increase by one.");
+
+ if (chosenLifeCycleState == LifeCycleStatesEnum.CHECKOUT) {
+ Assert.assertEquals(componentVersionBeforeUpdate, component.getVersion(), "Expected that check-out component will not change version number.");
+ } else {
+ Assert.assertEquals(String.format("%.1f", (Double.parseDouble(componentVersionBeforeUpdate) + 0.1)), component.getVersion(), "Expected that non check-out component version will increase by 0.1.");
+ }
+
+ // Download the uploaded artifact via external API
+ downloadResourceDeploymentArtifactExternalAPI(component, deploymentArtifacts.get(responseArtifact.getArtifactLabel()), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, componentTypeEnum);
+
+ return component;
+ }
+
+
+ // Update artifact via external API + Check auditing for upload operation + Check response of external API
+ protected RestResponse updateArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, component.getComponentInstances().get(0), artifactUUID);
+
+ // Check response of external API
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
+ return restResponse;
+ }
+
+
+ // Update artifact via external API + Check auditing for upload operation + Check response of external API
+ protected RestResponse updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, ArtifactReqDetails artifactReqDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIUpdateArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, artifactUUID);
+
+ // Check response of external API
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
+ return restResponse;
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+ // Delete External API //
+ ////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+ @DataProvider(name = "deleteArtifactForServiceViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactForServiceViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CERTIFICATIONREQUEST, ArtifactTypeEnum.OTHER.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CERTIFY, ArtifactTypeEnum.OTHER.getType()}
+ };
+ }
+
+ // Delete artifact for Service - Success
+ @Test(dataProvider = "deleteArtifactForServiceViaExternalAPI")
+ public void deleteArtifactForServiceViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s", lifeCycleStatesEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.SERVICE, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
+ deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.SERVICE, lifeCycleStatesEnum);
+ }
+
+ @DataProvider(name = "deleteArtifactForVFViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactForVFViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_JSON.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_POLICY.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_EVENT.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.APPC_CONFIG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_DOC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_TOSCA.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_JSON.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_POLICY.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_EVENT.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.APPC_CONFIG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_DOC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_TOSCA.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType()},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ };
+ }
+
+ // Delete artifact for VF - Success
+ @Test(dataProvider = "deleteArtifactForVFViaExternalAPI")
+ public void deleteArtifactForVFViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s", lifeCycleStatesEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
+ deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE, lifeCycleStatesEnum);
+ }
+
+ @DataProvider(name = "deleteArtifactForVfcVlCpViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactForVfcVlCpViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.YANG_XML.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VNF_CATALOG.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VF_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.MODEL_QUERY_SPEC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+ };
+ }
+
+ // Delete artifact for VFC, VL, CP - Success
+ @Test(dataProvider = "deleteArtifactForVfcVlCpViaExternalAPI")
+ public void deleteArtifactForVfcVlCpViaExternalAPI(LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("lifeCycleStatesEnum: %s, artifactType: %s, resourceTypeEnum: %s", lifeCycleStatesEnum, artifactType, resourceTypeEnum));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
+ deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE, lifeCycleStatesEnum);
+ }
+
+ @DataProvider(name = "deleteArtifactOnRIViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactOnRIViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), null},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), null},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), null},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), null},
+
+ };
+ }
+
+
+ @Test(dataProvider = "deleteArtifactOnRIViaExternalAPI")
+ public void deleteArtifactOnRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
+ deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState);
+ }
+
+ @DataProvider(name = "deleteArtifactOnVfcVlCpRIViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactOnVfcVlCpRIViaExternalAPI() {
+ return new Object[][]{
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP,},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VFC},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VFC},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.VL},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.VL},
+
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_POLL.getType(), ResourceTypeEnum.CP},
+ {LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.SNMP_TRAP.getType(), ResourceTypeEnum.CP},
+ };
+ }
+
+ @Test(dataProvider = "deleteArtifactOnVfcVlCpRIViaExternalAPI")
+ public void deleteArtifactOnVfcVlCpRIViaExternalAPI(LifeCycleStatesEnum chosenLifeCycleState, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("chosenLifeCycleState: %s, artifactType: %s", chosenLifeCycleState, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(ComponentTypeEnum.RESOURCE_INSTANCE, LifeCycleStatesEnum.CHECKOUT, artifactType, resourceTypeEnum);
+ deleteArtifactOnAssetViaExternalAPI(component, ComponentTypeEnum.RESOURCE_INSTANCE, chosenLifeCycleState);
+ }
+
+ @DataProvider(name = "deleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset() {
+ return new Object[][]{
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.TESTER, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.ADMIN, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.OPS, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKIN, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ {ComponentTypeEnum.RESOURCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.SERVICE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.OTHER.getType()},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, UserRoleEnum.GOVERNOR, LifeCycleStatesEnum.CHECKOUT, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
+ };
+ }
+
+ // External API
+ // Delete artifact by different user then creator of asset - Fail
+ @Test(dataProvider = "deleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset")
+ public void deleteArtifactOnVFViaExternalAPIByDiffrentUserThenCreatorOfAsset(ComponentTypeEnum componentTypeEnum, UserRoleEnum userRoleEnum, LifeCycleStatesEnum lifeCycleStatesEnum, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, userRoleEnum %s, lifeCycleStatesEnum %s, artifactType: %s", componentTypeEnum, userRoleEnum, lifeCycleStatesEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, lifeCycleStatesEnum, artifactType, null);
+ Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+
+ String artifactUUID = null;
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci")) {
+ artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
+ break;
+ }
+ }
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
+ List<String> variables = asList();
+
+ if (componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
+ component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, lifeCycleStatesEnum, true);
+ } else {
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(userRoleEnum),
+ null, artifactUUID, errorInfo, variables, lifeCycleStatesEnum, true);
+ }
+
+ //TODO
// downloadResourceDeploymentArtifactExternalAPI(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID, componentTypeEnum);
- }
-
-
- @DataProvider(name="deleteArtifactOnAssetWhichNotExist", parallel=true)
- public static Object[][] dataProviderDeleteArtifactOnAssetWhichNotExist() {
- return new Object[][] {
- {ComponentTypeEnum.SERVICE, ArtifactTypeEnum.OTHER.getType(), null},
- {ComponentTypeEnum.RESOURCE, ArtifactTypeEnum.OTHER.getType(), null},
- {ComponentTypeEnum.RESOURCE_INSTANCE, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VF},
- };
- }
-
-
- // External API
- // Upload artifact on VF via external API - happy flow
- @Test(dataProvider="deleteArtifactOnAssetWhichNotExist")
- public void deleteArtifactOnAssetWhichNotExist(ComponentTypeEnum componentTypeEnum, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, resourceTypeEnum);
-
- Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
-
- String artifactUUID = null;
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci")) {
- artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
- break;
- }
- }
-
- // Invalid artifactUUID
- String invalidArtifactUUID = "12341234-1234-1234-1234-123412341234";
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_NOT_FOUND.name());
- List<String> variables = asList(invalidArtifactUUID);
-
- if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), invalidArtifactUUID, errorInfo, variables, null, true);
- } else {
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, invalidArtifactUUID, errorInfo, variables, null, true);
-
- }
-
-
- // Invalid componentUUID
- if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
- component.getComponentInstances().get(0).setNormalizedName("invalidNormalizedName");
- errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER.name());
- variables = asList("invalidNormalizedName", ComponentTypeEnum.RESOURCE_INSTANCE.getValue().toLowerCase(), ComponentTypeEnum.SERVICE.getValue(), component.getName());
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, true);
- } else {
- component.setUUID("invalidComponentUUID");
- if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE)) {
- errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name());
- } else {
- errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name());
- }
- variables = asList("invalidComponentUUID");
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, false);
- }
-
-
-// performeClean();
-
- }
-
- @DataProvider(name="deleteArtifactOnAssetWhichInInvalidStateForUploading", parallel=true)
- public static Object[][] dataProviderDeleteArtifactOnAssetWhichInInvalidStateForUploading() {
- return new Object[][] {
- {ComponentTypeEnum.SERVICE, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE, ArtifactTypeEnum.OTHER.getType()},
- {ComponentTypeEnum.RESOURCE_INSTANCE, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType()},
- };
- }
-
-
- @Test(dataProvider="deleteArtifactOnAssetWhichInInvalidStateForUploading")
- public void deleteArtifactOnAssetWhichInInvalidStateForUploading(ComponentTypeEnum componentTypeEnum, String artifactType) throws Exception {
- getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
- Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
- component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.STARTCERTIFICATION, true).getLeft();
-
- Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
- String artifactUUID = null;
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci")) {
- artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
- break;
- }
- }
-
-
- // Invalid artifactUUID
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
- List<String> variables = asList(component.getName(), component.getComponentType().toString().toLowerCase(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getFirstName(),
- ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getLastName(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getUserId());
-
- if(componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, null, true);
- } else {
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- null, artifactUUID, errorInfo, variables, null, true);
-
- }
-
- }
-
-
- @DataProvider(name="deleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI", parallel=true)
- public static Object[][] dataProviderDeleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI() {
- return new Object[][] {
- {ResourceTypeEnum.VFC},
- {ResourceTypeEnum.VL},
- {ResourceTypeEnum.CP}
- };
- }
-
-
- // Verify that it cannot delete VFC/VL/CP artifact on VFCi/VLi/CPi - Failure flow
- @Test(dataProvider="deleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI")
- public void deleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI(ResourceTypeEnum resourceTypeEnum) throws Exception {
-
- getExtendTest().log(Status.INFO, String.format("resourceTypeEnum: %s", resourceTypeEnum));
-
- Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, resourceTypeEnum);
- ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", ArtifactTypeEnum.SNMP_TRAP.getType(), true, false);
- uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceInstanceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
- resourceInstanceDetails = AtomicOperationUtils.changeComponentState(resourceInstanceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
- Component component = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
- AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
- component = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
-
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name());
- Map<String, ArtifactDefinition> deploymentArtifacts;
- deploymentArtifacts = getDeploymentArtifactsOfAsset(component, ComponentTypeEnum.RESOURCE_INSTANCE);
- String artifactUUID = null;
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci")) {
- artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
- break;
- }
- }
- List<String> variables = asList(artifactUUID);
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
- component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, null, true);
- }
-
- protected RestResponse deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails,
- ComponentInstance componentInstance, String artifactUUID, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean resourceNameInAudit) throws Exception {
- RestResponse restResponse;
-
- if(componentInstance != null) {
- restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, componentInstance, artifactUUID);
- } else {
- restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfTheAsset(component, sdncModifierDetails, artifactUUID);
-
- }
-
- // validate response code
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct.");
-
- /*// Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_DELETE_BY_API;
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
-// ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, resourceDetails);
-
- responseArtifact.setUpdaterFullName("");
- responseArtifact.setUserIdLastUpdater(sdncModifierDetails.getUserId());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditFailure(assetTypeEnum, action, responseArtifact, component.getUUID(), errorInfo, variables);
- expectedExternalAudit.setRESOURCE_NAME(component.getName());
- expectedExternalAudit.setRESOURCE_TYPE(component.getComponentType().getValue());
- expectedExternalAudit.setARTIFACT_DATA(null);
- expectedExternalAudit.setCURR_ARTIFACT_UUID(artifactUUID);
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
- if(componentInstance != null) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getComponentInstances().get(0).getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + component.getComponentInstances().get(0).getNormalizedName() + "/artifacts/" + artifactUUID);
- expectedExternalAudit.setRESOURCE_NAME(component.getComponentInstances().get(0).getNormalizedName());
- } else {
- expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL() + "/" + artifactUUID);
- if((errorInfo.getMessageId().equals(ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name()).getMessageId())) ||
- errorInfo.getMessageId().equals(ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name()).getMessageId()) ||
- (lifeCycleStatesEnum == LifeCycleStatesEnum.STARTCERTIFICATION)) {
- if(resourceNameInAudit) {
- expectedExternalAudit.setRESOURCE_NAME(component.getName());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- } else {
- expectedExternalAudit.setRESOURCE_NAME("");
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
- }
- } else {
- if(resourceNameInAudit) {
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- } else {
- expectedExternalAudit.setRESOURCE_NAME("");
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
- }
- }
- }
-
-// getExtendTest().log(LogStatus.INFO, "Audit Action: " + AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName());
-// body.forEach((k,v)->getExtendTest().log(LogStatus.INFO,"key : " + k + " value : " + v));
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body);*/
-
- return restResponse;
-
- }
-
-
- // Happy flow - get chosen life cycle state, artifact type and asset type
- // delete artifact via external API + check audit & response code
- protected Component deleteArtifactOnAssetViaExternalAPI(Component component, ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState) throws Exception {
- String artifactName = null;
- component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
- if(!LifeCycleStatesEnum.CHECKOUT.equals(chosenLifeCycleState)){
- component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
- }else{
- component = getNewerVersionOfComponent(component, chosenLifeCycleState);
- }
- // get updated artifact data
- String artifactUUID = null;
- int moduleTypeArtifact = 0;
- Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
-
- for (String key : deploymentArtifacts.keySet()) {
- if (key.startsWith("ci") && StringUtils.isNotEmpty(deploymentArtifacts.get(key).getArtifactUUID())) {
- artifactName = key;
- artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
-
- if (deploymentArtifacts.get(key).getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA)){
- moduleTypeArtifact = 1;
- }
- break;
- }
- }
-
- String componentVersionBeforeDelete = component.getVersion();
- int numberOfArtifact = deploymentArtifacts.size();
-
- // create component/s & upload artifact via external api
- if(ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
- deleteArtifactOfRIIncludingValiditionOfAuditAndResponseCode(component, component.getComponentInstances().get(0), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID, 200);
- } else {
- deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID, 200);
- }
-
- component = updateComponentDetailsByLifeCycleState(chosenLifeCycleState, component);
-
- // Get list of deployment artifact + download them via external API
- deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
- if(deploymentArtifacts.get(artifactName) != null) {
- Assert.assertTrue(false, "Expected that deleted artifact will not appear in deployment artifact list.");
- }
- if((LifeCycleStatesEnum.CERTIFICATIONREQUEST.equals(chosenLifeCycleState)) && (ComponentTypeEnum.RESOURCE_INSTANCE.equals(componentTypeEnum)) && (!component.getComponentType().toString().equals(ComponentTypeEnum.RESOURCE.toString()))) {
- Assert.assertEquals(numberOfArtifact - 1 - moduleTypeArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact (one deleted and one vfmodule) will decrease by two.");
- } else {
- Assert.assertEquals(numberOfArtifact - 1, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will decrease by one.");
- }
-
- if(chosenLifeCycleState == LifeCycleStatesEnum.CHECKOUT) {
- Assert.assertEquals(componentVersionBeforeDelete, component.getVersion(), "Expected that check-out component will not change version number.");
- } else {
- Assert.assertEquals(String.format("%.1f", (Double.parseDouble(componentVersionBeforeDelete) + 0.1)), component.getVersion(), "Expected that non check-out component version will increase by 0.1.");
- }
-
- downloadResourceDeploymentArtifactExternalAPI(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID, componentTypeEnum);
-
- return component;
- }
-
- // Delete artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse deleteArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentInstances().get(0), artifactUUID);
-
- // Check response of external API
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
-
-
- /*// Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_DELETE_BY_API;
-
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, componentInstance.getNormalizedName());
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
-// expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID);
- expectedExternalAudit.setRESOURCE_NAME(componentInstance.getNormalizedName());
- expectedExternalAudit.setRESOURCE_URL("/sdc/v1/catalog/" + assetTypeEnum.getValue() + "/" + component.getUUID() + "/resourceInstances/" + componentInstance.getNormalizedName() + "/artifacts/" + artifactUUID);
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body);*/
- component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
- return restResponse;
- }
-
-
- // Delete artifact via external API + Check auditing for upload operation + Check response of external API
- protected RestResponse deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
- RestResponse restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID);
-
- // Check response of external API
- Integer responseCode = restResponse.getErrorCode();
- Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
-
-
- /*// Check auditing for upload operation
- ArtifactDefinition responseArtifact = getArtifactDataFromJson(restResponse.getResponse());
-
- AuditingActionEnum action = AuditingActionEnum.ARTIFACT_DELETE_BY_API;
-
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
-
- AssetTypeEnum assetTypeEnum = AssetTypeEnum.valueOf((component.getComponentType().getValue() + "s").toUpperCase());
- ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalArtifactAuditSuccess(assetTypeEnum, action, responseArtifact, component);
- expectedExternalAudit.setRESOURCE_URL(expectedExternalAudit.getRESOURCE_URL()+ "/" + artifactUUID);
- AuditValidationUtils.validateExternalAudit(expectedExternalAudit, AuditingActionEnum.ARTIFACT_DELETE_BY_API.getName(), body);*/
- component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
- return restResponse;
- }
-
-
-
- // download deployment via external api + check response code for success (200) + get artifactReqDetails and verify payload + verify audit
- protected RestResponse downloadResourceDeploymentArtifactExternalAPI(Component component, User sdncModifierDetails, String artifactUUID, ComponentTypeEnum componentTypeEnum) throws Exception {
- RestResponse restResponse;
-
- if(componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) {
- restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(component.getUUID(), component.getComponentInstances().get(0).getNormalizedName(), artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
- } else {
- restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(component.getUUID(), artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
- }
-
- Integer responseCode = restResponse.getErrorCode();
- Integer expectedCode = 404;
- Assert.assertEquals(responseCode,expectedCode, "Response code is not correct.");
-
-
- //TODO - including body - resourceDetails.getName()
-// // Verify audit
-// String auditAction = "DownloadArtifact";
-//
-// Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
-// body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, responseCode.toString());
-// body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceDetails.getName());
-//
-// ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = new ExpectedResourceAuditJavaObject();
-// expectedResourceAuditJavaObject.setAction(auditAction);
-// expectedResourceAuditJavaObject.setResourceType(resourceDetails.getComponentType().getValue());
-// expectedResourceAuditJavaObject.setStatus("200");
-// expectedResourceAuditJavaObject.setDesc("OK");
-// expectedResourceAuditJavaObject.setCONSUMER_ID("ci");
-//
-// if(componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) {
-// expectedResourceAuditJavaObject.setResourceName(resourceDetails.getComponentInstances().get(0).getName());
-// String resource_url = String.format("/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s", resourceDetails.getUUID(), resourceDetails.getComponentInstances().get(0).getNormalizedName(), artifactDefinition.getArtifactUUID());
-// expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url);
-//
-// AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false);
-// } else {
-// expectedResourceAuditJavaObject.setResourceName(resourceDetails.getName());
-// String resource_url = String.format("/sdc/v1/catalog/services/%s/artifacts/%s", resourceDetails.getUUID(), artifactDefinition.getArtifactUUID());
-// expectedResourceAuditJavaObject.setRESOURCE_URL(resource_url);
-// }
-//
-// AuditValidationUtils.validateAuditDownloadExternalAPI(expectedResourceAuditJavaObject, auditAction, null, false);
-
- return restResponse;
-
- }
-
-
-
-
- public Component getComponentInTargetLifeCycleState(String componentType, UserRoleEnum creatorUser, LifeCycleStatesEnum targetLifeCycleState, ResourceTypeEnum resourceTypeEnum) throws Exception {
- Component resourceDetails = null;
-
- if((componentType.toLowerCase().equals("vf")) || (componentType.toLowerCase().equals("resource"))){
- if(resourceTypeEnum==null) {
- resourceTypeEnum = ResourceTypeEnum.VF;
- }
- Either<Resource, RestResponse> createdResource = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(resourceTypeEnum, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, creatorUser, true);
- resourceDetails = createdResource.left().value();
- resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, creatorUser, targetLifeCycleState, true).getLeft();
- } else {
- Either<Service, RestResponse> createdResource = AtomicOperationUtils.createDefaultService(creatorUser, true);
- resourceDetails = createdResource.left().value();
- // Add artifact to service if asked for certifcationrequest - must be at least one artifact for the flow
- if((LifeCycleStatesEnum.CERTIFICATIONREQUEST == targetLifeCycleState) || (LifeCycleStatesEnum.STARTCERTIFICATION == targetLifeCycleState)) {
- AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.OTHER, resourceDetails, UserRoleEnum.DESIGNER, true, true).left().value();
- }
- resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, creatorUser, targetLifeCycleState, true).getLeft();
- }
-
- return resourceDetails;
- }
-
+ }
+
+
+ @DataProvider(name = "deleteArtifactOnAssetWhichNotExist", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactOnAssetWhichNotExist() {
+ return new Object[][]{
+ {ComponentTypeEnum.SERVICE, ArtifactTypeEnum.OTHER.getType(), null},
+ {ComponentTypeEnum.RESOURCE, ArtifactTypeEnum.OTHER.getType(), null},
+ {ComponentTypeEnum.RESOURCE_INSTANCE, ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), ResourceTypeEnum.VF},
+ };
+ }
+
+ // External API
+ // Upload artifact on VF via external API - happy flow
+ @Test(dataProvider = "deleteArtifactOnAssetWhichNotExist")
+ public void deleteArtifactOnAssetWhichNotExist(ComponentTypeEnum componentTypeEnum, String artifactType, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKIN, artifactType, resourceTypeEnum);
+
+ Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+
+ String artifactUUID = null;
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci")) {
+ artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
+ break;
+ }
+ }
+
+ // Invalid artifactUUID
+ String invalidArtifactUUID = "12341234-1234-1234-1234-123412341234";
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_NOT_FOUND.name());
+ List<String> variables = asList(invalidArtifactUUID);
+
+ if (componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), invalidArtifactUUID, errorInfo, variables, null, true);
+ } else {
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, invalidArtifactUUID, errorInfo, variables, null, true);
+
+ }
+ // Invalid componentUUID
+ if (componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
+ component.getComponentInstances().get(0).setNormalizedName("invalidNormalizedName");
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER.name());
+ variables = asList("invalidNormalizedName", ComponentTypeEnum.RESOURCE_INSTANCE.getValue().toLowerCase(), ComponentTypeEnum.SERVICE.getValue(), component.getName());
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, true);
+ } else {
+ component.setUUID("invalidComponentUUID");
+ if (componentTypeEnum.equals(ComponentTypeEnum.RESOURCE)) {
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESOURCE_NOT_FOUND.name());
+ } else {
+ errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name());
+ }
+ variables = asList("invalidComponentUUID");
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactUUID, errorInfo, variables, LifeCycleStatesEnum.CHECKIN, false);
+ }
+
+ }
+
+ @DataProvider(name = "deleteArtifactOnAssetWhichInInvalidStateForUploading", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactOnAssetWhichInInvalidStateForUploading() {
+ return new Object[][]{
+ {ComponentTypeEnum.SERVICE, ArtifactTypeEnum.OTHER.getType()},
+ };
+ }
+
+
+ @Test(dataProvider = "deleteArtifactOnAssetWhichInInvalidStateForUploading")
+ public void deleteArtifactOnAssetWhichInInvalidStateForUploading(ComponentTypeEnum componentTypeEnum, String artifactType) throws Exception {
+ getExtendTest().log(Status.INFO, String.format("componentTypeEnum: %s, artifactType: %s", componentTypeEnum, artifactType));
+ Component component = uploadArtifactOnAssetViaExternalAPI(componentTypeEnum, LifeCycleStatesEnum.CHECKOUT, artifactType, null);
+ component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.STARTCERTIFICATION, true).getLeft();
+
+ Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+ String artifactUUID = null;
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci")) {
+ artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
+ break;
+ }
+ }
+ // Invalid artifactUUID
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_IN_CERT_IN_PROGRESS_STATE.name());
+ List<String> variables = asList(component.getName(), component.getComponentType().toString().toLowerCase(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getFirstName(),
+ ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getLastName(), ElementFactory.getDefaultUser(UserRoleEnum.TESTER).getUserId());
+
+ if (componentTypeEnum.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, null, true);
+ } else {
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ null, artifactUUID, errorInfo, variables, null, true);
+
+ }
+
+ }
+
+ @DataProvider(name = "deleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI", parallel = true)
+ public static Object[][] dataProviderDeleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI() {
+ return new Object[][]{
+ {ResourceTypeEnum.VFC},
+ {ResourceTypeEnum.VL},
+ {ResourceTypeEnum.CP}
+ };
+ }
+
+ // Verify that it cannot delete VFC/VL/CP artifact on VFCi/VLi/CPi - Failure flow
+ @Test(dataProvider = "deleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI")
+ public void deleteArtifactOfVfcVlCpForVfciVliCpiViaExternalAPI(ResourceTypeEnum resourceTypeEnum) throws Exception {
+
+ getExtendTest().log(Status.INFO, String.format("resourceTypeEnum: %s", resourceTypeEnum));
+
+ Component resourceInstanceDetails = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.getValue(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, resourceTypeEnum);
+ ArtifactReqDetails artifactReqDetails = ElementFactory.getArtifactByType("ci", ArtifactTypeEnum.SNMP_TRAP.getType(), true, false);
+ uploadArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(resourceInstanceDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactReqDetails, 200);
+ resourceInstanceDetails = AtomicOperationUtils.changeComponentState(resourceInstanceDetails, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
+ Component component = getComponentInTargetLifeCycleState(ComponentTypeEnum.RESOURCE.toString(), UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, null);
+ AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceInstanceDetails, component, UserRoleEnum.DESIGNER, true).left().value();
+ component = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, component.getName(), component.getVersion());
+
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.OK.name());
+ Map<String, ArtifactDefinition> deploymentArtifacts;
+ deploymentArtifacts = getDeploymentArtifactsOfAsset(component, ComponentTypeEnum.RESOURCE_INSTANCE);
+ String artifactUUID = null;
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci")) {
+ artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
+ break;
+ }
+ }
+ List<String> variables = asList(artifactUUID);
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
+ component.getComponentInstances().get(0), artifactUUID, errorInfo, variables, null, true);
+ }
+
+ protected RestResponse deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails,
+ ComponentInstance componentInstance, String artifactUUID, ErrorInfo errorInfo, List<String> variables, LifeCycleStatesEnum lifeCycleStatesEnum, Boolean resourceNameInAudit) throws Exception {
+ RestResponse restResponse;
+
+ if (componentInstance != null) {
+ restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfComponentInstanceOnAsset(component, sdncModifierDetails, componentInstance, artifactUUID);
+ } else {
+ restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfTheAsset(component, sdncModifierDetails, artifactUUID);
+
+ }
+
+ // validate response code
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, errorInfo.getCode(), "Response code is not correct.");
+ return restResponse;
+
+ }
+
+
+ // Happy flow - get chosen life cycle state, artifact type and asset type
+ // delete artifact via external API + check audit & response code
+ protected Component deleteArtifactOnAssetViaExternalAPI(Component component, ComponentTypeEnum componentTypeEnum, LifeCycleStatesEnum chosenLifeCycleState) throws Exception {
+ String artifactName = null;
+ component = AtomicOperationUtils.changeComponentState(component, UserRoleEnum.DESIGNER, chosenLifeCycleState, true).getLeft();
+ if (!LifeCycleStatesEnum.CHECKOUT.equals(chosenLifeCycleState)) {
+ component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
+ } else {
+ component = getNewerVersionOfComponent(component, chosenLifeCycleState);
+ }
+ // get updated artifact data
+ String artifactUUID = null;
+ int moduleTypeArtifact = 0;
+ Map<String, ArtifactDefinition> deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+
+ for (String key : deploymentArtifacts.keySet()) {
+ if (key.startsWith("ci") && StringUtils.isNotEmpty(deploymentArtifacts.get(key).getArtifactUUID())) {
+ artifactName = key;
+ artifactUUID = deploymentArtifacts.get(key).getArtifactUUID();
+
+ if (deploymentArtifacts.get(key).getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA)) {
+ moduleTypeArtifact = 1;
+ }
+ break;
+ }
+ }
+
+ String componentVersionBeforeDelete = component.getVersion();
+ int numberOfArtifact = deploymentArtifacts.size();
+
+ // create component/s & upload artifact via external api
+ if (ComponentTypeEnum.RESOURCE_INSTANCE == componentTypeEnum) {
+ deleteArtifactOfRIIncludingValiditionOfAuditAndResponseCode(component, component.getComponentInstances().get(0), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID, 200);
+ } else {
+ deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID, 200);
+ }
+
+ component = updateComponentDetailsByLifeCycleState(chosenLifeCycleState, component);
+
+ // Get list of deployment artifact + download them via external API
+ deploymentArtifacts = getDeploymentArtifactsOfAsset(component, componentTypeEnum);
+ if (deploymentArtifacts.get(artifactName) != null) {
+ Assert.assertTrue(false, "Expected that deleted artifact will not appear in deployment artifact list.");
+ }
+ if ((LifeCycleStatesEnum.CERTIFICATIONREQUEST.equals(chosenLifeCycleState)) && (ComponentTypeEnum.RESOURCE_INSTANCE.equals(componentTypeEnum)) && (!component.getComponentType().toString().equals(ComponentTypeEnum.RESOURCE.toString()))) {
+ Assert.assertEquals(numberOfArtifact - 1 - moduleTypeArtifact, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact (one deleted and one vfmodule) will decrease by two.");
+ } else {
+ Assert.assertEquals(numberOfArtifact - 1, deploymentArtifacts.keySet().size(), "Expected that number of deployment artifact will decrease by one.");
+ }
+
+ if (chosenLifeCycleState == LifeCycleStatesEnum.CHECKOUT) {
+ Assert.assertEquals(componentVersionBeforeDelete, component.getVersion(), "Expected that check-out component will not change version number.");
+ } else {
+ Assert.assertEquals(String.format("%.1f", (Double.parseDouble(componentVersionBeforeDelete) + 0.1)), component.getVersion(), "Expected that non check-out component version will increase by 0.1.");
+ }
+
+ downloadResourceDeploymentArtifactExternalAPI(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID, componentTypeEnum);
+
+ return component;
+ }
+
+ // Delete artifact via external API + Check auditing for upload operation + Check response of external API
+ protected RestResponse deleteArtifactOfRIIncludingValiditionOfAuditAndResponseCode(Component component, ComponentInstance componentInstance, User sdncModifierDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfComponentInstanceOnAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentInstances().get(0), artifactUUID);
+
+ // Check response of external API
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
+// component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
+ return restResponse;
+ }
+
+
+ // Delete artifact via external API + Check auditing for upload operation + Check response of external API
+ protected RestResponse deleteArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(Component component, User sdncModifierDetails, String artifactUUID, Integer expectedResponseCode) throws Exception {
+ RestResponse restResponse = ArtifactRestUtils.externalAPIDeleteArtifactOfTheAsset(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), artifactUUID);
+
+ // Check response of external API
+ Integer responseCode = restResponse.getErrorCode();
+ Assert.assertEquals(responseCode, expectedResponseCode, "Response code is not correct.");
+// component = AtomicOperationUtils.getComponentObject(component, UserRoleEnum.DESIGNER);
+ return restResponse;
+ }
+
+
+ // download deployment via external api + check response code for success (200) + get artifactReqDetails and verify payload + verify audit
+ protected RestResponse downloadResourceDeploymentArtifactExternalAPI(Component component, User sdncModifierDetails, String artifactUUID, ComponentTypeEnum componentTypeEnum) throws Exception {
+ RestResponse restResponse;
+
+ if (componentTypeEnum == ComponentTypeEnum.RESOURCE_INSTANCE) {
+ restResponse = ArtifactRestUtils.getComponentInstanceDeploymentArtifactExternalAPI(component.getUUID(), component.getComponentInstances().get(0).getNormalizedName(), artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
+ } else {
+ restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(component.getUUID(), artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), component.getComponentType().toString());
+ }
+
+ Integer responseCode = restResponse.getErrorCode();
+ Integer expectedCode = 404;
+ Assert.assertEquals(responseCode, expectedCode, "Response code is not correct.");
+
+ return restResponse;
+
+ }
+
+
+ public Component getComponentInTargetLifeCycleState(String componentType, UserRoleEnum creatorUser, LifeCycleStatesEnum targetLifeCycleState, ResourceTypeEnum resourceTypeEnum) throws Exception {
+ Component resourceDetails = null;
+
+ if ((componentType.toLowerCase().equals("vf")) || (componentType.toLowerCase().equals("resource"))) {
+ if (resourceTypeEnum == null) {
+ resourceTypeEnum = ResourceTypeEnum.VF;
+ }
+ Either<Resource, RestResponse> createdResource = AtomicOperationUtils.createResourcesByTypeNormTypeAndCatregory(resourceTypeEnum, NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, creatorUser, true);
+ resourceDetails = createdResource.left().value();
+ resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, creatorUser, targetLifeCycleState, true).getLeft();
+ } else {
+ Either<Service, RestResponse> createdResource = AtomicOperationUtils.createDefaultService(creatorUser, true);
+ resourceDetails = createdResource.left().value();
+ // Add artifact to service if asked for certifcationrequest - must be at least one artifact for the flow
+ if ((LifeCycleStatesEnum.CERTIFICATIONREQUEST == targetLifeCycleState) || (LifeCycleStatesEnum.STARTCERTIFICATION == targetLifeCycleState)) {
+ AtomicOperationUtils.uploadArtifactByType(ArtifactTypeEnum.OTHER, resourceDetails, UserRoleEnum.DESIGNER, true, true).left().value();
+ }
+ resourceDetails = AtomicOperationUtils.changeComponentState(resourceDetails, creatorUser, targetLifeCycleState, true).getLeft();
+ }
+ return resourceDetails;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java
index 9e82a818a1..fb60f44b64 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/DeploymentValiditaion.java
@@ -52,8 +52,9 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
+
import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.assertTrue;
+
public class DeploymentValiditaion extends ComponentBaseTest{
@Rule
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java
index 9db9e8a4d8..917d980184 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.externalApis;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
@@ -27,7 +28,6 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
@@ -49,7 +49,9 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.*;
+import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
import org.openecomp.sdc.common.api.Constants;
import org.testng.annotations.Test;
@@ -127,13 +129,13 @@ public class GetAssetServlet extends ComponentBaseTest {
resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.STARTCERTIFICATION, true).getLeft();
expectedAssetNamesList.add(resourceDetails.getName());
- resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails);
+/* resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails);
resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFICATIONREQUEST, true).getLeft();
- expectedAssetNamesList.add(resourceDetails.getName());
+ expectedAssetNamesList.add(resourceDetails.getName());*/
- System.out.println("7 VF resources were created");
+ System.out.println("6 VF resources were created");
RestResponse assetResponse = AssetRestUtils.getComponentListByAssetType(true, AssetTypeEnum.RESOURCES);
BaseRestUtils.checkSuccess(assetResponse);
@@ -146,8 +148,8 @@ public class GetAssetServlet extends ComponentBaseTest {
/* // Validate audit message
ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_ASSET_LIST);
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_LIST.getName(), body);*/
}
@@ -225,8 +227,8 @@ public class GetAssetServlet extends ComponentBaseTest {
/*// Validate audit message
ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(AssetTypeEnum.SERVICES, AuditingActionEnum.GET_ASSET_LIST);
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_LIST.getName(), body);*/
}
@@ -234,25 +236,35 @@ public class GetAssetServlet extends ComponentBaseTest {
@Test(enabled = false)
public void getToscaModelSuccess() throws Exception {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- ResourceReqDetails resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails);
- Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
- HttpResponse assetResponse = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID());
- resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
- String artId = resource.getToscaArtifacts().get("assettoscacsar").getEsId();
- String url = String.format(Urls.UI_DOWNLOAD_RESOURCE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), resource.getUniqueId(), artId);
- HttpGet httpGet = createGetRequest(url);
- HttpResponse response = httpclient.execute(httpGet);
- InputStream inputStream = response.getEntity().getContent();
- ArtifactUiDownloadData artifactUiDownloadData = getArtifactUiDownloadData(IOUtils.toString(inputStream));
+ Resource resource;
+ HttpResponse assetResponse;
+ HttpResponse response;
+ InputStream inputStream;
+ ArtifactUiDownloadData artifactUiDownloadData;
+ int len;
+ byte[] res;
+ byte[] fromUiDownload;
+ String fileName;
+ try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+ ResourceReqDetails resourceDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, sdncUserDetails);
+ resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
+ assetResponse = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID());
+ resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
+ String artId = resource.getToscaArtifacts().get("assettoscacsar").getEsId();
+ String url = String.format(Urls.UI_DOWNLOAD_RESOURCE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), resource.getUniqueId(), artId);
+ HttpGet httpGet = createGetRequest(url);
+ response = httpclient.execute(httpGet);
+ }
+ inputStream = response.getEntity().getContent();
+ artifactUiDownloadData = getArtifactUiDownloadData(IOUtils.toString(inputStream));
assetResponse = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.RESOURCES, resource.getUUID());
inputStream = assetResponse.getEntity().getContent();
- int len = (int) assetResponse.getEntity().getContentLength();
- byte[] res = new byte[len];
+ len = (int) assetResponse.getEntity().getContentLength();
+ res = new byte[len];
inputStream.read(res, 0, len);
- byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
+ fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
assertEquals(Base64.encodeBase64(res), fromUiDownload);
- String fileName = assetResponse.getFirstHeader(Constants.CONTENT_DISPOSITION_HEADER).getValue();
+ fileName = assetResponse.getFirstHeader(Constants.CONTENT_DISPOSITION_HEADER).getValue();
assertEquals(fileName, new StringBuilder().append("attachment; filename=\"")
.append(artifactUiDownloadData.getArtifactName()).append("\"").toString());
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java
index fbbd394731..57c678efc7 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetCSARofVF.java
@@ -197,6 +197,7 @@ public class GetCSARofVF extends ComponentBaseTest {
expectedDefinitionFolderFileList.add("Definitions/data.yml");
expectedDefinitionFolderFileList.add("Definitions/capabilities.yml");
expectedDefinitionFolderFileList.add("Definitions/artifacts.yml");
+ expectedDefinitionFolderFileList.add("Definitions/annotations.yml");
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while(entries.hasMoreElements()){
@@ -225,8 +226,8 @@ public class GetCSARofVF extends ComponentBaseTest {
expectedAudit.setRESOURCE_TYPE(resource.getComponentType().getValue());
// AuditValidationUtils.validateExternalAudit(expectedAudit, AuditingActionEnum.GET_TOSCA_MODEL.getName(), null);
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, expectedAudit.getRESOURCE_NAME());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, expectedAudit.getRESOURCE_NAME());
AuditValidationUtils.validateExternalAudit(expectedAudit, AuditingActionEnum.GET_TOSCA_MODEL.getName(), body);
}*/
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java
index 57a0f26a90..fd230d4943 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetFilteredAssetServlet.java
@@ -37,7 +37,6 @@ import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
@@ -388,8 +387,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest {
/*// Validate audit message
ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getFilteredAssetListAuditCategoryNotFound(AssetTypeEnum.RESOURCES, "?" + query, "Application L3+");
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);*/
}
@@ -444,7 +443,7 @@ public class GetFilteredAssetServlet extends ComponentBaseTest {
}
- @Test
+ /*@Test
public void getFilteredServiceAssetInformationalSuccess() throws Exception {
List<String> expectedAssetNamesList = new ArrayList<>();
@@ -500,10 +499,7 @@ public class GetFilteredAssetServlet extends ComponentBaseTest {
List<String> getActualAssetNamesList = AssetRestUtils.getServiceNamesList(resourceAssetList);
Utils.compareArrayLists(getActualAssetNamesList, expectedAssetNamesList, "Element");
- /*// Validate audit message
- validateFilteredAudit(query, AssetTypeEnum.SERVICES);*/
-
- }
+ }*/
@Test
public void getFilteredServiceAssetDeploymentSuccess() throws Exception {
@@ -567,15 +563,15 @@ public class GetFilteredAssetServlet extends ComponentBaseTest {
/*private void validateSuccessAudit(String[] filter, AssetTypeEnum assetType) throws Exception {
ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetListAudit(assetType, AuditingActionEnum.GET_FILTERED_ASSET_LIST);
expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter));
- Map<AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
+ Map<AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);
}
private void validateFilteredAudit(String query, AssetTypeEnum assetType) throws Exception {
ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultFilteredAssetListAudit(assetType, "?" + query);
- Map<AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
+ Map<AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);
}
@@ -584,8 +580,8 @@ public class GetFilteredAssetServlet extends ComponentBaseTest {
expectedAssetListAudit.setRESOURCE_URL(AssetRestUtils.buildUrlWithFilter(expectedAssetListAudit.getRESOURCE_URL(), filter));
expectedAssetListAudit.setSTATUS(errorInfo.getCode().toString());
expectedAssetListAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
- Map<AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
+ Map<AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);
}*/
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java
index c036c7fb41..6bd47e972f 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetSpecificAssetMetadataServlet.java
@@ -20,14 +20,11 @@
package org.openecomp.sdc.externalApis;
-import java.util.ArrayList;
-
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
@@ -39,14 +36,12 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.testng.annotations.Test;
+import java.util.ArrayList;
+
public class GetSpecificAssetMetadataServlet extends ComponentBaseTest {
@Rule
@@ -106,7 +101,7 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest {
Resource resource2 = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
resource2 = (Resource) AtomicOperationUtils.changeComponentState(resource2, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
Resource resource3 = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VFC, UserRoleEnum.DESIGNER, true).left().value();
- resource3 = (Resource) AtomicOperationUtils.changeComponentState(resource3, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFICATIONREQUEST, true).getLeft();
+ resource3 = (Resource) AtomicOperationUtils.changeComponentState(resource3, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
AtomicOperationUtils.addComponentInstanceToComponentContainer(resource2, resourceVF, UserRoleEnum.DESIGNER, true);
AtomicOperationUtils.addComponentInstanceToComponentContainer(resource3, resourceVF, UserRoleEnum.DESIGNER, true);
@@ -129,7 +124,7 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest {
validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/
}
- @Test // (enabled = false)
+ /*@Test // (enabled = false)
public void getResourceAssetMetadataWithResourceInstancesVfInSubmitForTestingSuccess() throws Exception {
Resource resourceVF = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
@@ -155,9 +150,9 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest {
ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse);
AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES);
- /* // Validate audit message
- validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/
- }
+ *//* // Validate audit message
+ validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*//*
+ }*/
@Test // (enabled = false)
public void getResourceAssetMetadataWithResourceInstancesVfInStartCertificationSuccess() throws Exception {
@@ -219,7 +214,7 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest {
validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/
}
- @Test // (enabled = false)
+ /*@Test // (enabled = false)
public void getResourceAssetMetadataWithNonCertifiedResourceInstancesAndArtifactsSuccess() throws Exception {
Resource resourceVF = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, true).left().value();
@@ -241,9 +236,7 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest {
ResourceDetailedAssetStructure resourceAssetMetadata = AssetRestUtils.getResourceAssetMetadata(assetResponse);
AssetRestUtils.resourceMetadataValidatior(resourceAssetMetadata, resourceVF, AssetTypeEnum.RESOURCES);
- /*// Validate audit message
- validateAudit(resourceVF, AssetTypeEnum.RESOURCES);*/
- }
+ }*/
// Import CSAR
@@ -404,8 +397,8 @@ public class GetSpecificAssetMetadataServlet extends ComponentBaseTest {
/*private void validateAudit(Component component, AssetTypeEnum assetType) throws Exception {
ExpectedExternalAudit expectedAssetListAudit = ElementFactory.getDefaultAssetMetadataAudit(assetType, component);
- Map<AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
+ Map<AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedAssetListAudit.getRESOURCE_URL());
AuditValidationUtils.validateExternalAudit(expectedAssetListAudit, AuditingActionEnum.GET_ASSET_METADATA.getName(), body);
}*/
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java
index 8b174e550d..e446dc356e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/SearchFilterCategoryExternalAPI.java
@@ -101,8 +101,8 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_FILTER_KEY.name());
expectedExternalAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
expectedExternalAudit.setSTATUS("400");
- Map<AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
+ Map<AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);
}*/
@@ -129,8 +129,8 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_CONTENT.name());
expectedExternalAudit.setDESC(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
expectedExternalAudit.setSTATUS("400");
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);*/
}
@@ -157,8 +157,8 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest {
/*ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + resourceTypeEnum.toString());
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);*/
}
}
@@ -179,8 +179,8 @@ public class SearchFilterCategoryExternalAPI extends ComponentBaseTest {
validateJsonContainResource(restResponse.getResponse(), createdResoucesName, true);
/*ExpectedExternalAudit expectedExternalAudit = ElementFactory.getDefaultExternalAuditObject(AssetTypeEnum.RESOURCES, AuditingActionEnum.GET_FILTERED_ASSET_LIST, "?" + SearchCriteriaEnum.RESOURCE_TYPE.getValue() + "=" + resourceTypeEnum.toString());
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_URL, expectedExternalAudit.getRESOURCE_URL());
AuditValidationUtils.validateAuditExternalSearchAPI(expectedExternalAudit, AuditingActionEnum.GET_FILTERED_ASSET_LIST.getName(), body);*/
}
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/UserAPIs.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/UserAPIs.java
index 2d1d87ef35..67c7fb0424 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/UserAPIs.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/UserAPIs.java
@@ -20,17 +20,8 @@
package org.openecomp.sdc.externalApis;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
-
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.portalsdk.core.restful.domain.EcompRole;
@@ -51,8 +42,12 @@ import org.openecomp.sdc.ci.tests.utils.rest.UserRestUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.*;
+
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
public class UserAPIs extends ComponentBaseTest {
@@ -311,7 +306,7 @@ public class UserAPIs extends ComponentBaseTest {
}
}
- @Test
+ /*@Test
public void deactivateUserRoleWithStartTestingResource() throws Exception {
EcompUser ecompUser = new EcompUser();
@@ -364,7 +359,7 @@ public class UserAPIs extends ComponentBaseTest {
ResourceRestUtils.deleteResource(resource.getUniqueId(), adminUser.getUserId());
deleteUser(ecompUser.getLoginId());
}
- }
+ }*/
@Test
public void changeUserRoleWithStartTestingResource() throws Exception {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
index 4cd5c1c0d5..8c3404ec67 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
@@ -104,8 +104,8 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
/* // auditing verification
AuditingActionEnum action = AuditingActionEnum.CREATE_RESOURCE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, parsedCreatedResponse.getName());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, parsedCreatedResponse.getName());
ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultCreateResourceExternalAPI(parsedCreatedResponse.getName());
AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body);*/
@@ -152,8 +152,8 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
/*// auditing verification
AuditingActionEnum action = AuditingActionEnum.CREATE_RESOURCE_BY_API;
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, parsedCreatedResponse.getName());
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, parsedCreatedResponse.getName());
ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultCreateResourceExternalAPI(parsedCreatedResponse.getName());
AuditValidationUtils.validateAuditExternalCreateResource(expectedResourceAuditJavaObject, action.getName(), body);*/
@@ -161,7 +161,7 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
RestResponse secondTryToCreate = ResourceRestUtilsExternalAPI.createResource(defaultResource, defaultUser);
Assert.assertEquals((int)secondTryToCreate.getErrorCode(), 409);
- /*body.put(AuditingFieldsKeysEnum.AUDIT_STATUS, "409");
+ /*body.put(AuditingFieldsKey.AUDIT_STATUS, "409");
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_NAME_ALREADY_EXIST.name());
List<String> variables = asList(ComponentTypeEnum.RESOURCE.getValue(), defaultResource.getName());
expectedResourceAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo, variables));
@@ -212,8 +212,8 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
/*List<String> variables = null;
AuditingActionEnum action = AuditingActionEnum.CREATE_RESOURCE_BY_API;
ExpectedResourceAuditJavaObject expectedResourceAuditJavaObject = ElementFactory.getDefaultCreateResourceExternalAPI(defaultResource.getName());
- Map <AuditingFieldsKeysEnum, String> body = new HashMap<>();
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, defaultResource.getName());*/
+ Map <AuditingFieldsKey, String> body = new HashMap<>();
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, defaultResource.getName());*/
switch (flow) {
case "name_missing":
@@ -224,21 +224,21 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_COMPONENT_NAME.name());
/*expectedResourceAuditJavaObject.setResourceName("");
variables = asList(ComponentTypeEnum.RESOURCE.getValue());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "");*/
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, "");*/
break;
case "name_to_long":
defaultResource.setName("asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1");
errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT.name());
/*expectedResourceAuditJavaObject.setResourceName("asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1");
variables = asList(ComponentTypeEnum.RESOURCE.getValue(), "1024");
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1");*/
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, "asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1asdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjklasdfghjk1");*/
break;
case "name_with_invalid_char":
defaultResource.setName("!@#$%^&*(");
errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.INVALID_COMPONENT_NAME.name());
/*expectedResourceAuditJavaObject.setResourceName("!@#$%^&*(");
variables = asList(ComponentTypeEnum.RESOURCE.getValue());
- body.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "!@#$%^&*(");*/
+ body.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME, "!@#$%^&*(");*/
break;
case "description_missing":
defaultResource.setDescription("");
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/internalApis/annotations/AnnotationsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/internalApis/annotations/AnnotationsTest.java
new file mode 100644
index 0000000000..05d7a80eb6
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/internalApis/annotations/AnnotationsTest.java
@@ -0,0 +1,201 @@
+package org.openecomp.sdc.internalApis.annotations;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+import org.openecomp.sdc.be.dao.utils.MapUtil;
+import org.openecomp.sdc.be.datatypes.elements.Annotation;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.utils.ComponentUtilities;
+import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
+import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaAnnotationsTypesDefinition;
+import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
+import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
+import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static java.util.stream.Collectors.groupingBy;
+import static java.util.stream.Collectors.toMap;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaAnnotationsTypesDefinition.SOURCE_ANNOTATION;
+import static org.openecomp.sdc.ci.tests.utils.ToscaTypesDefinitionUtils.getToscaAnnotationsFromCsar;
+import static org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils.*;
+import static org.openecomp.sdc.ci.tests.utils.general.ElementFactory.getDefaultUser;
+import static org.openecomp.sdc.ci.tests.utils.rest.InputsRestUtils.deleteInputFromComponent;
+import static org.openecomp.sdc.ci.tests.utils.validation.BaseValidationUtils.checkSuccess;
+import static org.springframework.util.CollectionUtils.isEmpty;
+
+public class AnnotationsTest extends ComponentBaseTest{
+
+ private static final String PCM_FLAVOR_NAME = "pcm_flavor_name";
+ private static final String AVAILABILITY_ZONE = "availabilityzone_name";
+ private static final String NET_NAME = "net_name";
+ private static final String NF_NAMING_CODE = "nf_naming_code";
+ private static final String [] PROPS_TO_DECLARE = new String [] {PCM_FLAVOR_NAME, AVAILABILITY_ZONE, NET_NAME, NF_NAMING_CODE};
+ private static final String CSAR_WITH_ANNOTATIONS_V1 = "SIROV_annotations_VSP.csar";
+ private static final String CSAR_WITH_ANNOTATIONS_V2 = "SIROV_annotations_VSP_V2.csar";
+ private static final String SRIOV_PATH = FileHandling.getFilePath("SRIOV");
+
+ @Rule
+ public static TestName name = new TestName();
+
+ public AnnotationsTest() {
+ super(name, AnnotationsTest.class.getName());
+ }
+
+ @Test
+ public void whenExportingToscaOfTopologyTemplate_annotationTypeYamlExist_sourceAnnotationExist() throws Exception {
+ User sdncModifierDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ ResourceReqDetails resourceDetails = ElementFactory.getDefaultResourceByType("exportToscaAnnotationsYml", NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncModifierDetails.getUserId(), ResourceTypeEnum.VF.toString());
+ Resource createdVF = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
+ ToscaAnnotationsTypesDefinition toscaAnnotations = getToscaAnnotationsFromCsar(createdVF, sdncModifierDetails);
+ assertTrue(toscaAnnotations.getAnnotation_types().containsKey(SOURCE_ANNOTATION));
+ }
+
+ @Test
+ public void whenDeclaringAnInputFromPropertyWhichOriginatedFromInputWithAnnotation_copyAnnotationsToNewInput() throws Exception {
+ Resource vfWithAnnotationsV1 = importAnnotationsCsarAndCheckIn();
+ Service service = createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
+ ComponentInstance createdCmptInstance = addComponentInstanceToComponentContainer(vfWithAnnotationsV1, service).left().value();
+ Service fetchedService = getServiceObject(service.getUniqueId());
+ List<ComponentInstanceInput> declaredProps = declareProperties(fetchedService, createdCmptInstance, PROPS_TO_DECLARE);
+ verifyAnnotationsOnDeclaredInputs(vfWithAnnotationsV1, fetchedService, declaredProps);
+ Service serviceAfterPropertyDeclaration = getServiceObject(service.getUniqueId());
+ deleteDeclaredInputsAndVerifySuccess(serviceAfterPropertyDeclaration);
+ }
+
+ @Test
+ public void onChangeVersion_copyAnnotationsFromNewVspToServiceInputs() throws Exception {
+ Resource vfWithAnnotationsV1 = importAnnotationsCsarAndCheckIn();
+ Service service = createDefaultService(UserRoleEnum.DESIGNER, true).left().value();
+ ComponentInstance createdCmptInstance = addComponentInstanceToComponentContainer(vfWithAnnotationsV1, service).left().value();
+ Service fetchedService = getServiceObject(service.getUniqueId());
+ declareProperties(fetchedService, createdCmptInstance, PROPS_TO_DECLARE);
+
+ Resource vfWithAnnotationsV2 = updateAnnotationsCsarAndCheckIn(vfWithAnnotationsV1);
+ Pair<Component, ComponentInstance> changeVersionRes = changeComponentInstanceVersion(service, createdCmptInstance, vfWithAnnotationsV2, UserRoleEnum.DESIGNER, true).left().value();
+ Component serviceAfterChangeVersion = changeVersionRes.getKey();
+ ComponentInstance newInstance = changeVersionRes.getRight();
+ List<ComponentInstanceInput> declaredProps = getInstanceProperties(serviceAfterChangeVersion, newInstance.getUniqueId(), PROPS_TO_DECLARE);
+ verifyAnnotationsOnDeclaredInputs(vfWithAnnotationsV2, serviceAfterChangeVersion, declaredProps);
+
+ }
+
+ private void verifyAnnotationsOnDeclaredInputs(Resource vfWithAnnotations, Component fetchedService, List<ComponentInstanceInput> declaredProps) throws Exception {
+ Map<String, InputDefinition> serviceLevelInputsByProperty = getCreatedInputsByProperty(fetchedService, declaredProps);
+ Map<String, List<Annotation>> annotationsFromVfLevelInputs = getAnnotationsByInputName(vfWithAnnotations);
+ verifyInputsAnnotation(serviceLevelInputsByProperty, declaredProps, annotationsFromVfLevelInputs);
+ }
+
+ private Map<String, List<Annotation>> getAnnotationsByInputName(Resource resource) {
+ return resource.getInputs()
+ .stream()
+ .collect(toMap(InputDefinition::getName, input -> ComponentUtilities.getInputAnnotations(resource, input.getName())));
+ }
+
+ private void deleteDeclaredInputsAndVerifySuccess(Component service) throws Exception {
+ for (InputDefinition declaredInput : service.getInputs()) {
+ RestResponse deleteInputResponse = deleteInputFromComponent(service, declaredInput.getUniqueId());
+ checkSuccess(deleteInputResponse);
+ }
+ Service fetchedService = getServiceObject(service.getUniqueId());
+ assertThat(fetchedService.getInputs()).isNullOrEmpty();
+ }
+
+ private void verifyInputsAnnotation(Map<String, InputDefinition> inputsByProperty, List<ComponentInstanceInput> declaredProps, Map<String, List<Annotation>> expectedAnnotationsByInput) {
+ Map<String, ComponentInstanceInput> propsByName = MapUtil.toMap(declaredProps, ComponentInstanceInput::getName);
+
+ InputDefinition declaredFromPcmFlavourName = findInputDeclaredFromProperty(PCM_FLAVOR_NAME, inputsByProperty, propsByName);
+ verifyInputAnnotations(declaredFromPcmFlavourName, expectedAnnotationsByInput.get(PCM_FLAVOR_NAME));
+
+ InputDefinition declaredFromAvailabilityZone = findInputDeclaredFromProperty(AVAILABILITY_ZONE, inputsByProperty, propsByName);
+ verifyInputAnnotations(declaredFromAvailabilityZone, expectedAnnotationsByInput.get(AVAILABILITY_ZONE));
+
+ InputDefinition declaredFromNetName = findInputDeclaredFromProperty(NET_NAME, inputsByProperty, propsByName);
+ verifyInputAnnotations(declaredFromNetName, expectedAnnotationsByInput.get(NET_NAME));
+
+ InputDefinition declaredFromNFNamingCode = findInputDeclaredFromProperty(NF_NAMING_CODE, inputsByProperty, propsByName);
+ verifyInputHasNoAnnotations(declaredFromNFNamingCode);
+ }
+
+ private void verifyInputHasNoAnnotations(InputDefinition inputWithoutAnnotation) {
+ assertThat(inputWithoutAnnotation.getAnnotations()).isNullOrEmpty();
+ }
+
+ private InputDefinition findInputDeclaredFromProperty(String propName, Map<String, InputDefinition> inputsByProperty, Map<String, ComponentInstanceInput> propsByName) {
+ String propId = propsByName.get(propName).getUniqueId();
+ return inputsByProperty.get(propId);
+ }
+
+ private Map<String, InputDefinition> getCreatedInputsByProperty(Component service, List<ComponentInstanceInput> declaredProps) throws Exception {
+ Service fetchedService = getServiceObject(service.getUniqueId());
+ List<InputDefinition> inputs = fetchedService.getInputs();
+ return filterInputsCreatedByDeclaringFromProperties(declaredProps, inputs);
+ }
+
+ private Map<String, InputDefinition> filterInputsCreatedByDeclaringFromProperties(List<ComponentInstanceInput> declaredProps, List<InputDefinition> inputs) {
+ List<String> declaredPropsIds = declaredProps.stream().map(ComponentInstanceInput::getUniqueId).collect(Collectors.toList());
+ Map<String, InputDefinition> inputsByPropertyId = MapUtil.toMap(inputs, InputDefinition::getPropertyId);
+ return Maps.filterKeys(inputsByPropertyId, declaredPropsIds::contains);
+ }
+
+ private Resource importAnnotationsCsarAndCheckIn() throws Exception {
+ Resource annotationsVF = importResourceFromCsar(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, CSAR_WITH_ANNOTATIONS_V1, SRIOV_PATH);
+ changeComponentState(annotationsVF, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
+ return annotationsVF;
+ }
+
+ private Resource updateAnnotationsCsarAndCheckIn(Resource vfToUpdate) throws Exception {
+ changeComponentState(vfToUpdate, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true);
+ Resource annotationsVfV2 = updateResourceFromCsar(vfToUpdate, UserRoleEnum.DESIGNER, CSAR_WITH_ANNOTATIONS_V2, SRIOV_PATH);
+ changeComponentState(annotationsVfV2, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true);
+ return annotationsVfV2;
+ }
+
+ private List<ComponentInstanceInput> declareProperties(Service service, ComponentInstance instance, String ... propertiesToDeclareNames) throws Exception {
+ Map<String, List<ComponentInstanceInput>> propertiesToDeclare = getServiceInstancesProps(service, instance.getUniqueId(), propertiesToDeclareNames);
+ RestResponse restResponse = PropertyRestUtils.declareProporties(service, propertiesToDeclare, getDefaultUser(UserRoleEnum.DESIGNER));
+ checkSuccess(restResponse);
+ return propertiesToDeclare.get(instance.getUniqueId());
+ }
+
+ private List<ComponentInstanceInput> getInstanceProperties(Component service, String ofInstance, String ... propsNames) {
+ return getServiceInstancesProps(service, ofInstance, propsNames).get(ofInstance);
+ }
+
+ private void verifyInputAnnotations(InputDefinition input, List<Annotation> expectedAnnotations) {
+ if (isEmpty(expectedAnnotations)) {
+ assertThat(input.getAnnotations()).isNullOrEmpty();
+ return;
+ }
+ assertThat(input.getAnnotations())
+ .usingElementComparatorOnFields("type", "name", "properties")
+ .isNotEmpty()
+ .containsExactlyElementsOf(expectedAnnotations);
+ }
+
+ private Map<String, List<ComponentInstanceInput>> getServiceInstancesProps(Component fromService, String ofInstance, String ... propsToDeclareNames) {
+ Set<String> propsToDeclare = ImmutableSet.<String>builder().add(propsToDeclareNames).build();
+ List<ComponentInstanceInput> componentInstancesInputs = fromService.getComponentInstancesInputs().get(ofInstance);
+ return componentInstancesInputs.stream()
+ .filter(insInput -> propsToDeclare.contains(insInput.getName()))
+ .collect(groupingBy((i) -> ofInstance));
+ }
+
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java b/test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java
index 5e9e02c479..803e190b59 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/post/Install.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.post;
-import java.io.File;
-
import org.openecomp.sdc.be.dao.DAOTitanStrategy;
import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import java.io.File;
+
public class Install {
public static void main(String[] args) {