From 7db40ac5a55b688cae3335d9f62ca831e604b32f Mon Sep 17 00:00:00 2001 From: "Stone, Avi (as206k)" Date: Mon, 21 May 2018 14:57:57 +0300 Subject: Fix pom for CI Fix pom for CI so the project will not use D2 library any more Change-Id: I5398b8c974df11d2cb0e73778db69d1eb9f94593 Issue-ID: SDC-1339 Signed-off-by: Stone, Avi (as206k) --- pom.xml | 120 ++++--- .../dcae/ci/api/healthcheck/HealthcheckTest.java | 62 ---- .../ecomp/dcae/ci/api/tests/DcaeRestBaseTest.java | 196 ------------ .../tests/blueprint/SaveCompositionPositve.java | 110 ------- .../composition/CompositionControllerApiTests.java | 203 ------------ .../CompositionElementsControllerTests.java | 198 ------------ .../CompositionMicroServicesApiTests.java | 154 --------- .../composition/GetCompositionControllerTests.java | 106 ------- .../SaveAndSubmitCompositionFullFlowTest.java | 115 ------- .../dcae/ci/api/tests/lifeCycle/ArrangeHelper.java | 68 ---- .../dcae/ci/api/tests/lifeCycle/PutCertify.java | 49 --- .../dcae/ci/api/tests/lifeCycle/PutCheckin.java | 145 --------- .../dcae/ci/api/tests/lifeCycle/PutCheckout.java | 148 --------- .../ci/api/tests/ruleEditor/GetDefinitionTest.java | 137 -------- .../ruleEditor/GetListEventsAndVersionsTest.java | 47 --- .../tests/ruleEditor/RuleEditorControllerTest.java | 319 ------------------- .../tests/services/attachment/GetAttachment.java | 62 ---- .../tests/services/attachment/PostAttachment.java | 172 ---------- .../instance/GetServiceInstanceNagative.java | 24 -- .../instance/GetServiceInstancePositive.java | 122 ------- .../services/list/GetAllServicesNagative.java | 48 --- .../services/list/GetAllServicesPositive.java | 72 ----- .../api/tests/vfcmt/CreateMonitoringComponent.java | 253 --------------- .../ecomp/dcae/ci/api/tests/vfcmt/CreateVfcmt.java | 140 -------- .../vfcmt/GetAllMonitoringTemplateVfcmts.java | 60 ---- .../dcae/ci/api/tests/vfcmt/GetAllVfcmts.java | 54 ---- .../ci/api/tests/vfcmt/GetVfcmtsForMigration.java | 104 ------ .../dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java | 37 --- .../ci/entities/composition/items/Artifact.java | 109 ------- .../dcae/ci/entities/composition/items/Data.java | 21 -- .../entities/composition/items/DcaeComponents.java | 54 ---- .../ci/entities/composition/items/Element.java | 55 ---- .../dcae/ci/entities/composition/items/Error.java | 8 - .../dcae/ci/entities/composition/items/Item.java | 220 ------------- .../dcae/ci/entities/composition/items/Model.java | 65 ---- .../composition/rightMenu/element/Artifact.java | 109 ------- .../composition/rightMenu/element/Item.java | 220 ------------- .../rightMenu/element/ItemsElement.java | 55 ---- .../composition/rightMenu/element/Model.java | 65 ---- .../composition/rightMenu/element/Service.java | 21 -- .../composition/rightMenu/elements/Element.java | 76 ----- .../composition/rightMenu/elements/Elements.java | 18 -- .../entities/composition/services/CiService.java | 11 - .../dcae/ci/entities/composition/services/Vfi.java | 21 -- .../ci/entities/rule_editor/SaveRuleError.java | 27 -- .../ecomp/dcae/ci/entities/sdc/SdcCategory.java | 20 -- .../ecomp/dcae/ci/entities/sdc/SdcComponent.java | 40 --- .../dcae/ci/entities/sdc/SdcComponentMetadata.java | 12 - .../com/att/ecomp/dcae/ci/run/RunTestSuite.java | 11 - .../dcae/ci/ui/pages/DCAECompositionPage.java | 70 ---- .../ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java | 41 --- .../att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java | 27 -- .../att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java | 28 -- .../ecomp/dcae/ci/ui/pages/DCAEServicesPage.java | 38 --- .../dcae/ci/ui/pages/SDCCreateServicePage.java | 175 ---------- .../ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java | 123 ------- .../att/ecomp/dcae/ci/ui/pages/SDCHomePage.java | 60 ---- .../att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java | 143 --------- .../dcae/ci/ui/rule_editor/TranslateResult.java | 32 -- .../ui/rule_editor/components/BaseComponenet.java | 15 - .../ci/ui/rule_editor/components/HomePage.java | 113 ------- .../ci/ui/rule_editor/components/LoginPage.java | 39 --- .../ui/rule_editor/components/RuleComponent.java | 40 --- .../ci/ui/rule_editor/components/RulePopup.java | 141 -------- .../components/actions/ActionComponent.java | 48 --- .../rule_editor/components/actions/ActionType.java | 7 - .../components/actions/ConcatActionComponent.java | 31 -- .../components/actions/CopyActionComponent.java | 24 -- .../components/actions/MapActionComponent.java | 44 --- .../actions/from/DeleteableFromComponent.java | 26 -- .../actions/from/RegexFromComponent.java | 38 --- .../actions/from/SimpleFromComponent.java | 34 -- .../components/condition/ConditionComponent.java | 34 -- .../dcae/ci/ui/rule_editor/tests/SanityTest.java | 150 --------- .../com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java | 83 ----- .../ecomp/dcae/ci/ui/setup/DcaeConfiguration.java | 48 --- .../com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java | 99 ------ .../com/att/ecomp/dcae/ci/ui/tests/SanityTest.java | 108 ------- .../att/ecomp/dcae/ci/ui/tests/ServiceTest.java | 42 --- .../tests/verificator/CompositionVerificator.java | 16 - .../ui/tests/verificator/ServiceVerificator.java | 22 -- .../com/att/ecomp/dcae/ci/ui/utils/ByTest.java | 17 - .../com/att/ecomp/dcae/ci/ui/utils/Locator.java | 74 ----- .../att/ecomp/dcae/ci/ui/utils/NestedFilter.java | 28 -- .../att/ecomp/dcae/ci/ui/utils/NestedFinder.java | 28 -- .../dcae/ci/utilities/ConfigurationReader.java | 41 --- .../ecomp/dcae/ci/utilities/DcaeEntityClient.java | 139 -------- .../ecomp/dcae/ci/utilities/DcaeRestClient.java | 247 -------------- .../ecomp/dcae/ci/utilities/DcaeTestConstants.java | 19 -- .../com/att/ecomp/dcae/ci/utilities/DcaeUtil.java | 200 ------------ .../com/att/ecomp/dcae/ci/utilities/Report.java | 26 -- .../dcae/ci/utilities/SdcInternalApiClient.java | 131 -------- .../att/ecomp/dcae/ci/utilities/StringUtils.java | 16 - .../dcae/ci/api/healthcheck/HealthcheckTest.java | 59 ++++ .../onap/dcae/ci/api/tests/DcaeRestBaseTest.java | 166 ++++++++++ .../tests/blueprint/SaveCompositionPositve.java | 109 +++++++ .../composition/CompositionControllerApiTests.java | 201 ++++++++++++ .../CompositionElementsControllerTests.java | 200 ++++++++++++ .../CompositionMicroServicesApiTests.java | 90 ++++++ .../composition/GetCompositionControllerTests.java | 105 ++++++ .../SaveAndSubmitCompositionFullFlowTest.java | 116 +++++++ .../ci/api/tests/deploy_tool/DeployToolTest.java | 19 ++ .../dcae/ci/api/tests/lifeCycle/ArrangeHelper.java | 68 ++++ .../dcae/ci/api/tests/lifeCycle/PutCertify.java | 34 ++ .../dcae/ci/api/tests/lifeCycle/PutCheckin.java | 146 +++++++++ .../dcae/ci/api/tests/lifeCycle/PutCheckout.java | 148 +++++++++ .../ci/api/tests/ruleEditor/GetDefinitionTest.java | 138 ++++++++ .../ruleEditor/GetListEventsAndVersionsTest.java | 49 +++ .../tests/ruleEditor/RuleEditorControllerTest.java | 353 +++++++++++++++++++++ .../tests/services/attachment/GetAttachment.java | 62 ++++ .../tests/services/attachment/PostAttachment.java | 173 ++++++++++ .../instance/GetServiceInstanceNagative.java | 25 ++ .../instance/GetServiceInstancePositive.java | 121 +++++++ .../services/list/GetAllServicesNagative.java | 47 +++ .../services/list/GetAllServicesPositive.java | 72 +++++ .../api/tests/vfcmt/CreateMonitoringComponent.java | 253 +++++++++++++++ .../onap/dcae/ci/api/tests/vfcmt/CreateVfcmt.java | 126 ++++++++ .../vfcmt/GetAllMonitoringTemplateVfcmts.java | 61 ++++ .../onap/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java | 55 ++++ .../ci/api/tests/vfcmt/GetVfcmtsForMigration.java | 96 ++++++ .../dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java | 37 +++ .../org/onap/dcae/ci/config/Configuration.java | 299 +++++++++++++++++ .../org/onap/dcae/ci/entities/RestResponse.java | 57 ++++ .../ci/entities/composition/items/Artifact.java | 109 +++++++ .../dcae/ci/entities/composition/items/Data.java | 21 ++ .../entities/composition/items/DcaeComponents.java | 56 ++++ .../ci/entities/composition/items/Element.java | 55 ++++ .../dcae/ci/entities/composition/items/Error.java | 8 + .../dcae/ci/entities/composition/items/Item.java | 220 +++++++++++++ .../dcae/ci/entities/composition/items/Model.java | 65 ++++ .../composition/rightMenu/element/Artifact.java | 109 +++++++ .../composition/rightMenu/element/Item.java | 220 +++++++++++++ .../rightMenu/element/ItemsElement.java | 55 ++++ .../composition/rightMenu/element/Model.java | 65 ++++ .../composition/rightMenu/element/Service.java | 21 ++ .../composition/rightMenu/elements/Element.java | 76 +++++ .../composition/rightMenu/elements/Elements.java | 18 ++ .../entities/composition/services/CiService.java | 11 + .../dcae/ci/entities/composition/services/Vfi.java | 21 ++ .../ci/entities/rule_editor/SaveRuleError.java | 27 ++ .../org/onap/dcae/ci/entities/sdc/SdcCategory.java | 28 ++ .../onap/dcae/ci/entities/sdc/SdcComponent.java | 113 +++++++ .../dcae/ci/entities/sdc/SdcComponentFactory.java | 41 +++ .../dcae/ci/entities/sdc/SdcComponentInstance.java | 20 ++ .../dcae/ci/entities/sdc/SdcComponentMetadata.java | 12 + .../org/onap/dcae/ci/entities/sdc/SdcResource.java | 26 ++ .../org/onap/dcae/ci/entities/sdc/SdcService.java | 37 +++ .../org/onap/dcae/ci/enums/HttpHeaderEnum.java | 25 ++ .../org/onap/dcae/ci/report/ExtentManager.java | 192 +++++++++++ .../org/onap/dcae/ci/report/ExtentTestManager.java | 42 +++ src/main/java/org/onap/dcae/ci/report/Report.java | 155 +++++++++ .../java/org/onap/dcae/ci/run/RunTestSuite.java | 28 ++ .../org/onap/dcae/ci/utilities/BaseRestUtils.java | 96 ++++++ .../dcae/ci/utilities/ConfigurationReader.java | 39 +++ .../onap/dcae/ci/utilities/DcaeEntityClient.java | 148 +++++++++ .../org/onap/dcae/ci/utilities/DcaeRestClient.java | 263 +++++++++++++++ .../onap/dcae/ci/utilities/DcaeTestConstants.java | 19 ++ .../java/org/onap/dcae/ci/utilities/DcaeUtil.java | 205 ++++++++++++ .../org/onap/dcae/ci/utilities/HttpRequest.java | 305 ++++++++++++++++++ .../dcae/ci/utilities/SdcInternalApiClient.java | 107 +++++++ .../org/onap/dcae/ci/utilities/SetupReport.java | 131 ++++++++ .../org/onap/dcae/ci/utilities/StringUtils.java | 16 + src/main/resources/scripts/run.sh | 2 +- src/main/resources/testSuite/testSuite.xml | 57 ++-- src/main/resources/testSuite/testSuiteSelenium.xml | 10 - 165 files changed, 6805 insertions(+), 7422 deletions(-) delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/healthcheck/HealthcheckTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/DcaeRestBaseTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionControllerApiTests.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/GetCompositionControllerTests.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCertify.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckin.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckout.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/GetAttachment.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/PostAttachment.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesNagative.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesPositive.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateVfcmt.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Artifact.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Data.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/DcaeComponents.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Element.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Error.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Item.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Model.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Artifact.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Item.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Model.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Service.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Element.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Elements.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/CiService.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/Vfi.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/rule_editor/SaveRuleError.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcCategory.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponentMetadata.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/run/RunTestSuite.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/utilities/ConfigurationReader.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeEntityClient.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeRestClient.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeTestConstants.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeUtil.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/utilities/Report.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/utilities/SdcInternalApiClient.java delete mode 100644 src/main/java/com/att/ecomp/dcae/ci/utilities/StringUtils.java create mode 100644 src/main/java/org/onap/dcae/ci/api/healthcheck/HealthcheckTest.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/DcaeRestBaseTest.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionControllerApiTests.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/composition/GetCompositionControllerTests.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/deploy_tool/DeployToolTest.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCertify.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckin.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckout.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/services/attachment/GetAttachment.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/services/attachment/PostAttachment.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesNagative.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesPositive.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateVfcmt.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java create mode 100644 src/main/java/org/onap/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java create mode 100644 src/main/java/org/onap/dcae/ci/config/Configuration.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/RestResponse.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/items/Artifact.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/items/Data.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/items/DcaeComponents.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/items/Element.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/items/Error.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/items/Item.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/items/Model.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Artifact.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Item.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Model.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Service.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Element.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Elements.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/services/CiService.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/composition/services/Vfi.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/rule_editor/SaveRuleError.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/sdc/SdcCategory.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponent.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentFactory.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentInstance.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentMetadata.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/sdc/SdcResource.java create mode 100644 src/main/java/org/onap/dcae/ci/entities/sdc/SdcService.java create mode 100644 src/main/java/org/onap/dcae/ci/enums/HttpHeaderEnum.java create mode 100644 src/main/java/org/onap/dcae/ci/report/ExtentManager.java create mode 100644 src/main/java/org/onap/dcae/ci/report/ExtentTestManager.java create mode 100644 src/main/java/org/onap/dcae/ci/report/Report.java create mode 100644 src/main/java/org/onap/dcae/ci/run/RunTestSuite.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/BaseRestUtils.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/ConfigurationReader.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/DcaeEntityClient.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/DcaeRestClient.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/DcaeTestConstants.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/DcaeUtil.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/HttpRequest.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/SdcInternalApiClient.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/SetupReport.java create mode 100644 src/main/java/org/onap/dcae/ci/utilities/StringUtils.java delete mode 100644 src/main/resources/testSuite/testSuiteSelenium.xml diff --git a/pom.xml b/pom.xml index f4b2ea9..46648ac 100644 --- a/pom.xml +++ b/pom.xml @@ -13,19 +13,15 @@ 1.8 UTF-8 UTF-8 - https://nexus.onap.org + https://nexus.onap.org 176c31dfe190a + 4.5.5 + 1.21 + 1.7.25 - - org.openecomp.d2 - ui-api-ci - 1.0.1-SNAPSHOT - - - org.assertj assertj-core @@ -38,7 +34,82 @@ DCAE-DT-PROPERTY ${project.version} - + + + + org.yaml + snakeyaml + ${snakeyaml.version} + compile + + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + compile + + + + org.apache.httpcomponents + httpmime + ${httpclient.version} + compile + + + + commons-io + commons-io + 2.5 + compile + + + + org.apache.commons + commons-collections4 + 4.1 + + + + com.google.code.gson + gson + 2.8.4 + + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + + org.slf4j + slf4j-api + ${slf4j.version} + compile + + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + org.testng + testng + 6.14.3 + compile + + + + com.aventstack + extentreports + 3.1.5 + compile + + + @@ -56,7 +127,7 @@ - com.att.ecomp.dcae.ci.run.RunTestSuite + org.onap.dcae.ci.run.RunTestSuite @@ -66,34 +137,10 @@ - - - org.apache.maven.plugins - maven-site-plugin - 3.4 - - - org.apache.maven.wagon - wagon-webdav-jackrabbit - 2.10 - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ${nexus.proxy} - ${staging.profile.id} - ecomp-staging - - - + + ecomp-releases @@ -129,4 +176,5 @@ dav:${nexus.proxy}${sitePath} + diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/healthcheck/HealthcheckTest.java b/src/main/java/com/att/ecomp/dcae/ci/api/healthcheck/HealthcheckTest.java deleted file mode 100644 index 6a3755a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/healthcheck/HealthcheckTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.att.ecomp.dcae.ci.api.healthcheck; - -import static org.assertj.core.api.Assertions.*; -import org.testng.annotations.*; - -import java.io.IOException; -import java.util.List; - -import org.assertj.core.api.SoftAssertions; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.onap.sdc.dcae.composition.restmodels.health.ComponentsInfo; -import org.onap.sdc.dcae.composition.restmodels.health.HealthResponse; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class HealthcheckTest extends DcaeRestBaseTest { - - @Test - public void getHealthcheck_statusOK() throws IOException { - Report.log(Status.INFO, "Starting Health Check test"); - RestResponse response = DcaeRestClient.getHealthcheck(); - Report.log(Status.INFO, "Health Check response=%s", response); - assertThat(response.getStatusCode().intValue()) - .as("response status") - .isEqualTo(200); - } - - @Test - public void getHealthcheck_validDataStructure() throws IOException { - Report.log(Status.INFO, "Starting getHealthcheck_validDataStructure"); - RestResponse response = DcaeRestClient.getHealthcheck(); - Report.log(Status.INFO, "Response=%s", response); - HealthResponse hcData = gson.fromJson(response.getResponse(), HealthResponse.class); - - SoftAssertions.assertSoftly(softly -> { - assertHealthStructure(softly, hcData, "DCAE Designer"); - List componentsInfo = hcData.getComponentsInfo(); - softly.assertThat(componentsInfo).extracting("healthCheckComponent").contains("BE", "TOSCA_LAB"); - assertHealthComponentStructure(softly, hcData.getComponentsInfo().get(0)); - assertHealthComponentStructure(softly, hcData.getComponentsInfo().get(1)); - }); - } - - private void assertHealthStructure(SoftAssertions softly, HealthResponse hcData, String name) { - softly.assertThat(hcData.getHealthCheckComponent()).isEqualTo(name); - softly.assertThat(hcData.getHealthCheckStatus()).isEqualTo("UP"); - softly.assertThat(hcData.getSdcVersion()).isNotEmpty(); - softly.assertThat(hcData.getDescription()).isNotEmpty(); - } - - private void assertHealthComponentStructure(SoftAssertions softly, ComponentsInfo hcData) { - softly.assertThat(hcData.getHealthCheckStatus()).isEqualTo("UP"); - softly.assertThat(hcData.getVersion()).isNotEmpty(); - softly.assertThat(hcData.getDescription()).isNotEmpty(); - } -} \ No newline at end of file diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/DcaeRestBaseTest.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/DcaeRestBaseTest.java deleted file mode 100644 index 2dd0646..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/DcaeRestBaseTest.java +++ /dev/null @@ -1,196 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests; - -import com.att.ecomp.dcae.ci.entities.composition.services.CiService; -import com.att.ecomp.dcae.ci.entities.sdc.SdcComponent; -import com.att.ecomp.dcae.ci.utilities.*; -import org.openecomp.d2.ci.datatypes.Configuration; -import org.openecomp.d2.ci.setup.SetupReport; - -import com.aventstack.extentreports.Status; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import org.onap.sdc.dcae.composition.model.Requirement; -import org.onap.sdc.dcae.composition.model.Value; -import org.onap.sdc.dcae.composition.model.deserializer.RequirementDeserializer; -import org.onap.sdc.dcae.composition.model.deserializer.ValueDeserializer; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.ActionDeserializer; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.BaseAction; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.BaseCondition; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.ConditionDeserializer; -import org.onap.sdc.dcae.composition.services.Artifact; -import org.onap.sdc.dcae.composition.services.Resource; -import org.onap.sdc.dcae.composition.services.Service; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.api.ResponseParser; -import org.openecomp.d2.ci.api.ServiceRestUtils; -import org.openecomp.d2.ci.api.VfRestUtils; -import org.openecomp.d2.ci.datatypes.*; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUtility; -import org.testng.annotations.AfterSuite; - -import java.io.IOException; -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Collections; - - -public class DcaeRestBaseTest extends SetupReport { - - public static Gson gson = null; - protected DcaeEntityClient client = new DcaeEntityClient(); - - public DcaeRestBaseTest() { - super(); - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapter(Requirement.class, new RequirementDeserializer()); - gsonBuilder.registerTypeAdapter(Value.class, new ValueDeserializer()); - gsonBuilder.registerTypeAdapter(BaseAction.class, new ActionDeserializer()); - gsonBuilder.registerTypeAdapter(BaseCondition.class, new ConditionDeserializer()); - gson = gsonBuilder.create(); - } - - @Override - protected Configuration getEnvConfiguration() { - return ConfigurationReader.getConfiguration(); - } - - protected Service createServiceWithVFiAsSdcDesigner() throws Exception{ - ExtentTestActions.log(Status.INFO, "Create Service with VFi as SDC Designer method started"); - ServiceReqDetails defaultService = ElementFactory.getDefaultService(); - - ExtentTestActions.log(Status.INFO, "Going to create service with name " + defaultService.getName()); - ResourceReqDetails vf = ElementFactory.getDefaultResource(ResourceTypeEnum.VF); - - User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - - RestResponse createServiceRes = ServiceRestUtils.createService(defaultService, defaultUser); - Status logSts = checkForErrors(createServiceRes); - ExtentTestActions.log(logSts, "Service with uuid " + defaultService.getUUID() +" created"); - - RestResponse createResourceRes = VfRestUtils.createResource(vf, defaultUser); - logSts = checkForErrors(createResourceRes); - ExtentTestActions.log(logSts, "VF with uuid " + vf.getUUID() +" created"); - - RestResponse changeResourceStateRes = VfRestUtils.changeResourceState(vf, defaultUser, LifeCycleStatesEnum.CHECKIN); - logSts = checkForErrors(changeResourceStateRes); - ExtentTestActions.log(logSts, "VF with uuid " + vf.getUUID() + " was checked in"); - - RestResponse createVfiRes = ServiceRestUtils.createComponentInstance(defaultService, vf, defaultUser, ComponentTypeEnum.RESOURCE, true); - logSts = checkForErrors(createVfiRes); - ExtentTestActions.log(logSts, "VF instance added to service"); - - String vfiName = ResponseParser.getValueFromJsonResponse(createVfiRes.getResponse(), "name"); - return convertToDcaeServiceWithVfi(defaultService, vfiName); - - } - - private Status checkForErrors(RestResponse httpResponse) { - Status logSts = httpResponse.getStatusCode()==200 || httpResponse.getStatusCode()==201 ? Status.INFO : Status.ERROR; - assertThat(httpResponse.getStatusCode()).isIn(200, 201); - return logSts; - } - - // converts from ui-api-ci object to dcae-ci object (partial construction) - private Service convertToDcaeServiceWithVfi(ServiceReqDetails service, String vfiName){ - Service newService = new CiService(service); - Resource newVfi = new Resource(); - newVfi.setResourceInstanceName(vfiName); - newService.setResources(Arrays.asList(newVfi)); - return newService; - } - - protected Vfcmt createVfcmt() throws IOException { - String newName = "CI" + GeneralUtility.generateUUIDforSufix(); - Report.log(Status.INFO, "createVfcmt start"); - RestResponse res = DcaeRestClient.createVfcmt(newName, "description"); - Report.log(Status.INFO, "createVfcmt response=%s", res); - assertThat(res.getStatusCode()).isEqualTo(200); - return gson.fromJson(res.getResponse(), Vfcmt.class); - } - - protected Artifact fetchVfcmtArtifactMetadataByName(String vfcmtUid, String artifactName) throws IOException { - Report.log(Status.INFO, "fetchVfcmtArtifactMetadataByName, vfcmtUid="+vfcmtUid+", artifactName"+artifactName); - RestResponse res = DcaeRestClient.getResourceDetails(vfcmtUid); - Resource vfcmt = gson.fromJson(res.getResponse(), Resource.class); - return vfcmt.getArtifacts().stream() - .filter(a -> artifactName.equalsIgnoreCase(a.getArtifactName())) - .findAny() - .orElse(null); - } - - //***** delete all assets created by test users - uses internal SDC API ****// - - @AfterSuite(alwaysRun = true) - public static void cleanup() throws IOException { - - final String resources = "resources"; - final String services = "services"; - List testUsers = Collections.synchronizedList(Arrays.asList(UserRoleEnum.DESIGNER.getUserId(), UserRoleEnum.DESIGNER2.getUserId())); - Map> testComponents = testUsers.parallelStream() - .map(DcaeRestBaseTest::getSafeComponentByUser) - .flatMap(m -> m.entrySet().stream()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (v1, v2) -> { - v1.addAll(v2); - return v1; - })); - collectAllResourceIds(Collections.synchronizedList(testComponents.get(resources))).parallelStream().forEach(id -> deleteAsset(resources, id)); - collectAllServiceIds(Collections.synchronizedList(testComponents.get(services))).parallelStream().forEach(id -> deleteAsset(services, id)); - SdcInternalApiClient.deleteMarkedResources(); - SdcInternalApiClient.deleteMarkedServices(); - } - - private static Set getUidsToDelete(String context, SdcComponent component) { - try { - return Arrays.asList("0.1", "1.0").contains(component.getVersion()) ? Collections.singleton(component.getUniqueId()) : - new HashSet<>(SdcInternalApiClient.getAssetMetadata(context, component.getUniqueId(), component.getLastUpdaterUserId()).getMetadata().getAllVersions().values()); - } catch (Exception e) { - Report.log(Status.ERROR, "failed to fetch sdc component: %s, Error: %s", component.getUniqueId(), e); - return Collections.emptySet(); - } - } - - private static Set collectAllResourceIds(List resources) { - Predicate deleteResource = p -> Arrays.asList("VF", "VFCMT").contains(p.getResourceType()) && !"Base Monitoring Template".equals(p.getCategories().get(0).getSubcategories().get(0).getName()); - Set resourceIds = Collections.synchronizedSet(resources.parallelStream() - .filter(deleteResource) - .map(r -> getUidsToDelete("resources", r)) - .flatMap(Set::stream) - .collect(Collectors.toSet())); - Report.log(Status.INFO, "collected %s resourceIds", resourceIds.size()); - return resourceIds; - } - - private static Set collectAllServiceIds(List services) { - Set serviceIds = Collections.synchronizedSet(services.parallelStream() - .map(c -> getUidsToDelete("services", c)) - .flatMap(Set::stream) - .collect(Collectors.toSet())); - Report.log(Status.INFO, "collected %s serviceIds", serviceIds.size()); - return serviceIds; - } - - private static Map> getSafeComponentByUser(String userId) { - try { - return SdcInternalApiClient.getAssetsByUser(userId); - } catch (Exception e){ - Report.log(Status.ERROR, "failed to fetch followed components. Error: %s", e); - return new HashMap<>(); - } - } - - private static void deleteAsset(String context, String id) { - try { - Report.log(Status.INFO, "about to delete sdc asset(%s): %s", context, id); - SdcInternalApiClient.deleteAssetFromSdc(context, id); - } catch (Exception e){ - Report.log(Status.ERROR, "failed to delete sdc asset(%s): %s, Error: %s" ,context, id, e); - } - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java deleted file mode 100644 index 17dcce8..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.blueprint; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeUtil; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.text.WordUtils; -import org.assertj.core.api.SoftAssertions; -import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; -import org.onap.sdc.dcae.composition.services.Service; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SaveCompositionPositve extends DcaeRestBaseTest { - - private RestResponse response; - private static final String VFCMT_NAME = "teSt.__.monitoring---TempLATE."; - - private Vfcmt createVFCMTAndServiceWithVFIAndAttach() throws Exception{ - Report.log(Status.INFO, "createVFCMTAndServiceWithVFIAndAttach start"); - Vfcmt newVfcmt = createNewVfcmt(); - - // create a service in sdc - Service newService = createServiceWithVFiAsSdcDesigner(); - - String serviceUuid = newService.getUuid(); - String vfiName = newService.getResources().get(0).getResourceInstanceName(); - String vfcmtId = newVfcmt.getUuid(); - - // attach VFCMT to vfi and service (creation of svc_reference file in the BE) - Report.log(Status.INFO, "Going to attach the created service and VFi to the VFCMT"); - RestResponse res = DcaeRestClient.attachVfiRef(vfcmtId, serviceUuid, vfiName); - Report.log(Status.INFO, "attachment result="+res); - - return newVfcmt; - } - - private Vfcmt createNewVfcmtWithoutArtifact() throws Exception{ - Report.log(Status.INFO, "createNewVfcmtWithoutArtifact"); - Vfcmt newVfcmt = createNewVfcmt(); - return newVfcmt; - } - - private Vfcmt createNewVfcmt() throws Exception { - String randomSuffix = WordUtils.capitalize(RandomStringUtils.randomAlphanumeric(4).toLowerCase()); - Vfcmt newVfcmt = createVfcmtInstance(randomSuffix); - return newVfcmt; - } - - private Vfcmt createVfcmtInstance(String randomSuffix) throws Exception{ - String newName = VFCMT_NAME + randomSuffix; - RestResponse res = DcaeRestClient.createVfcmt(newName,"description"); - assertThat(res.getStatusCode()).isEqualTo(200); - return gson.fromJson(res.getResponse(), Vfcmt.class); - } - - - - @Test - public void test_responseStatusOkAndCreateMode() throws Exception{ - // assert - ExtentTestActions.log(Status.INFO, "Save Composition init"); - Vfcmt vfcmtWithoutArtifactUuid = createNewVfcmtWithoutArtifact(); - String uuid = vfcmtWithoutArtifactUuid.getUuid(); - String lastUpdaterUserId = vfcmtWithoutArtifactUuid.getLastUpdaterUserId(); - response = DcaeRestClient.saveComposition(uuid, lastUpdaterUserId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat((gson.fromJson(response.getResponse(), Resource.class)).getVersion()) - .as("version") - .isEqualTo("0.1"); - }); - } - - @Test - public void test_updateMode() throws Exception { - // assert - ExtentTestActions.log(Status.INFO, "Save Composition init"); - Vfcmt vfcmtWithArtifactUuid = createVFCMTAndServiceWithVFIAndAttach(); - String uuid = vfcmtWithArtifactUuid.getUuid(); - String lastUpdaterUserId = vfcmtWithArtifactUuid.getLastUpdaterUserId(); - ExtentTestActions.log(Status.INFO, "New VFCMT uuid="+uuid+", lastUpdaterUserId="+lastUpdaterUserId); - //generate cdump - String cdump = DcaeUtil.generateCdumpFromSnmpModels(uuid); - // save composition.yml - ExtentTestActions.log(Status.INFO, "Going to Save the composition now"); - DcaeRestClient.saveComposition(uuid, lastUpdaterUserId, cdump); - // update - response = DcaeRestClient.saveComposition(uuid, lastUpdaterUserId, cdump); - ExtentTestActions.log(Status.DEBUG, "Save composition Response: " + StringUtils.truncate(response)); - ExtentTestActions.log(Status.INFO, "Verifying response status is 200"); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat((gson.fromJson(response.getResponse(), Resource.class)).getVersion()) - .as("version") - .isEqualTo("0.3"); - }); - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionControllerApiTests.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionControllerApiTests.java deleted file mode 100644 index 9f8833b..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionControllerApiTests.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.text.WordUtils; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.json.simple.parser.ParseException; -import org.onap.sdc.dcae.composition.services.Artifact; -import org.onap.sdc.dcae.composition.util.DcaeBeConstants; -import org.openecomp.d2.ci.api.ResponseParser; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import org.onap.sdc.dcae.composition.services.Resource; -import org.onap.sdc.dcae.composition.services.Service; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeUtil; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; -import com.google.gson.JsonObject; - -public class CompositionControllerApiTests extends DcaeRestBaseTest { - - private static final String EVENT_PROC_BP_YAML = "event_proc_bp.yaml"; - private static final String CREATE_BLUEPRINT_DESCRIPTION = "creating new artifact blueprint on the service vfi"; - private static final String UPDATE_BLUEPRINT_DESCRIPTION = "updating artifact blueprint on the service vfi"; - private static final String VFCMT_NAME = "teSt.__.monitoring---TempLATE."; - private static final String NORMALIZED_VFCMT_NAME = "TestMonitoringTemplate"; - - @Test - public void createMultipleBlueprintsTest() throws Exception { - Report.log(Status.INFO, "createMultipleBlueprintsTest start"); - String randomSuffix = WordUtils.capitalize(RandomStringUtils.randomAlphanumeric(4).toLowerCase()); - Vfcmt newVfcmt = createVfcmt(randomSuffix); - - // create a service in sdc - Service newService = createServiceWithVFiAsSdcDesigner(); - - String serviceUuid = newService.getUuid(); - String vfiName = newService.getResources().get(0).getResourceInstanceName(); - String vfcmtId = newVfcmt.getUuid(); - - // attach VFCMT to vfi - Report.log(Status.INFO, "Trying to attach the service+vfi to the vfcmt. serviceUuid="+serviceUuid+", vfiName="+vfiName+", vfcmtId="+vfcmtId); - RestResponse res = DcaeRestClient.attachVfiRef(vfcmtId, serviceUuid, vfiName); - assertThat(res.getStatusCode()).isEqualTo(200); - - //generate and save composition.yml(cdump) - generateAndSaveCdump(vfcmtId); - - String bpType1 = "bpType t1"; - String bpType2 = "bpType T2"; - String normalizedVfcmtName = NORMALIZED_VFCMT_NAME + randomSuffix; - List> expectedBpDetails = Arrays.asList(buildBlueprintDetails(bpType1, normalizedVfcmtName), buildBlueprintDetails(bpType2, normalizedVfcmtName)); - - // submit - generate and save type1 blueprint artifact - Report.log(Status.INFO, "Going to Submit the composition with vfcmtId="+vfcmtId+", serviceUuid="+serviceUuid+", vfiName="+vfiName+", TYPE1="+bpType1); - res = DcaeRestClient.submitComposition(vfcmtId, serviceUuid, vfiName, bpType1); - assertBlueprintSuccessResponse(res); - - // 1806 US 374593 assert vfcmt is certified - res = DcaeRestClient.getResourceDetails(vfcmtId); - newVfcmt = gson.fromJson(res.getResponse(), Vfcmt.class); - Report.log(Status.INFO, "Checking lifecycle state of vfcmt after first blueprint submission. State = {}", newVfcmt.getLifecycleState()); - assertThat(newVfcmt.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.CERTIFIED.name()); - Report.log(Status.INFO, "Checking version of vfcmt after first blueprint submission. Version = {}", newVfcmt.getVersion()); - assertThat(newVfcmt.getVersion()).isEqualTo("1.0"); - - res = DcaeRestClient.checkoutVfcmt(vfcmtId, newVfcmt.getLastUpdaterUserId()); - newVfcmt = gson.fromJson(res.getResponse(), Vfcmt.class); - vfcmtId = newVfcmt.getUuid(); - // submit - generate and save type2 blueprint artifact - Report.log(Status.INFO, "Going to Submit the composition with vfcmtId="+vfcmtId+", serviceUuid="+serviceUuid+", vfiName="+vfiName+", TYPE2="+bpType2); - res = DcaeRestClient.submitComposition(vfcmtId, serviceUuid, vfiName, bpType2); - assertBlueprintSuccessResponse(res); - res = DcaeRestClient.getResourceDetails(vfcmtId); - newVfcmt = gson.fromJson(res.getResponse(), Vfcmt.class); - Report.log(Status.INFO, "Checking lifecycle state of vfcmt after checkout and second blueprint submission. State = {}", newVfcmt.getLifecycleState()); - assertThat(newVfcmt.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.CERTIFIED.name()); - Report.log(Status.INFO, "Checking version of vfcmt after checkout and second blueprint submission. Version = {}", newVfcmt.getVersion()); - assertThat(newVfcmt.getVersion()).isEqualTo("2.0"); - assertBlueprintsExistOnVfiAfterUpload(expectedBpDetails, serviceUuid, vfiName); - } - - - @Test - public void updateBlueprintTest() throws Exception { - Report.log(Status.INFO, "updateBlueprintTest start"); - String randomSuffix = WordUtils.capitalize(RandomStringUtils.randomAlphanumeric(4).toLowerCase()); - Vfcmt newVfcmt = createVfcmt(randomSuffix); - - // create a service in sdc - Service newService = createServiceWithVFiAsSdcDesigner(); - - String serviceUuid = newService.getUuid(); - String vfiName = newService.getResources().get(0).getResourceInstanceName(); - String vfcmtId = newVfcmt.getUuid(); - - // attach VFCMT to vfi - RestResponse res = DcaeRestClient.attachVfiRef(vfcmtId, serviceUuid, vfiName); - assertThat(res.getStatusCode()).isEqualTo(200); - - generateAndSaveCdump(vfcmtId); - - String normalizedVfcmtName = NORMALIZED_VFCMT_NAME + randomSuffix; - String bpType1 = "bpType 1"; - ImmutablePair expectedBpDetails = buildBlueprintDetails(bpType1, normalizedVfcmtName); - - // submit - generate and save type1 blueprint artifact - Report.log(Status.INFO, "Going to Submit the composition with vfcmtId="+vfcmtId+", serviceUuid="+serviceUuid+", vfiName="+vfiName+", bpType1="+bpType1); - res = DcaeRestClient.submitComposition(vfcmtId, serviceUuid, vfiName, bpType1); - assertBlueprintSuccessResponse(res); - // assert initial version exists - assertBlueprintExistsOnVfi(expectedBpDetails, serviceUuid, vfiName, CREATE_BLUEPRINT_DESCRIPTION); - - // submit - regenerate and save type1 blueprint artifact - Report.log(Status.INFO, "Going to Submit the composition with vfcmtId="+vfcmtId+", serviceUuid="+serviceUuid+", vfiName="+vfiName+", bpType1="+bpType1); - res = DcaeRestClient.submitComposition(vfcmtId, serviceUuid, vfiName, bpType1); - assertBlueprintSuccessResponse(res); - // assert blueprint updated - assertBlueprintExistsOnVfi(expectedBpDetails, serviceUuid, vfiName, UPDATE_BLUEPRINT_DESCRIPTION); - - } - - - private void assertBlueprintSuccessResponse(RestResponse response){ - assertThat(response.getStatusCode()).isEqualTo(200); - assertThat(ResponseParser.getValueFromJsonResponse(response.getResponse(), "successResponse")).isNotNull(); - } - - private void assertBlueprintsExistOnVfiAfterUpload(List> expectedBpDetails, String serviceId, String vfiName) throws IOException{ - List vfiArtifact = fetchVfiArtifacts(serviceId, vfiName); - List> vfiArtifactDetails = vfiArtifact.stream() - .map(a -> new ImmutablePair<>(a.getArtifactLabel(), a.getArtifactName())) - .collect(Collectors.toList()); - for(ImmutablePair bp : expectedBpDetails){ - assertThat(vfiArtifactDetails).contains(bp); - } - } - - private void assertBlueprintExistsOnVfi(ImmutablePair expectedBpDetails, String serviceId, String vfiName, String description) throws IOException{ - List vfiArtifact = fetchVfiArtifacts(serviceId, vfiName); - Predicate artifactPredicate = p -> expectedBpDetails.getLeft().equals(p.getArtifactLabel()) && expectedBpDetails.getRight().equals(p.getArtifactName()) && description.equals(p.getArtifactDescription()); - Artifact artifact = vfiArtifact.stream() - .filter(artifactPredicate) - .findAny() - .orElse(null); - assertThat(artifact).isNotNull(); - } - - - private List fetchVfiArtifacts(String serviceId, String vfiName) throws IOException { - Report.log(Status.INFO, "fetchVfiArtifacts start"); - RestResponse serviceRes = DcaeRestClient.getServicesInstance(serviceId); - Report.log(Status.INFO, "fetchVfiArtifacts response=%s", serviceRes); - Service service = gson.fromJson(serviceRes.getResponse(), Service.class); - Resource vfi = service.getResources().stream() - .filter(p -> p.getResourceInstanceName().equals(vfiName)) - .findAny() - .orElse(null); - assertThat(vfi).isNotNull(); - return vfi.getArtifacts(); - } - - private ImmutablePair buildBlueprintDetails(String bpType, String normalizedVfcmtName) { - return new ImmutablePair<>("blueprint"+bpType.toLowerCase().replaceAll(" ", ""),bpType.replaceAll(" ", "-")+"."+normalizedVfcmtName+"."+EVENT_PROC_BP_YAML); - } - - - private Vfcmt createVfcmt(String randomSuffix) throws IOException { - String newName = VFCMT_NAME + randomSuffix; - Report.log(Status.DEBUG, "createVfcmt start. VFCMT Name="+newName); - RestResponse res = DcaeRestClient.createVfcmt(newName,"description"); - Report.log(Status.DEBUG, "Create VFCMT response=%s", res); - assertThat(res.getStatusCode()).isEqualTo(200); - return gson.fromJson(res.getResponse(), Vfcmt.class); - } - - private void generateAndSaveCdump(String vfcmtId) throws ParseException, IOException { - Report.log(Status.DEBUG, "generateAndSaveCdump start"); - RestResponse res = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(0); - assertThat(res.getStatusCode()).isEqualTo(200); - JsonObject cdump = DcaeRestClient.generateCdumpInput(vfcmtId); - Report.log(Status.DEBUG, "Generated cdump="+cdump); - cdump.add("nodes", DcaeUtil.parseNodesFromDcaeModelAndAssignUiNid(res.getResponse())); - Report.log(Status.DEBUG, "save composition - generate and save composition.yml artifact"); - res = DcaeRestClient.saveComposition(vfcmtId, DcaeRestClient.getDefaultUser().getUserId(), cdump.toString()); - Report.log(Status.DEBUG, "Save composition result="+res); - assertThat(res.getStatusCode()).isEqualTo(200); - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java deleted file mode 100644 index 46a62c0..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; - -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.List; -import java.util.stream.Collectors; - -import org.assertj.core.api.SoftAssertions; -import org.onap.sdc.dcae.composition.model.Model; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.entities.composition.rightMenu.element.Item; -import com.att.ecomp.dcae.ci.entities.composition.rightMenu.elements.Element; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; - -public class CompositionElementsControllerTests extends DcaeRestBaseTest { - - JsonParser parser = new JsonParser(); - - @Test - public void test_getAllElements() throws IOException{ - Report.log(Status.INFO, "test_getAllElements start"); - RestResponse response = DcaeRestClient.getElements(); - Report.log(Status.INFO, "getElements response=%s", response); - JsonElement getElementJsonResponse = getElementsJson(response); - Type listType = new TypeToken>(){}.getType(); - List responseData = gson.fromJson(getElementJsonResponse, listType); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat(getElementJsonResponse.toString()).isNotEmpty(); - softly.assertThat(responseData).extracting("itemId") - .containsExactlyInAnyOrder("Policy","Utility","Microservice","Database","Collector","Analytics","Source"); - }); - } - - - @DataProvider(name="item") - public static Object[][] allElementsItems() throws IOException{ - RestResponse response = DcaeRestClient.getElements(); - JsonElement getElementJsonResponse = getElementsJson(response); - Type listType = new TypeToken>(){}.getType(); - List responseData = gson.fromJson(getElementJsonResponse, listType); - return responseData - .stream() - .map(x -> new Object[]{ x.getItemId() } ) - .collect(Collectors.toList()) - .toArray(new Object[responseData.size()][1]); - } - - @Test(dataProvider ="item") - public void test_getAllElementsByItemId(String itemName) throws IOException{ - Report.log(Status.INFO, "test_getAllElementsByItemId start"); - RestResponse response = DcaeRestClient.getItem(itemName); - Report.log(Status.INFO, "getItem response=%s", response); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - }); - } - - @Test - public void test_getModelData() throws IOException{ - Report.log(Status.INFO, "test_getModelData start"); - RestResponse responseGetElements = DcaeRestClient.getElements(); - JsonElement obj = getElementsJson(responseGetElements); - String elementItemName = getElementItemName(obj); - - RestResponse responseElementsItem = DcaeRestClient.getItem(elementItemName); - JsonElement elementsById = parser.parse(responseElementsItem.getResponse()); - JsonElement itemData = elementsById.getAsJsonObject().get("data").getAsJsonObject().get("element").getAsJsonObject().get("items"); - - String elemId = getElementItemID(itemData); - Report.log(Status.INFO, "test_getModelData start"); - - RestResponse response = DcaeRestClient.getItemModel(elemId); - Report.log(Status.INFO, "getItemModel response=%s", response); - JsonElement responseJson = parser.parse(response.getResponse()); - JsonElement itemModelData = responseJson.getAsJsonObject().get("data").getAsJsonObject().get("model"); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat(itemModelData.toString()).isNotEmpty(); - }); - } - - @Test - public void test_getTypeData() throws IOException{ - Report.log(Status.INFO, "test_getTypeData start"); - RestResponse responseGetElements = DcaeRestClient.getElements(); - JsonElement obj = getElementsJson(responseGetElements); - String elementItemName = getElementItemName(obj); - - RestResponse responseElementsItem = DcaeRestClient.getItem(elementItemName); - JsonElement elementsById = parser.parse(responseElementsItem.getResponse()); - JsonElement itemData = elementsById.getAsJsonObject().get("data").getAsJsonObject().get("element").getAsJsonObject().get("items"); - - String elemId = getElementItemID(itemData); - RestResponse responseModel = DcaeRestClient.getItemModel(elemId); - JsonElement jsonRes = parser.parse(responseModel.getResponse()); - JsonElement jsonModel = jsonRes.getAsJsonObject().get("data").getAsJsonObject().get("model").getAsJsonObject(); - Model model = gson.fromJson(jsonModel, Model.class); - List nodesDataTypes = model.getNodes().stream() - .map(y -> y.getType()) - .collect(Collectors.toList()); - - nodesDataTypes.forEach(z -> Report.log(Status.INFO, "All types inside model: " + z)); - String nodeType = nodesDataTypes.get(0); - RestResponse response = DcaeRestClient.getItemType(elemId, nodeType); - JsonElement elementsById2 = parser.parse(response.getResponse()); - JsonElement data2 = elementsById2.getAsJsonObject().get("data").getAsJsonObject().get("type").getAsJsonObject(); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat(data2.toString()).isNotEmpty(); - }); - } - - /**************** nagative ***************/ - @Test - public void test_getAllElementsByNonExistItemId() throws IOException{ - Report.log(Status.INFO, "test_getAllElementsByNonExistItemId start"); - RestResponse response = DcaeRestClient.getItem("notExist"); - JsonElement elementsById = parser.parse(response.getResponse()); - JsonElement exception = elementsById.getAsJsonObject().get("error").getAsJsonObject().get("exception"); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat(exception.toString()).isNotEmpty(); - }); - } - - @Test - public void test_getErrorNonExistingModelData() throws IOException{ - Report.log(Status.INFO, "test_getErrorNonExistingModelData start"); - RestResponse response = DcaeRestClient.getItemModel("notExist"); - JsonElement elementsById = parser.parse(response.getResponse()); - JsonElement exception = elementsById.getAsJsonObject().get("error"); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(500); - softly.assertThat(exception.toString()).isNotEmpty(); - }); - } - - @Test - public void test_getErrorNonExistingItemType() throws IOException{ - Report.log(Status.INFO, "test_getErrorNonExistingItemType start"); - RestResponse response = DcaeRestClient.getItemType("notExistId","nonType"); - JsonElement elementsById = parser.parse(response.getResponse()); - JsonElement exception = elementsById.getAsJsonObject().get("error"); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(500); - softly.assertThat(exception.toString()).isNotEmpty(); - }); - } - - /******************** private ********************/ - private static JsonElement getElementsJson(RestResponse response) { - JsonParser parser = new JsonParser(); - JsonElement element = parser.parse(response.getResponse()); - JsonElement obj = element.getAsJsonObject().get("data").getAsJsonObject().get("elements"); - return obj; - } - - private String getElementItemName(JsonElement obj) { - Type listType = new TypeToken>(){}.getType(); - List fromJson = gson.fromJson(obj, listType); - List collect = fromJson.stream().filter(x->x.getName().equals("Collector")).collect(Collectors.toList()); - Element element = collect.get(0); - String elementItemName = element.getName(); - return elementItemName; - } - - private String getElementItemID(JsonElement data) { - Type listType = new TypeToken>(){}.getType(); - List elementsItemFoi = gson.fromJson(data, listType); - Report.log(Status.INFO, "getElementItemID for FOI collector"); - List foiItemData = elementsItemFoi.stream().filter(x->x.getName().equals("FOI")).collect(Collectors.toList()); - if(foiItemData!=null && foiItemData.size()>0){ - Item item = foiItemData.get(0); - String elemId = item.getItemId(); - return elemId; - }else{ - Report.log(Status.ERROR, "getElementItemID for FOI collector failed. Does the CI environment has FOI Collector component in it??"); - return null; - } - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java deleted file mode 100644 index 52fae05..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; - -import static org.assertj.core.api.Assertions.*; - -import org.onap.sdc.dcae.composition.model.ModelDcae; -import org.testng.annotations.*; - -import java.io.IOException; - -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.openecomp.d2.ci.datatypes.http.RestResponse; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeTestConstants; -import com.att.ecomp.dcae.ci.utilities.DcaeUtil; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - - -public class CompositionMicroServicesApiTests extends DcaeRestBaseTest { - - @Test - public void getAllElementsTest() throws IOException, ParseException{ - Report.log(Status.INFO, "getAllElementsTest start"); - RestResponse services = DcaeRestClient.getElements(); - Report.log(Status.INFO, "getAllElementsTest response=%s", services); - assertThat(services.getStatusCode().intValue()).isEqualTo(200); -// System.out.println(services); - String response = services.getResponse(); - JSONParser parser = new JSONParser(); - JSONObject o = (JSONObject) parser.parse(response); - JSONObject ele = (JSONObject) o.get("data"); - String arrString = ele.get(("elements")).toString(); -// System.out.println(arrString); - assertThat(arrString) - .as("Check that elements not empty") - .isNotEmpty(); - } - - @Test - public void getMsElementsTest() throws IOException, ParseException{ - Report.log(Status.INFO, "getMsElementsTest start"); - RestResponse services = DcaeUtil.SdcElementsModelType.getMsElements(); - Report.log(Status.INFO, "getMsElementsTest response=%s", services); - assertThat(services.getStatusCode().intValue()).isEqualTo(200); -// System.out.println(services); - String response = services.getResponse(); - JSONParser parser = new JSONParser(); - JSONObject o = (JSONObject) parser.parse(response); - JSONObject ele = (JSONObject) o.get("data"); - String arrString = ele.get(("element")).toString(); -// System.out.println(arrString); - assertThat(arrString) - .as("Check that elements not empty") - .isNotEmpty(); - } - - @Test - public void getItemModelTest() throws IOException{ - Report.log(Status.INFO, "getItemModelTest start"); - RestResponse itemModelRes = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(2); - Report.log(Status.INFO, "getItemModelTest response=%s", itemModelRes); - assertThat(itemModelRes.getStatusCode().intValue()).isEqualTo(200); - - String response = itemModelRes.getResponse(); - JSONObject object = (JSONObject) JSONValue.parse(response); - String errorMsg = object.get("error").toString(); - assertThat(errorMsg).isEqualTo(DcaeTestConstants.Composition.EMPTY_OBJECT); - } - - @Test - public void getItemTypeTest() throws IOException{ - Report.log(Status.INFO, "getItemModelTest start"); - RestResponse itemModelRes = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(2); - Report.log(Status.INFO, "itemModelRes response=%s", itemModelRes); - String response = itemModelRes.getResponse(); - - String uuid = DcaeUtil.SdcElementsModelType.getItemUuid(2); - - ModelDcae model = gson.fromJson(response, ModelDcae.class); - Report.log(Status.INFO, "model "+model); - String type = model.getData().getModel().getNodes().get(0).getType(); - Report.log(Status.INFO, "type "+type); - - RestResponse services = DcaeRestClient.getItemType(uuid, type); - assertThat(services.getStatusCode().intValue()).isEqualTo(200); - } - -// @Test -// public void saveCompositionCheckoutConflictTest() throws IOException{ -// // pull checkout VFCMT -// Vfcmt checkoutVFCMT = DcaeUtil.CatalogReources.checkoutVFCMT(); -// // call API -// RestResponse saveComposition = DcaeRestClient.saveComposition(checkoutVFCMT.getUuid(), checkoutVFCMT.getLastUpdaterUserId()); -// System.out.println(saveComposition); -// assertThat(saveComposition.getStatusCode()) -// .as("status 500") -// .isEqualTo(500); -// } -// -// @Test -// public void saveCompositionTest() throws IOException{ -// // Create new VFCMT -// Resource createNewVfcmtObject = DcaeUtil.CatalogReources.createNewVfcmtObject(); -// // Call SDC API to create the new VFCMT -// RestResponse resNewVfcmt = DcaeRestClient.createVfcmt(createNewVfcmtObject.getResourceInstanceName(),createNewVfcmtObject.getDescription()); -// -// Vfcmt newVfcmt = gson.fromJson(resNewVfcmt.getResponse(), Vfcmt.class); -// -// // call api -// RestResponse saveComposition = DcaeRestClient.saveComposition(newVfcmt.getUuid(), newVfcmt.getLastUpdaterUserId()); -// System.out.println(saveComposition); -// String response = saveComposition.getResponse(); -// -// String msg = "Artifact created"; -// int errorIndex = response.indexOf(msg); -// assertThat(errorIndex) -// .as("Conflict of checkout") -// .isGreaterThan(-1); -// } - -// @Test -// public void submitCompositionTest() throws IOException{ -// // pull checkout VFCMT -// Vfcmt checkoutVFCMT = DcaeUtil.CatalogReources.checkoutVFCMT(); -// String componentId = checkoutVFCMT.getUuid(); -// /* TODO: create new service (requires SDC api support) instead of using a random one that already exists */ -// ThinService oneService = DcaeUtil.Services.getOneService(componentId,0); -// Resource oneVfInstance = DcaeUtil.Services.getOneVfInstance(oneService, 0); -// RestResponse submitCompositionRes = DcaeRestClient -// .submitComposition(componentId, oneService.getUuid(), oneVfInstance.getResourceInstanceName()); -// String response = submitCompositionRes.getResponse(); -// int errorIndex = response.indexOf(DcaeTestConstants.Sdc.State.CONFLICT); -// assertThat("Conflict of checkout",errorIndex, greaterThan(-1)); -// } - -//TODO Block need to get shai service -// @Test -// public void submitCompositionTest() throws IOException{ -// String componentId = DcaeUtil.CatalogReources.getComponentID(202); -// ThinService oneService = DcaeUtil.Services.getOneService(0); -// Resource oneVfInstance = DcaeUtil.Services.getOneVfInstance(oneService, 0); -// RestResponse submitCompositionRes = DcaeRestClient -// .submitComposition(componentId, oneService.getUuid(), oneVfInstance.getResourceInstanceName()); -// String response = submitCompositionRes.getResponse(); -// JSONObject object = (JSONObject) JSONValue.parse(response); -// assertThat("Success response is not null", object.get("successResponse"), is(notNullValue())); -// } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/GetCompositionControllerTests.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/GetCompositionControllerTests.java deleted file mode 100644 index 3493536..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/GetCompositionControllerTests.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.text.WordUtils; -import org.assertj.core.api.SoftAssertions; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import org.onap.sdc.dcae.composition.services.Service; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeUtil; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class GetCompositionControllerTests extends DcaeRestBaseTest { - - private static final String VFCMT_NAME = "teSt.__.monitoring---TempLATE."; - - @Test - public void test_getComposition() throws Exception{ - Report.log(Status.INFO, "test_getComposition start"); - Vfcmt vfcmtWithArtifactUuid = createServiceAndVfiAndVfcmtAndAttach(); - String uuid = vfcmtWithArtifactUuid.getUuid(); - String lastUpdaterUserId = vfcmtWithArtifactUuid.getLastUpdaterUserId(); - Report.log(Status.INFO, "the created VFCMT uuid is:"+uuid+", going to save composition now"); - saveComposition(uuid, lastUpdaterUserId); - Report.log(Status.INFO, "Composition saved"); - - ExtentTestActions.log(Status.INFO, "Get Composition - execute"); - RestResponse response = DcaeRestClient.getComposition(uuid); - JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat(resData.get("successResponse").toString()).isNotEmpty(); - }); - } - - @Test - public void test_getCompositionNoArtifact() throws Exception{ - ExtentTestActions.log(Status.INFO, "test_getCompositionNoArtifact Get Composition - create vfcmt"); - - Vfcmt newVfcmt = createNewVfcmt(); - String uuid = newVfcmt.getUuid(); - - ExtentTestActions.log(Status.INFO, "Get Composition - execute"); - RestResponse response = DcaeRestClient.getComposition(uuid); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(204); - }); - } - - private void saveComposition(String uuid, String lastUpdaterUserId) throws Exception, IOException { - //generate cdump - String cdump = generateAndSaveCdump(uuid); - // save composition.yml - DcaeRestClient.saveComposition(uuid, lastUpdaterUserId, cdump); - } - - private Vfcmt createServiceAndVfiAndVfcmtAndAttach() throws Exception{ - Vfcmt newVfcmt = createNewVfcmt(); - - // create a service in sdc - Service newService = createServiceWithVFiAsSdcDesigner(); - - String serviceUuid = newService.getUuid(); - String vfiName = newService.getResources().get(0).getResourceInstanceName(); - String vfcmtId = newVfcmt.getUuid(); - - // attach VFCMT to vfi - RestResponse res = DcaeRestClient.attachVfiRef(vfcmtId, serviceUuid, vfiName); - - return newVfcmt; - } - - private Vfcmt createNewVfcmt() throws Exception { - String randomSuffix = WordUtils.capitalize(RandomStringUtils.randomAlphanumeric(4).toLowerCase()); - Vfcmt newVfcmt = createVfcmtInstance(randomSuffix); - return newVfcmt; - } - - private Vfcmt createVfcmtInstance(String randomSuffix) throws Exception{ - String newName = VFCMT_NAME + randomSuffix; - RestResponse res = DcaeRestClient.createVfcmt(newName,"description"); - assertThat(res.getStatusCode()).isEqualTo(200); - return gson.fromJson(res.getResponse(), Vfcmt.class); - } - private String generateAndSaveCdump(String vfcmtId) throws Exception{ - JsonArray snmpModelItemFromSdc = DcaeUtil.SdcElementsModelType.getSNMPModelItemFromSdc(); - JsonObject cdump = DcaeRestClient.generateCdumpInput(vfcmtId); - cdump.add("nodes", snmpModelItemFromSdc); - return cdump.toString(); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java deleted file mode 100644 index aaeebdc..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.composition; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.aventstack.extentreports.Status; -import com.google.gson.reflect.TypeToken; -import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; -import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; -import org.onap.sdc.dcae.composition.restmodels.MonitoringComponent; -import org.onap.sdc.dcae.composition.restmodels.sdc.ExternalReferencesMap; -import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; -import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed; -import org.onap.sdc.dcae.composition.services.Service; -import org.onap.sdc.dcae.composition.util.DcaeBeConstants; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.lang.reflect.Type; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SaveAndSubmitCompositionFullFlowTest extends DcaeRestBaseTest { - - private Resource baseTemplate = null; - - - @BeforeClass - public void setup() { - try { - ExtentTestActions.log(Status.INFO, "running before class - find a base template"); - Resource[] resources = gson.fromJson(DcaeRestClient.getAllMonitoringTemplatesVfcmts().getResponse(), Resource[].class); - if (resources.length > 0){ - baseTemplate = resources[0]; - } - } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); - } - } - - - @Test - public void saveAndSubmitCompositionSuccessTest() throws Exception { - - CreateVFCMTRequest request = new CreateVFCMTRequest(); - // If you crashed here (below) it is because your environment has no Base Monitoring Templates - request.setTemplateUuid(baseTemplate.getUuid()); - Service service = createServiceWithVFiAsSdcDesigner(); - request.setVfiName(service.getResources().get(0).getResourceInstanceName()); - request.setServiceUuid(service.getUuid()); - DcaeRestClient.fillCreateMcRequestMandatoryFields(request); - - RestResponse response = DcaeRestClient.createMc(gson.toJson(request)); - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - - CreateMcResponse mcResponse = gson.fromJson(response.getResponse(), CreateMcResponse.class); - ExtentTestActions.log(Status.INFO, "Vfcmt created successfully. About to update composition"); - String initialUuid = mcResponse.getVfcmt().getUuid(); - response = DcaeRestClient.saveComposition(request.getServiceUuid(), request.getVfiName(), initialUuid, gson.toJson(mcResponse.getCdump())); - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - - ResourceDetailed mc = gson.fromJson(response.getResponse(), ResourceDetailed.class); - // the save action should check the mc out then in - promoting the version - assertThat(mc.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name()); - assertThat(mc.getVersion()).isEqualTo("0.2"); - - ExtentTestActions.log(Status.INFO, "About to submit the composition"); - response = DcaeRestClient.submitComposition(request.getServiceUuid(), request.getVfiName(), mc.getUuid()); - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - // the submit action should certify the mc. - ExtentTestActions.log(Status.INFO, "Save new composition version after submit"); - response = DcaeRestClient.saveComposition(request.getServiceUuid(), request.getVfiName(), initialUuid, gson.toJson(mcResponse.getCdump())); - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - // the save action should promote the mc version to 1.1 and create a new reference to it - both references should be kept at this point - mc = gson.fromJson(response.getResponse(), ResourceDetailed.class); - assertThat(mc.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name()); - assertThat(mc.getVersion()).isEqualTo("1.1"); - - response = DcaeRestClient.getServiceExternalReferences(service.getUuid(), service.getVersion()); - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - ExtentTestActions.log(Status.INFO, "Verify service vfi has references to both mc versions"); - Type typeToken = new TypeToken>>(){}.getType(); - Map> monitoringComponents = gson.fromJson(response.getResponse(), typeToken); - assertThat(monitoringComponents.get("monitoringComponents").size()).isEqualTo(2); - ExtentTestActions.log(Status.INFO, "About to re-submit the composition"); - response = DcaeRestClient.submitComposition(request.getServiceUuid(), request.getVfiName(), mc.getUuid()); - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - // a successful submission of the new version should result in the deletion of the previous reference - response = DcaeRestClient.getServiceExternalReferences(service.getUuid(), service.getVersion()); - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - monitoringComponents = gson.fromJson(response.getResponse(), typeToken); - List mcList = monitoringComponents.get("monitoringComponents"); - assertThat(mcList.size()).isEqualTo(1); - assertThat(mcList.get(0).getUuid()).isEqualTo(mc.getUuid()); - - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java deleted file mode 100644 index 933fc38..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.lifeCycle; - -import static org.assertj.core.api.Assertions.fail; - -import com.att.ecomp.dcae.ci.utilities.DcaeEntityClient; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; - -public class ArrangeHelper { - - private DcaeEntityClient client; - - public ArrangeHelper(DcaeEntityClient client) { - this.client = client; - } - - /** - * Tries to arrange checkedin vfcmt. - * If unable to do so, fails test with arrange error message - * @param userId - lastUpdater of the returned vfcmt - * @return checkedin vfcmt - */ - public Vfcmt getCheckedinVfcmt(String userId) { - Vfcmt vfcmt = null; - try { - vfcmt = client.createCheckedinVfcmt(userId); - } catch (Exception err) { - fail("could not arrange test: ", err); - } - return vfcmt; - } - - /** - * Tries to arrange checkedin vfcmt. - * If unable to do so, fails test with arrange error message - * @return checkedin vfcmt - */ - public Vfcmt getCheckedinVfcmt() { - String userId = DcaeRestClient.getDefaultUser().getUserId(); - return getCheckedinVfcmt(userId); - } - - /** - * Tries to arrange checkedout vfcmt. - * If unable to do so, fails test with arrange error message - * @param userId - lastUpdater of the returned vfcmt - * @return checkedout vfcmt - */ - public Vfcmt getCheckedoutVfcmt(String userId) { - Vfcmt vfcmt = null; - try { - vfcmt = client.createCheckedoutVfcmt(userId); - } catch (Exception err) { - fail("could not arrange test: ", err); - } - return vfcmt; - } - - /** - * Tries to arrange checkedout vfcmt. - * If unable to do so, fails test with arrange error message - * @return checkedout vfcmt - */ - public Vfcmt getCheckedoutVfcmt() { - String userId = DcaeRestClient.getDefaultUser().getUserId(); - return getCheckedoutVfcmt(userId); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCertify.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCertify.java deleted file mode 100644 index 4081b20..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCertify.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.lifeCycle; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.aventstack.extentreports.Status; -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.testng.annotations.Test; - -public class PutCertify extends DcaeRestBaseTest { - - private ArrangeHelper arrange = new ArrangeHelper(client); - - /* Positive */ - - @Test - public void certifyVfcmt_success() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedinVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Calling certify vfcmt with lastUpdater as user (designer role)"); - RestResponse response = DcaeRestClient.certifyVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - // assert - Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).isEqualTo(200); - softly.assertThat(vfcmtAfterCheckin.getLifecycleState()).isEqualTo("CERTIFIED"); - }); - } - - - /* Negative */ - - @Test - public void notReadyForCertification_statusCode500() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Calling certify on a checked out vfcmt"); - RestResponse response = DcaeRestClient.certifyVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - // assert - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).isEqualTo(500); - }); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckin.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckin.java deleted file mode 100644 index 45f71e0..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckin.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.lifeCycle; - -import java.io.IOException; -import java.util.UUID; - -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.*; -import static org.assertj.core.api.Assertions.*; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; - -public class PutCheckin extends DcaeRestBaseTest{ - - private ArrangeHelper arrange = new ArrangeHelper(client); - - /* Positive */ - - @Test - public void checkedoutVfcmt_success() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt with it's lastUpdater user"); - RestResponse response = checkinVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - // assert - Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).isEqualTo(200); - softly.assertThat(vfcmtAfterCheckin.getLifecycleState()).contains("CHECKIN"); - }); - } - - /* Negative */ - - @Test - public void alreadyCheckedinVfcmt_statusCode409() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedinVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt AGAIN with it's lastUpdater user"); - RestResponse response = checkinVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - // assert - assertThat(response.getStatusCode()).isEqualTo(409); - } - - @Test - public void invalidVfcmtUuid_statusCode400() throws Exception { - // arrange - String userId = DcaeRestClient.getDefaultUser().getUserId(); - // act - ExtentTestActions.log(Status.INFO, "Checkin with an invalid-uuid as vfcmt-uuid"); - RestResponse response = checkinVfcmt("invalid-vfcmt-uuid", userId); - // assert - assertThat(response.getStatusCode()).isEqualTo(400); - } - - @Test - public void nonExistingUuid_statusCode409() throws Exception { - // arrange - String uuid = UUID.randomUUID().toString(); - String userId = DcaeRestClient.getDefaultUser().getUserId(); - // act - ExtentTestActions.log(Status.INFO, "Checkin with a non-existing vfcmt-uuid"); - RestResponse response = checkinVfcmt(uuid, userId); - // assert - assertThat(response.getStatusCode()).isEqualTo(409); - } - - @Test - public void nonExistingUser_statusCode403() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Checkin with a non-existing user"); - RestResponse response = checkinVfcmt(vfcmt.getUuid(), "anonymus"); - // assert - assertThat(response.getStatusCode()).isEqualTo(403); - } - - @Test - public void notLastUser_statusCode403() throws Exception { - // arrange - String user1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId(); - String user2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId(); - Vfcmt vfcmt = arrange.getCheckedoutVfcmt(user1); - // act - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt with different user: " + user2); - RestResponse response = checkinVfcmt(vfcmt.getUuid(), user2); - // assert - assertThat(response.getStatusCode()).isEqualTo(403); - } - - @Test - public void invalidAssetType_statusCode400() throws Exception { - // arrange - String assetType = "kengero"; - String userId = DcaeRestClient.getDefaultUser().getUserId(); - Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt with invalid asset-type"); - RestResponse response = checkinGeneral(assetType, userId, vfcmt); - // assert - assertThat(response.getStatusCode()).isEqualTo(400); - } - - - /* Private Methods */ - - /** - * Performs checkin on a general vfcmt/service, use this in test action - * @param assetType - * @param userId - * @param vfcmt - * @return - * @throws IOException - */ - private RestResponse checkinGeneral(String assetType, String userId, Vfcmt vfcmt) throws IOException { - RestResponse response = DcaeRestClient.checkinGeneral(assetType, vfcmt.getUuid(), userId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - return response; - } - - /** - * Performs checkin on vfcmt, use this in test action - * @param vfcmtUuid - * @param userId - * @return - * @throws IOException - */ - private RestResponse checkinVfcmt(String vfcmtUuid, String userId) throws IOException { - RestResponse response = DcaeRestClient.checkinVfcmt(vfcmtUuid, userId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - return response; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckout.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckout.java deleted file mode 100644 index 5696ee3..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/lifeCycle/PutCheckout.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.lifeCycle; - -import java.io.IOException; -import java.util.UUID; - -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.*; -import static org.assertj.core.api.Assertions.*; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; - -public class PutCheckout extends DcaeRestBaseTest{ - - private ArrangeHelper arrange = new ArrangeHelper(client); - - /* Positive */ - - @Test - public void checkedinVfcmt_success() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedinVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Checkout the vfcmt with it's lastUpdater user"); - RestResponse response = checkoutVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - // assert - Vfcmt vfcmtAfterCheckout = gson.fromJson(response.getResponse(), Vfcmt.class); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).isEqualTo(200); - softly.assertThat(vfcmtAfterCheckout.getLifecycleState()).contains("CHECKOUT"); - }); - } - - @Test - public void notLastUser_success() throws Exception { - // arrange - String user1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId(); - String user2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId(); - Vfcmt vfcmt = arrange.getCheckedinVfcmt(user1); - // act - ExtentTestActions.log(Status.INFO, "Checkout the vfcmt with different user: " + user2); - RestResponse response = checkoutVfcmt(vfcmt.getUuid(), user2); - // assert - Vfcmt vfcmtAfterCheckout = gson.fromJson(response.getResponse(), Vfcmt.class); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).isEqualTo(200); - softly.assertThat(vfcmtAfterCheckout.getLifecycleState()).contains("CHECKOUT"); - }); - } - - - /* Negative */ - - @Test - public void alreadyCheckedoutVfcmt_statusCode403() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Checkout the vfcmt with it's lastUpdater user"); - RestResponse response = checkoutVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - // assert - assertThat(response.getStatusCode()).isEqualTo(403); - } - - @Test - public void invalidVfcmtUuid_statusCode400() throws Exception { - // arrange - String userId = DcaeRestClient.getDefaultUser().getUserId(); - // act - ExtentTestActions.log(Status.INFO, "Checkout with an invalid-uuid as vfcmt-uuid"); - RestResponse response = checkoutVfcmt("invalid-vfcmt-uuid", userId); - // assert - assertThat(response.getStatusCode()).isEqualTo(400); - } - - @Test - public void nonExistingUuid_statusCode409() throws Exception { - // arrange - String uuid = UUID.randomUUID().toString(); - String userId = DcaeRestClient.getDefaultUser().getUserId(); - // act - ExtentTestActions.log(Status.INFO, "Checkin with a non-existing vfcmt-uuid"); - RestResponse response = checkoutVfcmt(uuid, userId); - // assert - assertThat(response.getStatusCode()).isEqualTo(409); - } - - @Test - public void nonExistingUser_statusCode403() throws Exception { - // arrange - Vfcmt vfcmt = arrange.getCheckedinVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Checkin with a non-existing user"); - RestResponse response = checkoutVfcmt(vfcmt.getUuid(), "anonymus"); - // assert - assertThat(response.getStatusCode()).isEqualTo(403); - } - - @Test - public void invalidAssetType_statusCode400() throws Exception { - // arrange - String assetType = "kengero"; - String userId = DcaeRestClient.getDefaultUser().getUserId(); - Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); - // act - ExtentTestActions.log(Status.INFO, "Checkout the vfcmt with invalid asset-type"); - RestResponse response = checkoutGeneral(assetType, userId, vfcmt); - // assert - assertThat(response.getStatusCode()).isEqualTo(400); - } - - - /* Private Methods */ - - /** - * Performs checkout on a general vfcmt/service and logs the response - * @param assetType - * @param userId - * @param vfcmt - * @return - * @throws IOException - */ - private RestResponse checkoutGeneral(String assetType, String userId, Vfcmt vfcmt) throws IOException { - RestResponse response = DcaeRestClient.checkinGeneral(assetType, vfcmt.getUuid(), userId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - return response; - } - - /** - * Performs checkout on vfcmt and logs the response - * @param vfcmtUuid - * @param userId - * @return - * @throws IOException - */ - private RestResponse checkoutVfcmt(String vfcmtUuid, String userId) throws IOException { - RestResponse response = DcaeRestClient.checkoutVfcmt(vfcmtUuid, userId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - return response; - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java deleted file mode 100644 index 358f45a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.ruleEditor; - -import java.lang.reflect.Field; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypeDefinitionUI; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypesByVersionUI; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; - -public class GetDefinitionTest extends DcaeRestBaseTest { - - @DataProvider(name = "EventTypes") - public static Object[][] getVesVersions() { - Gson gson = new GsonBuilder().create(); - try { - Report.log(Status.INFO, "Requesting VES event types"); - RestResponse response = DcaeRestClient.getVesEventTypes(); - Report.logDebug("Response", response); - if (response.getStatusCode() != 200) { - throw new Exception(response.toString()); - } - EventTypesByVersionUI[] eventsByVersionList = gson.fromJson(response.getResponse(), EventTypesByVersionUI[].class); - - return Arrays.stream(eventsByVersionList) - .flatMap(version -> version.getEventTypes().stream() - .map( event -> new Object[] {version.getVersion(), event} ) - ).toArray(Object[][]::new); - - } catch (Exception err) { - Report.log(Status.ERROR, "Unable to get ves event types\nException: %s", err.toString()); - return new Object[][] {}; - } - } - - - /* Positive */ - - @Test(dataProvider = "EventTypes") - public void testParameterized(String version, String eventType) throws Exception { - // arrange - - Report.log(Status.INFO, "testParameterized. version="+version+", eventType="+eventType); - - Gson gsonStrict = new GsonBuilder() - .registerTypeAdapter(EventTypeDefinitionUI.class, new StrictJsonDeserializer()) - .create(); - - // act - RestResponse response = DcaeRestClient.getVesDataTypes(version, eventType); - Report.logDebug("Response", response); - // assert - - EventTypeDefinitionUI[] resBody = gson.fromJson(response.getResponse(), EventTypeDefinitionUI[].class); - List resBodyFlat = flatten(Arrays.asList(resBody)); - Report.logDebug("resBodyFlat", gsonStrict.toJson(resBodyFlat)); - - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - - softly.assertThat(resBodyFlat).extracting("name").as("name") - .doesNotContain(StringUtils.EMPTY) - .doesNotContainNull(); - - softly.assertThat(resBodyFlat).extracting("id").as("id") - .doesNotContain(StringUtils.EMPTY) - .doesNotContainNull(); - }); - } - - - /* Negative */ - - - - - /* Private Methods */ - - public class StrictJsonDeserializer implements JsonDeserializer { - private Gson gson = new Gson(); - - @Override - public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - try { - Field[] declaredFields = Class.forName(typeOfT.getTypeName()).getDeclaredFields(); - Arrays.asList(declaredFields).stream() - .map(field -> field.getName()) - .forEach(fieldName -> { - if (json.getAsJsonObject().has(fieldName) == false) { - throw new JsonParseException(String.format("Missing field '%s'", fieldName)); - } - }); - } catch (SecurityException e) { - throw new JsonParseException("unable to parse", e); - } catch (ClassNotFoundException e) { - throw new JsonParseException("unable to parse", e); - } - return gson.fromJson(json, typeOfT); - } - - } - - - private List flatten(List events) { - List result = new ArrayList(); - events.stream().forEach(e -> { - List children = e.getChildren(); - result.add(e); // add this node - if (children != null) { - result.addAll(flatten(children)); // add child nodes recursively - } - }); - return result; - } - - /* Negative */ - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java deleted file mode 100644 index 66ca1cb..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.ruleEditor; - -import org.apache.commons.collections.SetUtils; -import org.apache.commons.lang3.StringUtils; -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypesByVersionUI; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class GetListEventsAndVersionsTest extends DcaeRestBaseTest { - - /* Positive */ - - @Test - public void test_successResponse() throws Exception { - // act - Report.log(Status.INFO, "test_successResponse: Requesting VES event types"); - RestResponse response = DcaeRestClient.getVesEventTypes(); - Report.logDebug("Response", response); - // assert - EventTypesByVersionUI[] resBody = gson.fromJson(response.getResponse(), EventTypesByVersionUI[].class); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - - softly.assertThat(resBody).as("response body").isNotEmpty(); - - softly.assertThat(resBody).extracting("version").as("version") - .doesNotContain(StringUtils.EMPTY) - .doesNotContainNull(); - - softly.assertThat(resBody).extracting("eventTypes").as("eventTypes list") - .doesNotContain(SetUtils.EMPTY_SET) - .doesNotContainNull(); - softly.assertThat(resBody).flatExtracting("eventTypes").as("eventTypes list (flatten)") - .doesNotContainAnyElementsOf(EventTypesByVersionUI.DEFAULT_EVENTS) - .doesNotContain(StringUtils.EMPTY) - .doesNotContainNull(); - }); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java deleted file mode 100644 index 73b51be..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java +++ /dev/null @@ -1,319 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.ruleEditor; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.entities.rule_editor.SaveRuleError; -import org.onap.sdc.dcae.composition.services.Artifact; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.JsonObject; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.MappingRules; -import org.onap.sdc.dcae.composition.restmodels.ruleeditor.Rule; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.testng.annotations.Test; -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.fail; - -import java.util.List; - -public class RuleEditorControllerTest extends DcaeRestBaseTest { - - private String ruleRequestBody = - "{version:4.1,eventType:syslogFields,description:newRule,actions:[{from:{value:fromField,regex:\"\"},target:event.commonEventHeader.target,id:id,actionType:copy}," - + "{actionType:concat,from:{values:[{value:concat1},{value:_concat2}]},target:concatTargetField},{actionType:copy,from:{value:extractFromHere,regex:\"([^:]*):.*\"},target:regexTargetField}," - + "{actionType:map,from:{value:fromField},target:mapTargetField,map:{values:[{key:sourceVal1,value:targetVal1},{key:sourceVal2,value:targetVal2}],haveDefault:true,default:'\"\"'}}," - + "{actionType:\"Date Formatter\",id:98908,from:{value:\"${dateFormatterFrom}\"},target:dateFormatterTarget,dateFormatter:{toTimezone:UVW,fromTimezone:XYZ,fromFormat:inputFormat,toFormat:outputFormat}}]," - + "condition:{left:\"${leftOperand}\",operator:contains,right:[rightOperand1,rightOperand2]}}"; - - @Test - public void saveNewMappingRulesArtifactSuccessTest() throws Exception { - Report.log(Status.INFO, "test start"); - Vfcmt vfcmt = createVfcmt(); - RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "n.1.map", "param1", ruleRequestBody); - JsonObject jsonRes = gson.fromJson(res.getResponse(), JsonObject.class); - assertThat(jsonRes.get("version").getAsString()).isEqualTo("4.1"); - assertThat(jsonRes.get("eventType").getAsString()).isEqualTo("syslogFields"); - assertThat(jsonRes.get("uid")).isNotNull(); - String expectedArtifactName = "map_n.1.map_param1_MappingRules.json"; - Artifact savedArtifact = fetchVfcmtArtifactMetadataByName(vfcmt.getUuid(), expectedArtifactName); - assertThat(savedArtifact).isNotNull(); - } - - @Test - public void translateSnmpMappingRuleWithAllActionTypesSuccessTest() throws Exception { - String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"}," - + "{\"phase\":\"%s\",\"class\":\"RunPhase\"}]},{\"phase\":\"%s\",\"filter\":{\"filters\":[{\"string\":\"${leftOperand}\",\"value\":\"rightOperand1\",\"class\":\"Contains\"}," - + "{\"string\":\"${leftOperand}\",\"value\":\"rightOperand2\",\"class\":\"Contains\"}],\"class\":\"Or\"}," - + "\"processors\":[{\"updates\":{\"event.commonEventHeader.target\":\"fromField\",\"concatTargetField\":\"concat1_concat2\"},\"class\":\"Set\"}," - + "{\"regex\":\"([^:]*):.*\",\"field\":\"regexTargetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}," - + "{\"map\":{\"sourceVal1\":\"targetVal1\",\"sourceVal2\":\"targetVal2\"},\"field\":\"fromField\",\"toField\":\"mapTargetField\",\"default\":\"\",\"class\":\"MapAlarmValues\"}," - + "{\"fromFormat\":\"inputFormat\",\"fromTz\":\"XYZ\",\"toField\":\"dateFormatterTarget\",\"toFormat\":\"outputFormat\",\"toTz\":\"UVW\",\"value\":\"${dateFormatterFrom}\",\"class\":\"DateFormatter\"}]}," - + "{\"phase\":\"%s\",\"processors\":[{\"phase\":\"map_publish\",\"class\":\"RunPhase\"}]}]}"; - Vfcmt vfcmt = createVfcmt(); - String name = vfcmt.getName(); - saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); - RestResponse res = DcaeRestClient.translateRules(vfcmt.getUuid(),"map", "map", "param1", "SNMP"); - Report.log(Status.INFO, "translateRules response= "+res); - assertThat(res.getStatusCode()).isEqualTo(200); - assertThat(res.getResponse()).isEqualTo(String.format(expectedTranslation, name, name, name)); - } - - @Test - public void addNewRuleToExistingArtifact() throws Exception{ - Vfcmt vfcmt = createVfcmt(); - String nid = "n.565663636.0"; - RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", nid, "param1", ruleRequestBody); - Rule rule1 = gson.fromJson(res.getResponse(), Rule.class); - res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", nid, "param1", ruleRequestBody); - Report.log(Status.INFO, "saveRule response= "+res); - Rule rule2 = gson.fromJson(res.getResponse(), Rule.class); - RestResponse responseGetRules = DcaeRestClient.getRules(vfcmt.getUuid(),"map", nid, "param1"); - Report.log(Status.INFO, "getRules response= "+responseGetRules); - MappingRules rules = gson.fromJson(responseGetRules.getResponse(), MappingRules.class); - Report.log(Status.INFO, "MappingRules="+responseGetRules.getResponse()); - assertThat(rules.getRules()).hasSize(2); - assertThat(rules.getRules().keySet()).containsOnly(rule1.getUid(), rule2.getUid()); - } - - @Test - public void editExistingRuleInArtifact() throws Exception{ - Vfcmt vfcmt = createVfcmt(); - String updated = "This is an update"; - RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); - Rule rule = gson.fromJson(res.getResponse(), Rule.class); - Report.log(Status.INFO, "save rule response=%s", res.getResponse()); - res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); - Report.log(Status.INFO, "getRules3 response= "+res); - MappingRules rules = gson.fromJson(res.getResponse(), MappingRules.class); - Report.log(Status.INFO, "MappingRules1="+res.getResponse()); - assertThat(rules.getRules().get(rule.getUid()).getDescription()).isEqualTo("newRule"); - assertThat(rules.getRules().keySet()).containsOnly(rule.getUid()); - rule.setDescription(updated); - DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", rule.toJson()); - Report.log(Status.INFO, "saveRule response= "+res); - res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); - Report.log(Status.INFO, "getRules2 response= "+res); - rules = gson.fromJson(res.getResponse(), MappingRules.class); - Report.log(Status.INFO, "MappingRules2="+res.getResponse()); - assertThat(rules.getRules()).hasSize(1); - assertThat(rules.getRules().get(rule.getUid()).getDescription()).isEqualTo(updated); - } - - @Test - public void editRuleInArtifactNoSuchIdErrorTest() throws Exception { - String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6036\",\"text\":\"Error - Failed to save rule. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Error - Failed to save rule. Internal persistence error\"}},\"notes\":\"\"}"; - Vfcmt vfcmt = createVfcmt(); - RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); - Rule rule = gson.fromJson(res.getResponse(), Rule.class); - Report.log(Status.INFO, "rule="+rule); - rule.setUid("NoSuchUid"); - res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", rule.toJson()); - Report.log(Status.INFO, "saveRule response= "+res); - assertThat(res.getStatusCode()).isEqualTo(409); - assertThat(res.getResponse()).isEqualTo(expectedError); - } - - - @Test - public void getAllRules() throws Exception{ - Vfcmt vfcmt = createVfcmt(); - RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); - String uid1 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); - //save two more rules - res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody); - Report.log(Status.INFO, "saveRule1 response= "+res); - String uid2 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); - res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody); - Report.log(Status.INFO, "saveRule2 response= "+res); - String uid3 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); - res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); - Report.log(Status.INFO, "getRules response= "+res); - JsonObject jsonRes = gson.fromJson(res.getResponse(), JsonObject.class); - Report.log(Status.INFO, "jsonRes="+jsonRes); - assertThat(jsonRes.get("schema")).isNotNull(); - MappingRules actualRules = gson.fromJson(res.getResponse(), MappingRules.class); - Report.log(Status.INFO, "MappingRules="+res.getResponse()); - assertThat(actualRules.getRules()).hasSize(3); - assertThat(actualRules.getRules().keySet()).containsOnly(uid1, uid2, uid3); - } - - - @Test - public void deleteRuleSuccessTest() throws Exception{ - Vfcmt vfcmt = createVfcmt(); - //save first rule - RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); - String uid1 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); - // save second rule - res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody); - Report.log(Status.INFO, "saveRule response= "+res); - String uid2 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); - res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); - Report.log(Status.INFO, "getRules1 response= "+res); - MappingRules actualRules = gson.fromJson(res.getResponse(), MappingRules.class); - Report.log(Status.INFO, "MappingRules1="+res.getResponse()); - // get all rules should return both - assertThat(actualRules.getRules()).hasSize(2); - assertThat(actualRules.getRules().keySet()).containsOnly(uid1, uid2); - // delete a rule - res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", uid2); - Report.log(Status.INFO, "deleteRule1 response= "+res); - assertThat(res.getStatusCode()).isEqualTo(200); - res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); - Report.log(Status.INFO, "getRules2 response= "+res); - actualRules = gson.fromJson(res.getResponse(), MappingRules.class); - Report.log(Status.INFO, "MappingRules2="+res.getResponse()); - // get rules should return one rule - assertThat(actualRules.getRules()).hasSize(1); - assertThat(actualRules.getRules().keySet()).containsOnly(uid1); - // delete the last rule - artifact should be deleted - res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", uid1); - Report.log(Status.INFO, "deleteRule2 response= "+res); - assertThat(res.getStatusCode()).isEqualTo(200); - String expectedArtifactName = "map_map_param1_MappingRules.json"; - Artifact savedArtifact = fetchVfcmtArtifactMetadataByName(vfcmt.getUuid(), expectedArtifactName); - Report.log(Status.INFO, "savedArtifact= "+savedArtifact); - assertThat(savedArtifact).isNull(); - // get rules should return empty - res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); - Report.log(Status.INFO, "getRules3 response= "+res); - assertThat(res.getStatusCode()).isEqualTo(200); - assertThat(res.getResponse()).isEqualTo("{}"); - - } - - @Test - public void invalidJsonRuleFormatTest() throws Exception{ - String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6035\",\"text\":\"Error - Rule format is invalid: %1.\",\"variables\":[\"java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $\"],\"formattedErrorMessage\":\"Error - Rule format is invalid: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $.\"}},\"notes\":\"\"}"; - RestResponse res = DcaeRestClient.saveRule("someId", "someName", "someNid", "someParam", "gibberish" ); - assertThat(res.getStatusCode()).isEqualTo(400); - assertThat(res.getResponse()).isEqualTo(expectedError); - } - - @Test - public void invalidActionTypeTest() throws Exception { - String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6035\",\"text\":\"Error - Rule format is invalid: %1.\",\"variables\":[\"Undefined action type: gibberish\"],\"formattedErrorMessage\":\"Error - Rule format is invalid: Undefined action type: gibberish.\"}},\"notes\":\"\"}"; - RestResponse res = DcaeRestClient.saveRule("someId", "someName", "someNid", "someParam", "{actions:[{actionType:gibberish}]}"); - assertThat(res.getStatusCode()).isEqualTo(400); - assertThat(res.getResponse()).isEqualTo(expectedError); - } - - @Test - public void conflictingUsersErrorTest() throws Exception { - Vfcmt vfcmt = createVfcmt(); - RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); - assertThat(res.getStatusCode()).isEqualTo(200); - //check out by other user then try to save rule by current user - res = DcaeRestClient.checkoutVfcmt(vfcmt.getUuid(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId()); - assertThat(res.getStatusCode()).isEqualTo(200); - res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "someParam", ruleRequestBody); - assertThat(res.getStatusCode()).isEqualTo(403); - } - - @Test - public void uploadArtifactSdcErrorTest() throws Exception { - String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6036\",\"text\":\"Error - Failed to save rule. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Error - Failed to save rule. Internal persistence error\"}},\"notes\":\"Error: Invalid content.\"}"; - Vfcmt vfcmt = createVfcmt(); - RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); - assertThat(res.getStatusCode()).isEqualTo(200); - // Generated artifact label would be invalid and should fail when submitted to SDC - res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "()someParam", ruleRequestBody); - assertThat(res.getStatusCode()).isEqualTo(409); - assertThat(res.getResponse()).isEqualTo(expectedError); - } - - @Test - public void saveMappingRuleNoSuchNidErrorTest() throws Exception { - String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6114\",\"text\":\"DCAE component %1 not found in composition\",\"variables\":[\"noSuchComponent\"],\"formattedErrorMessage\":\"DCAE component noSuchComponent not found in composition\"}},\"notes\":\"\"}"; - Vfcmt vfcmt = createVfcmt(); - RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); - assertThat(res.getStatusCode()).isEqualTo(200); - res = DcaeRestClient.saveRule(vfcmt.getUuid(), "noSuchComponent", "noSuchComponent", "someParam", ruleRequestBody); - assertThat(res.getStatusCode()).isEqualTo(400); - assertThat(res.getResponse()).isEqualTo(expectedError); - } - - - @Test - public void deleteRuleNoSuchIdTest() throws Exception { - String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6115\",\"text\":\"Delete rule failed. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Delete rule failed. Internal persistence error\"}},\"notes\":\"\"}"; - Vfcmt vfcmt = createVfcmt(); - //save rule - saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); - RestResponse res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", "noSuchRuleId"); - Report.log(Status.INFO, "deleteRule response=%s", res); - assertThat(res.getStatusCode()).isEqualTo(409); - assertThat(res.getResponse()).isEqualTo(expectedError); - } - - // After first rule is saved the mappingRules.json artifact is available for get/delete/edit tests - private RestResponse saveCompositionAndFirstRuleSuccess(Vfcmt vfcmt, String dcaeCompName, String nid, String configParam, String body) throws Exception { - // generate and save a composition.yml - Report.log(Status.INFO, "saveCompositionAndFirstRuleSuccess start"); - RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), String.format("{\"nid\":\"%s\"}", nid)); - Report.log(Status.INFO, "saveComposition response=%s", res); - assertThat(res.getStatusCode()).isEqualTo(200); - - res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam, body); - Report.log(Status.INFO, "saveRule response=%s", res); - assertThat(res.getStatusCode()).isEqualTo(200); - return res; - } - - - @Test - public void saveMappingRuleNegativeTest_BadResponse() throws Exception { - // arrange - Report.log(Status.INFO, "Arrangeing test..."); - ObjectMapper mapper = new ObjectMapper(); - String badRuleRequestBody = "{\"version\":\"5.3\",\"eventType\":\"syslogFields\",\"uid\":\"\",\"description\":\"map rules\"," - + "\"actions\":[{actionType:\"Date Formatter\",from:{value:whatever}},{\"id\":\"22fdded0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"AAA\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"BBB\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":true,\"default\":\"\"}},{\"id\":\"2d6fab00-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"DDD\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"60bff5a0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"EEE\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"75ea0ce0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"FFF\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"GGG\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"},{\"key\":\"\",\"value\":\"\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"75ea0ce0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"FFF\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"GGG\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"},{\"key\":\"foo\",\"value\":\"not bar\"}],\"haveDefault\":false,\"default\":\"\"}}],\"condition\":null}"; - Vfcmt vfcmt = createVfcmt(); - Report.log(Status.INFO, "Saving composition of a fake cdump..."); - RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); - Report.logDebug("saveComposition response", res); - if (res.getStatusCode() != 200) { - fail("Unable to arrange test, save composition failed\n" + res.toString()); - } - // act - Report.log(Status.INFO, "Executing..."); - Report.logDebug("Request body", badRuleRequestBody); - RestResponse targetRes = DcaeRestClient.saveRule(vfcmt.getUuid(), "noSuchComponent", "map", "someParam", badRuleRequestBody); - Report.logDebug("saveRule response", targetRes); - // assert - Report.log(Status.INFO, "Asserting..."); - List errors = mapper.readValue(targetRes.getResponse(), SaveRuleError.class).getFormattedErrors(); // parse response - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(targetRes.getStatusCode()).isEqualTo(400); - softly.assertThat(errors).containsExactlyInAnyOrder( - "Please fill the default value of map action to BBB", - "Please fill the from field of map action to DDD", - "Please fill the target field of map action to ", - "Please fill all key-value pairs of map action to GGG", - "Error: Duplication in map keys exists, please modify rule configuration", - "Please fill the target field of Date Formatter action to null", - "Please fill the to timezone field of Date Formatter action to null", - "Please fill the from timezone field of Date Formatter action to null", - "Please fill the from format field of Date Formatter action to null", - "Please fill the to format field of Date Formatter action to null" - ); - }); - } - - @Test - public void translateInvalidFlowTypeFailureTest() throws Exception { - String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6116\",\"text\":\"Translation failed. Reason: %s\",\"variables\":[\"%s\"],\"formattedErrorMessage\":\"Translation failed. Reason: %s\"}},\"notes\":\"\"}"; - RestResponse res = DcaeRestClient.translateRules("someId","map", "map", "param1", "noSuchFlowType"); - assertThat(res.getStatusCode()).isEqualTo(400); - assertThat(res.getResponse()).isEqualTo(String.format(expectedError, "%1", "Flow type noSuchFlowType not found", "Flow type noSuchFlowType not found")); - res = DcaeRestClient.translateRules("someId","map", "map", "param1", null); - assertThat(res.getStatusCode()).isEqualTo(400); - assertThat(res.getResponse()).isEqualTo(String.format(expectedError, "%1", "Flow type null not found", "Flow type null not found")); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/GetAttachment.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/GetAttachment.java deleted file mode 100644 index a1c9193..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/GetAttachment.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.services.attachment; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; - -import static org.assertj.core.api.Assertions.*; - -import java.util.UUID; - -import org.assertj.core.api.SoftAssertions; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.testng.annotations.*; - -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class GetAttachment extends DcaeRestBaseTest { - - /* Positive */ - - @Test - public void testNewVfcmt_noAttachedService() throws Exception { - Report.log(Status.INFO, "testNewVfcmt_noAttachedService start"); - // arrange - Vfcmt vfcmt = client.createVfcmt(); - // act - RestResponse response = DcaeRestClient.getAttachedService(vfcmt.getUuid()); - // assert - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); - softly.assertThat(resData.get("successResponse")) - .as("successResponse") - .isEqualTo("No Artifacts"); - }); - } - - /* Negative */ - - @Test - public void testNonUuidVfcmt_responseStatus404() throws Exception { - // act - RestResponse response = DcaeRestClient.getAttachedService("I am not a uuid"); - // assert - assertThat(response.getStatusCode()).as("status code").isEqualTo(404); - } - - @Test - public void testNonExistingVfcmt_responseStatus404() throws Exception { - // arrange - String fakeUuid = UUID.randomUUID().toString(); - // act - RestResponse response = DcaeRestClient.getAttachedService(fakeUuid); - // assert - assertThat(response.getStatusCode()).as("status code").isEqualTo(404); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/PostAttachment.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/PostAttachment.java deleted file mode 100644 index afd018f..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/attachment/PostAttachment.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.services.attachment; - -import static org.assertj.core.api.Assertions.*; - -import com.att.ecomp.dcae.ci.entities.composition.services.Vfi; -import org.assertj.core.api.SoftAssertions; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.testng.annotations.*; - -import java.util.UUID; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.openecomp.d2.ci.datatypes.ResourceReqDetails; -import org.openecomp.d2.ci.datatypes.ServiceReqDetails; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.SdcInternalApiClient; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class PostAttachment extends DcaeRestBaseTest { - - /* Positive */ - - @Test - public void vfcmtWithVfi_responseStatusOk() throws Exception { - // arrange - Vfcmt vfcmt; - Vfi vfi; - try { - vfcmt = client.createCheckedinVfcmt(); - vfi = arrangeVfi(); - } catch (Exception err) { - throw new Exception("Could not arrange test", err); - } - // act - Report.log(Status.INFO, "Attaching vfcmt [%s] to vfi [%s]", vfcmt.getUuid(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); - Report.logDebug("Response:", response); - // assert - JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat(resData.get("successResponse")) - .as("successResponse") - .isEqualTo("Artifact updated"); - }); - } - - - @Test - public void vfcmtAlreadyAttached_responseStatusOk() throws Exception { - // arrange - Vfcmt vfcmt; - Vfi vfi; - try { - vfcmt = client.createCheckedinVfcmt(); - Report.log(Status.INFO, "Arranging first attachment"); - arrangeAttachmentToNewVfi(vfcmt); - vfi = arrangeVfi(); - } catch (Exception err) { - throw new Exception("Could not arrange test", err); - } - // act - Report.log(Status.INFO, "Updating attachment of vfcmt [%s] to a new vfi [%s]", vfcmt.getUuid(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); - Report.logDebug("Response:", response); - // assert - JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - softly.assertThat(resData.get("successResponse")) - .as("successResponse") - .isEqualTo("Artifact updated"); - }); - } - - - /* Negative */ - - - @Test - public void vfWithVfi_statusCode400() throws Exception { - // arrange - ResourceReqDetails vf; - Vfi vfi; - try { - Report.log(Status.INFO, "Create vf"); - vf = SdcInternalApiClient.createVf(); - vfi = arrangeVfi(); - } catch (Exception err) { - throw new Exception("Could not arrange test", err); - } - // act - Report.log(Status.INFO, "Attaching vf [%s] to vfi [%s]", vf.getUUID(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vf.getUUID(), vfi.getContainer().getUUID(), vfi.getName()); - Report.logDebug("Response:", response); - // assert - assertThat(response.getStatusCode()).as("status code").isEqualTo(400); - } - - - @Test - public void vfcmtWithFakeServiceAndFakeVfi_statusCode404() throws Exception { - // arrange - Vfcmt vfcmt; - String fakeServiceUuid = UUID.randomUUID().toString(); - String fakeVfiName = "fakeVfi"; - try { - vfcmt = client.createCheckedinVfcmt(); - fakeServiceUuid = UUID.randomUUID().toString(); - fakeVfiName = "fakeVfi"; - } catch (Exception err) { - throw new Exception("Could not arrange test", err); - } - // act - Report.log(Status.INFO, "Attaching real vfcmt [%s] to fake service [%s] (random uuid) and fake vfi [%s]", vfcmt.getUuid(), fakeServiceUuid, fakeVfiName); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), fakeServiceUuid, fakeVfiName); - Report.logDebug("Response:", response); - // assert - assertThat(response.getStatusCode()).as("status code").isEqualTo(404); - } - - - @Test - public void vfcmtWithFakeVfi_statusCode404() throws Exception { - // arrange - Vfcmt vfcmt; - Vfi vfi; - try { - vfcmt = client.createCheckedinVfcmt(); - Report.log(Status.INFO, "Create service"); - ServiceReqDetails service = SdcInternalApiClient.createService(); - vfi = new Vfi("fakeVfi", service); - } catch (Exception err) { - throw new Exception("Could not arrange test", err); - } - // act - Report.log(Status.INFO, "Attaching vfcmt [%s] to real service [%s] and fake vfi [%s]", vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); - Report.logDebug("Response:", response); - // assert - assertThat(response.getStatusCode()).as("status code").isEqualTo(404); - } - - - /* Private Methods */ - - private Vfi arrangeVfi() throws Exception { - Report.log(Status.INFO, "Create service"); - ServiceReqDetails service = SdcInternalApiClient.createService(); - Report.log(Status.INFO, "Create vf"); - ResourceReqDetails vf = SdcInternalApiClient.createVf(); - Report.log(Status.INFO, "Checkin vf"); - ResourceReqDetails vfCheckedin = SdcInternalApiClient.checkinVf(vf); - Report.log(Status.INFO, "Create vfi from (service [%s] + vf [%s])", service.getUUID(), vf.getUUID()); - return SdcInternalApiClient.createVfi(service, vf); - } - - - private void arrangeAttachmentToNewVfi(Vfcmt vfcmt) throws Exception { - Vfi vfi = arrangeVfi(); - Report.log(Status.INFO, "Attaching vfcmt [%s] to vfi [%s]", vfcmt.getUuid(), vfi.getName()); - RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUUID(), vfi.getName()); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 200) { - throw new Exception("Failed to attach vfcmt to vfi\nResponse: " + response.toString()); - } - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java deleted file mode 100644 index 582bc9b..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.services.instance; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.aventstack.extentreports.Status; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.Test; - -import java.io.IOException; - -import static org.assertj.core.api.Assertions.assertThat; - -public class GetServiceInstanceNagative extends DcaeRestBaseTest { - - @Test - public void test_invalidServiceID() throws IOException{ - ExtentTestActions.log(Status.INFO, "Send invalid service Instance"); - RestResponse response = DcaeRestClient.getServicesInstance("123456789"); - ExtentTestActions.log(Status.INFO, "Verifying response status is 404"); - assertThat(response.getStatusCode()).as("response status").isEqualTo(404); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java deleted file mode 100644 index a724b39..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.services.instance; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.List; -import java.util.function.Predicate; - -import org.assertj.core.api.SoftAssertions; -import org.onap.sdc.dcae.composition.restmodels.sdc.ServiceDetailed; -import org.onap.sdc.dcae.composition.services.Resource; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.onap.sdc.dcae.composition.restmodels.DcaeMinimizedService; -import org.springframework.util.CollectionUtils; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; - -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; - -public class GetServiceInstancePositive extends DcaeRestBaseTest { - - private RestResponse response; - - @BeforeClass - public void executeApiCall() throws Exception { - // arrange - DcaeMinimizedService service = arrangeService(); - try { - // act - ExtentTestActions.log(Status.INFO, "Get all VFIs for service [" + service.getUuid() + "]"); - response = DcaeRestClient.getServicesInstance(service.getUuid()); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - } catch (Exception err) { - ExtentTestActions.log(Status.FAIL, "Unable to execute api call: " + err.toString()); - err.printStackTrace(); - } - } - - private DcaeMinimizedService arrangeService() throws Exception { - DcaeMinimizedService service = null; - try { - Predicate hasVfi = p -> !CollectionUtils.isEmpty(getService(p.getUuid()).getResources()); - Vfcmt vfcmt = client.createCheckedoutVfcmt(); - ExtentTestActions.log(Status.INFO, "Created vfcmt [" + vfcmt.getUuid() + "]"); - ExtentTestActions.log(Status.INFO, "Get all services for vfcmt [" + vfcmt.getUuid() + "]"); - RestResponse responseServices = DcaeRestClient.getServices(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(responseServices)); - DcaeMinimizedService[] servicesList = gson.fromJson(responseServices.getResponse(), DcaeMinimizedService[].class); - // TODO: create a service instead of picking a random one - // find a service with a vfi - service = Arrays.stream(servicesList).filter(hasVfi).findAny().orElse(null); - } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, "Could not arrange test: " + err.toString()); - } - return service; - } - - private ServiceDetailed getService(String serviceId) { - ServiceDetailed service = null; - try { - service = gson.fromJson(DcaeRestClient.getServicesInstance(serviceId).getResponse(), ServiceDetailed.class); - } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, "Could not arrange test: " + e.toString()); - } - return service; - } - - @Test - public void test_responseStatusOk() throws IOException{ - // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); - assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - } - - @Test - public void test_atLeastOneOrMoreResources() throws IOException{ - // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a one service instance"); - List resourceList = getResourceListFromJsonResponse(); - ExtentTestActions.log(Status.INFO, "validating parsed response structure"); - assertThat(resourceList).size().isGreaterThanOrEqualTo(1); // TODO: create a VFI for the service instead of picking a random one - } - - @Test - public void test_responseIsValidStructure() throws IOException{ - // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a one service instance"); - - List resourceList = getResourceListFromJsonResponse(); - - ExtentTestActions.log(Status.INFO, "validating parsed response structure"); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(resourceList.get(0).getResourceInstanceName()).isNotEmpty(); - softly.assertThat(resourceList.get(0).getResourceInvariantUUID()).isNotEmpty(); - }); - } - - - /*** private method ***/ - private List getResourceListFromJsonResponse() { - JsonParser jsonParser = new JsonParser(); - JsonObject responseJson = (JsonObject)jsonParser.parse(response.getResponse()); - JsonArray resources = responseJson.getAsJsonArray("resources"); - Type listType = new TypeToken>(){}.getType(); - List resourceList = gson.fromJson(resources, listType); - return resourceList; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesNagative.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesNagative.java deleted file mode 100644 index a1935ae..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesNagative.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.services.list; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.fail; - -import java.io.IOException; - -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; - -public class GetAllServicesNagative extends DcaeRestBaseTest { - - @Test - public void userNotLastUpdater_statusCode403() throws Exception{ - // arrange - String user1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId(); - String user2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId(); - Vfcmt vfcmt = null; - try { - vfcmt = client.createCheckedoutVfcmt(user1); - } catch (Exception err) { - fail("Unable to arrange test", err); - } - // act - ExtentTestActions.log(Status.INFO, "GetServices for user that is not the vfcmt last-updater"); - RestResponse response = getServices(vfcmt.getUuid(), user2); - // assert - assertThat(response.getStatusCode()).as("response status").isEqualTo(403); - } - - - /* Private Methods */ - - private RestResponse getServices(String uuid, String user2) throws IOException { - RestResponse response = DcaeRestClient.getServices(uuid, user2); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - return response; - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesPositive.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesPositive.java deleted file mode 100644 index 88a7b71..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/services/list/GetAllServicesPositive.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.services.list; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.List; - -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.onap.sdc.dcae.composition.restmodels.sdc.Service; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; -import com.google.gson.reflect.TypeToken; - -public class GetAllServicesPositive extends DcaeRestBaseTest { - - private RestResponse response; - - @BeforeClass - public void executeApiCall() throws Exception { - ExtentTestActions.log(Status.INFO, "@BeforeClass --> executeApiCall"); - Vfcmt component = client.createCheckedoutVfcmt(); - String uuid = component.getUuid(); - String userIdLastUpdaterUserId = component.getLastUpdaterUserId(); - try { - // act - ExtentTestActions.log(Status.INFO, "Get all services"); - response = DcaeRestClient.getServices(uuid, userIdLastUpdaterUserId); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - err.printStackTrace(); - } - } - - @Test - public void test_responseStatusOk() throws IOException{ - // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); - assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - } - - @Test - public void test_responseIsValidStructure() throws IOException{ - // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a List of Services"); - Type listType = new TypeToken>(){}.getType(); - List servicesList = gson.fromJson(response.getResponse(), listType); - Service service = servicesList.get(0); - - ExtentTestActions.log(Status.INFO, "validating parsed response structure"); - - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(service.getInvariantUUID()).isNotEmpty(); - softly.assertThat(service.getLastUpdaterUserId()).isNotEmpty(); - softly.assertThat(service.getName()).isNotEmpty(); - softly.assertThat(service.getUuid()).isNotEmpty(); - softly.assertThat(service.getLifecycleState()).isNotEmpty(); - softly.assertThat(service.getVersion()).isNotEmpty(); - }); - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java deleted file mode 100644 index 33dd50f..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java +++ /dev/null @@ -1,253 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; -import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; -import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; -import org.onap.sdc.dcae.composition.restmodels.ImportVFCMTRequest; -import org.onap.sdc.dcae.composition.restmodels.MessageResponse; -import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; -import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed; -import org.onap.sdc.dcae.composition.services.Service; -import org.onap.sdc.dcae.composition.util.DcaeBeConstants; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateMonitoringComponent extends DcaeRestBaseTest { - - private RestResponse response; - private Resource res = null; - - - @BeforeClass - public void executeApiCall() { - // arrange - try { - // act - ExtentTestActions.log(Status.INFO, "Creating vfcmt"); - RestResponse clientResponse = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); - Resource[] resources = gson.fromJson(clientResponse.getResponse(),Resource[].class); - if (resources.length > 0){ - res = resources[0]; - } - } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - } - } - - @Test - public void testCreateMonitoringComponentSuccess() throws IOException { - - Service service; - - try { - service = createServiceWithVFiAsSdcDesigner(); - } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); - return; - } - - CreateVFCMTRequest request = new CreateVFCMTRequest(); - // If you crashed here (below) it is because your environment has no Base Monitoring Templates - request.setTemplateUuid(res.getUuid()); - request.setVfiName(service.getResources().get(0).getResourceInstanceName()); - request.setServiceUuid(service.getUuid()); - DcaeRestClient.fillCreateMcRequestMandatoryFields(request); - - response = DcaeRestClient.createMc(gson.toJson(request)); - - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - - CreateMcResponse mcResponse = gson.fromJson(response.getResponse(),CreateMcResponse.class); - - String vfUuid = mcResponse.getVfcmt().getUuid(); - String vfCdump = gson.toJson(mcResponse.getCdump()); - assertThat(vfCdump.contains(vfUuid)).isTrue(); - - RestResponse r = DcaeRestClient.getAttachedService(vfUuid); - assertThat(r.getResponse().contains(service.getUuid())).isTrue(); - - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - } - - @Test - public void testCreateMonitoringComponentBadUser() throws IOException { - - String fakeUserId = "anonymous"; - CreateVFCMTRequest request = new CreateVFCMTRequest(); - // If you crashed here (below) it is because your environment has no Base Monitoring Templates - request.setTemplateUuid(res.getUuid()); - DcaeRestClient.fillCreateMcRequestMandatoryFields(request); - - response = DcaeRestClient.createMc(gson.toJson(request),fakeUserId); - - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - // assert - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(403); - } - - @Test - public void testImportMonitoringComponentBothFlagsFalseSuccess() throws Exception { - - Service service; - - try { - service = createServiceWithVFiAsSdcDesigner(); - } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); - return; - } - - String vfiName = service.getResources().get(0).getResourceInstanceName(); - Vfcmt vfcmt = prepareMockVfcmtForImport(); - ImportVFCMTRequest request = new ImportVFCMTRequest(); - request.setTemplateUuid(vfcmt.getUuid()); - request.setVfiName(vfiName); - request.setServiceUuid(service.getUuid()); - DcaeRestClient.fillCreateMcRequestMandatoryFields(request); - - response = DcaeRestClient.importMc(gson.toJson(request)); - - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - - // the service vfi should now have an external reference record to the vfcmt - response = DcaeRestClient.getServiceExternalReferences(service.getUuid(), service.getVersion()); - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - Map> refs = gson.fromJson(response.getResponse(), Map.class); - assertThat(vfcmt.getUuid().equals(refs.get("monitoringComponents").get(0).get("uuid"))).isTrue(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - } - - @Test - public void testImportMonitoringComponentCloneFalseUpdateFlowTypeTrueSuccess() throws Exception { - - Service service; - - try { - service = createServiceWithVFiAsSdcDesigner(); - } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); - return; - } - - String vfiName = service.getResources().get(0).getResourceInstanceName(); - Vfcmt vfcmt = prepareMockVfcmtForImport(); - ImportVFCMTRequest request = new ImportVFCMTRequest(); - request.setUpdateFlowType(true); - request.setTemplateUuid(vfcmt.getUuid()); - request.setVfiName(vfiName); - request.setServiceUuid(service.getUuid()); - DcaeRestClient.fillCreateMcRequestMandatoryFields(request); - - response = DcaeRestClient.importMc(gson.toJson(request)); - - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - - // TODO update to one GET call after editMC is implemented - // assert that the vfcmt was updated as expected (version, owner, lifecycle) - response = DcaeRestClient.getResourceDetails(vfcmt.getUuid()); - ResourceDetailed updatedMC = gson.fromJson(response.getResponse(), ResourceDetailed.class); - assertThat(updatedMC.getVersion()).isEqualTo("0.2"); - assertThat(updatedMC.getLastUpdaterUserId()).isEqualTo(DcaeRestClient.getDefaultUser().getUserId()); - assertThat(updatedMC.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name()); - // assert that the updated cdump includes 'flowType' - - response = DcaeRestClient.getComposition(vfcmt.getUuid()); - String cdump = gson.fromJson(response.getResponse(), MessageResponse.class).getSuccessResponse(); - assertThat(cdump).isEqualTo("{\"flowType\":\"flowType_xxx\",\"cid\":\"1234567\"}"); - ExtentTestActions.log(Status.DEBUG, "Response updated mock cdump: " + cdump); - } - - @Test - public void testImportMonitoringComponentBothFlagsTrueSuccess() throws Exception { - - Service service; - - try { - service = createServiceWithVFiAsSdcDesigner(); - } catch (Exception e) { - ExtentTestActions.log(Status.ERROR, e); - return; - } - - String vfiName = service.getResources().get(0).getResourceInstanceName(); - Vfcmt vfcmt = prepareMockVfcmtForImport(); - ImportVFCMTRequest request = new ImportVFCMTRequest(); - request.setUpdateFlowType(true); - request.setCloneVFCMT(true); - request.setTemplateUuid(vfcmt.getUuid()); - request.setVfiName(vfiName); - request.setServiceUuid(service.getUuid()); - DcaeRestClient.fillCreateMcRequestMandatoryFields(request); - - response = DcaeRestClient.importMc(gson.toJson(request)); - - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(200); - - // assert that the vfcmt was cloned, the flowType updated and the reference artifact created - CreateMcResponse mcResponse = gson.fromJson(response.getResponse(),CreateMcResponse.class); - - assertThat(mcResponse.getVfcmt().getFlowType()).isEqualTo("flowType_xxx"); - // check the reference artifact - response = DcaeRestClient.getAttachedService(mcResponse.getVfcmt().getUuid()); - String ref = gson.fromJson(response.getResponse(), MessageResponse.class).getSuccessResponse(); - assertThat(ref).isEqualTo(service.getUuid()+"/resources/"+vfiName); - - ExtentTestActions.log(Status.DEBUG, "Response cloned Monitoring component: " + mcResponse); - } - - @Test - public void testImportMonitoringComponentServiceNotFoundFailure() throws Exception { - - Vfcmt vfcmt = prepareMockVfcmtForImport(); - ImportVFCMTRequest request = new ImportVFCMTRequest(); - request.setTemplateUuid(vfcmt.getUuid()); - DcaeRestClient.fillCreateMcRequestMandatoryFields(request); - response = DcaeRestClient.importMc(gson.toJson(request)); - - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(404); - - ExtentTestActions.log(Status.DEBUG, "Error response: " + response.getResponse()); - // assert vfcmt version was not increased - response = DcaeRestClient.getResourceDetails(vfcmt.getUuid()); - vfcmt = gson.fromJson(response.getResponse(), Vfcmt.class); - assertThat(vfcmt.getVersion()).isEqualTo("0.1"); - } - - - private Vfcmt prepareMockVfcmtForImport() throws IOException { - RestResponse createResponse = DcaeRestClient.createVfcmt(StringUtils.randomString("CI-", 20), "description", ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2).getUserId()); - Vfcmt vfcmt = gson.fromJson(createResponse.getResponse(), Vfcmt.class); - // create a composition artifact - DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"cid\":\"1234567\"}"); - return vfcmt; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateVfcmt.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateVfcmt.java deleted file mode 100644 index deb1020..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/CreateVfcmt.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; - -import static org.assertj.core.api.Assertions.*; - -import java.io.IOException; - -import org.assertj.core.api.SoftAssertions; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.User; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.*; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.DcaeTestConstants; -import com.aventstack.extentreports.Status; -import com.att.ecomp.dcae.ci.utilities.StringUtils; - -public class CreateVfcmt extends DcaeRestBaseTest { - - private Vfcmt input; - private RestResponse response; - - @BeforeClass - public void executeApiCall() { - // arrange - input = new Vfcmt(); - input.setName(StringUtils.randomString("CI-", 20)); - input.setDescription(StringUtils.randomString("", 10)); - try { - // act - ExtentTestActions.log(Status.INFO, "Creating vfcmt"); - response = DcaeRestClient.createVfcmt(input.getName(), input.getDescription()); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - err.printStackTrace(); - } - } - - /* Positive tests */ - - @Test - public void test_responseStatusOk() throws IOException { - // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); - assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - } - - @Test - public void test_responseIsValidStructure() throws IOException { - // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a VFCMT"); - Vfcmt createdVfcmt = gson.fromJson(response.getResponse(), Vfcmt.class); - ExtentTestActions.log(Status.INFO, "validating parsed response structure"); - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(createdVfcmt.getCategory()).isEqualTo("Template"); - softly.assertThat(createdVfcmt.getInvariantUUID()).isNotEmpty(); - softly.assertThat(createdVfcmt.getUuid()).isNotEmpty(); - softly.assertThat(createdVfcmt.getLastUpdaterUserId()).isEqualTo(DcaeRestClient.getDefaultUser().getUserId()); - softly.assertThat(createdVfcmt.getLifecycleState()).isEqualTo(DcaeTestConstants.Sdc.State.NOT_CERTIFIED_CHECKOUT); - softly.assertThat(createdVfcmt.getName()).isEqualTo(input.getName()); - softly.assertThat(createdVfcmt.getDescription()).isEqualTo(input.getDescription()); - softly.assertThat(createdVfcmt.getResourceType()).isEqualTo("VFCMT"); - softly.assertThat(createdVfcmt.getSubCategory()).isEqualTo("Monitoring Template"); - softly.assertThat(createdVfcmt.getVersion()).isEqualTo("0.1"); - }); - } - - /* Negative tests */ - -// @Test -// public void testNameLengthGraterThen50_TBD() throws IOException { -// // arrange -// int length = 51; -// String name = StringUtils.randomString("CI-", length); -// String description = StringUtils.randomString("", 10); -// // act -// RestResponse response = DcaeRestClient.createVfcmt(name, description); -// // assert -// -// } - - @Test - public void testWithNonExistingUser_status403() throws IOException { - // arrange - String fakeUserId = "anonymous"; - String name = StringUtils.randomString("CI-", 20); - String description = StringUtils.randomString("", 10); - // act - ExtentTestActions.log(Status.INFO, "Creating vfcmt with fake user"); - RestResponse response = DcaeRestClient.createVfcmt(name, description, fakeUserId); - ExtentTestActions.log(Status.DEBUG, "response: " + StringUtils.truncate(response)); - // assert - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(403); - } - - @Test - public void testCreateTwoVfcmtsWithSameName_status409() throws IOException { - // arrange - String name = StringUtils.randomString("CI-", 20); - ExtentTestActions.log(Status.INFO, "Creating first vfcmt with name '" + name + "'"); - RestResponse response1 = DcaeRestClient.createVfcmt(name, StringUtils.randomString("", 10)); - ExtentTestActions.log(Status.DEBUG, "First Response: " + StringUtils.truncate(response1)); - if (response1.getStatusCode() != 200) { - fail("unable to arrange test - could not create the first vfcmt"); - } - // act - ExtentTestActions.log(Status.INFO, "Creating second vfcmt with same name '" + name + "'"); - RestResponse response2 = DcaeRestClient.createVfcmt(name, StringUtils.randomString("", 10)); - ExtentTestActions.log(Status.DEBUG, "Second response: " + StringUtils.truncate(response2)); - // assert - assertThat(response2.getStatusCode()) - .as("second status code") - .isEqualTo(409); - } - - @Test - public void testWithNonDesignerRole_status403() throws IOException { - // arrange - User tester = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); - String name = StringUtils.randomString("CI-", 20); - String description = StringUtils.randomString("", 10); - // act - ExtentTestActions.log(Status.INFO, "Creating vfcmt with role tester"); - RestResponse response = DcaeRestClient.createVfcmt(name, description, tester.getUserId()); - ExtentTestActions.log(Status.DEBUG, "response: " + StringUtils.truncate(response)); - // assert - assertThat(response.getStatusCode()) - .as("status code") - .isEqualTo(403); - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java deleted file mode 100644 index 874c00d..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class GetAllMonitoringTemplateVfcmts extends DcaeRestBaseTest { - - private RestResponse response; - private static final String BASE_MONITORING_TEMPLATE = "Base Monitoring Template"; - - @BeforeClass - public void executeApiCall() { - try { - // act - ExtentTestActions.log(Status.INFO, "Fetching all monitoring templates vfcmt resources"); - response = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - } - } - - @Test - public void testResponseStatusOk() { - // assert - ExtentTestActions.log(Status.INFO, "Verifying response status is 200"); - assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - } - - @Test - public void testResponseBodyIsListOfVfcmtsOnly() { - // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a list of monitoring template VFCMTs"); - Vfcmt[] vfcmtList = gson.fromJson(response.getResponse(), Vfcmt[].class); - - ExtentTestActions.log(Status.INFO, "Verifying we got items"); - assertThat(vfcmtList).isNotEmpty(); - - ExtentTestActions.log(Status.INFO, "Verifying all items of the parsed response are VFCMTs"); - assertThat(vfcmtList) - .as("response data") - .extracting("resourceType") - .containsOnly("VFCMT"); - - ExtentTestActions.log(Status.INFO, "Verifying that all items of the parsed response are monitoring template VFCMTs"); - assertThat(vfcmtList) - .as("response data") - .extracting("subCategory") - .containsOnly(BASE_MONITORING_TEMPLATE); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java deleted file mode 100644 index 3483de7..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; - -import static org.assertj.core.api.Assertions.*; - -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.*; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; - -public class GetAllVfcmts extends DcaeRestBaseTest { - - private RestResponse response; - - @BeforeClass - public void executeApiCall() { - try { - // act - ExtentTestActions.log(Status.INFO, "Fetching all vfcmt resources"); - response = DcaeRestClient.getAllVfcmts(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - err.printStackTrace(); - } - } - - /* Positive tests */ - - @Test - public void testResponseStatusOk() { - // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 200"); - assertThat(response.getStatusCode()).as("response status").isEqualTo(200); - } - - @Test - public void testResponseBodyIsListOfVfcmtsOnly() { - // assert - ExtentTestActions.log(Status.INFO, "Parsing response to a list of VFCMTs"); - Vfcmt[] vfcmtList = gson.fromJson(response.getResponse(), Vfcmt[].class); - ExtentTestActions.log(Status.INFO, "Verifing all items of the parsed response are VFCMTs"); - assertThat(vfcmtList) - .as("response data") - .extracting("resourceType") - .containsOnly("VFCMT"); - } - - /* Negative tests */ -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java deleted file mode 100644 index f63ab7f..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.StringUtils; -import com.aventstack.extentreports.Status; -import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; -import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; -import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; -import org.onap.sdc.dcae.composition.services.Service; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -public class GetVfcmtsForMigration extends DcaeRestBaseTest { - - private static final String STATUS_CODE = "status code"; - private RestResponse response; - private Resource res = null; - - @BeforeClass - public void executeApiCall() { - try { - // act - ExtentTestActions.log(Status.INFO, "Selecting vfcmt resources for migration"); - response = DcaeRestClient.getVfcmtsForMigration("services","1111111","1.3"); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - - ExtentTestActions.log(Status.INFO, "getAllMonitoringTemplatesVfcmts"); - RestResponse clientResponse = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); - Resource[] resources = gson.fromJson(clientResponse.getResponse(),Resource[].class); - if (resources.length > 0){ - res = resources[0]; - } - } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - err.printStackTrace(); - } - } - - @Test - public void testResponseStatus500ServiceNotFound() { - // assert - ExtentTestActions.log(Status.INFO, "Verifing response status is 500"); - assertThat(response.getStatusCode()).as("response status").isEqualTo(500); - assertThat(response.getResponse().contains("resource was not found")); - } - - // If tests are taking too long: consider removing this very tedious and long test - @Test - public void testCreateMonitoringComponentSuccess() throws IOException { - CreateVFCMTRequest request = new CreateVFCMTRequest(); - - request.setDescription("Test description"); - - Service service; - - try { - service = createServiceWithVFiAsSdcDesigner(); - } catch (Exception e) { - e.printStackTrace(); - return; - } - - // If you crashed here (below) it is because your environment has no Base Monitoring Templates - request.setTemplateUuid(res.getUuid()); - if (service != null) { - request.setServiceUuid(service.getUuid()); - } - request.setVfiName(service.getResources().get(0).getResourceInstanceName()); - - List listOfVfcmtsConnectedToService = new ArrayList<>(); - for (int i = 0 ; i < 4 ; i++){ - request.setName(StringUtils.randomString("CI-", 20)); - addMandatoryInputFieldsToRequestObject(request); - response = DcaeRestClient.createMc(gson.toJson(request)); - assertThat(response.getStatusCode()).as(STATUS_CODE).isEqualTo(200); - CreateMcResponse mcResponse = gson.fromJson(response.getResponse(),CreateMcResponse.class); - String key = mcResponse.getVfcmt().getUuid(); - String value = gson.toJson(mcResponse.getCdump()); - assertThat(value.contains(key)).isTrue(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - listOfVfcmtsConnectedToService.add(key); - } - - response = DcaeRestClient.getVfcmtsForMigration("services",service.getUuid(),service.getVersion()); - assertThat(response.getStatusCode()).as(STATUS_CODE).isEqualTo(200); - - listOfVfcmtsConnectedToService.forEach( s -> assertThat(response.getResponse().contains(s)).isFalse()); - - response = DcaeRestClient.getAllVfcmts(); - assertThat(response.getStatusCode()).as(STATUS_CODE).isEqualTo(200); - - listOfVfcmtsConnectedToService.forEach( s -> assertThat(response.getResponse().contains(s)).isTrue()); - - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java b/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java deleted file mode 100644 index 34f4686..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.att.ecomp.dcae.ci.api.tests.vfcmt; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.testng.annotations.*; -import static org.assertj.core.api.Assertions.*; - -import com.att.ecomp.dcae.ci.api.tests.DcaeRestBaseTest; -import com.aventstack.extentreports.Status; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; - -public class VfcmtCreationFlow extends DcaeRestBaseTest { - - private Vfcmt[] vfcmtsBeforeAdd; - private Vfcmt newVfcmt; - private Vfcmt[] vfcmtsAfterAdd; - - @BeforeClass - public void executeFlow() throws Exception { - ExtentTestActions.log(Status.INFO, "@BeforeClass --> executeFlow (getAllVfcmts)"); - try { - // act - vfcmtsBeforeAdd = client.getAllVfcmts(); - newVfcmt = client.createVfcmt(); - vfcmtsAfterAdd = client.getAllVfcmts(); - } catch (Exception err) { - ExtentTestActions.log(Status.ERROR, err); - err.printStackTrace(); - } - } - - @Test - public void test_numberOfVfcmtsIncresed() { - ExtentTestActions.log(Status.INFO, String.format("asserting (after[%d] > before[%d])", vfcmtsAfterAdd.length, vfcmtsBeforeAdd.length)); - // assert - assertThat(vfcmtsAfterAdd.length).isGreaterThan(vfcmtsBeforeAdd.length); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Artifact.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Artifact.java deleted file mode 100644 index c7687d2..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Artifact.java +++ /dev/null @@ -1,109 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.items; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Artifact { - - @SerializedName("artifactChecksum") - @Expose - private String artifactChecksum; - @SerializedName("artifactType") - @Expose - private String artifactType; - @SerializedName("artifactUUID") - @Expose - private String artifactUUID; - @SerializedName("artifactVersion") - @Expose - private String artifactVersion; - @SerializedName("artifactName") - @Expose - private String artifactName; - @SerializedName("artifactGroupType") - @Expose - private String artifactGroupType; - @SerializedName("artifactURL") - @Expose - private String artifactURL; - @SerializedName("artifactDescription") - @Expose - private String artifactDescription; - @SerializedName("artifactLabel") - @Expose - private String artifactLabel; - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public String getArtifactType() { - return artifactType; - } - - public void setArtifactType(String artifactType) { - this.artifactType = artifactType; - } - - public String getArtifactUUID() { - return artifactUUID; - } - - public void setArtifactUUID(String artifactUUID) { - this.artifactUUID = artifactUUID; - } - - public String getArtifactVersion() { - return artifactVersion; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public String getArtifactGroupType() { - return artifactGroupType; - } - - public void setArtifactGroupType(String artifactGroupType) { - this.artifactGroupType = artifactGroupType; - } - - public String getArtifactURL() { - return artifactURL; - } - - public void setArtifactURL(String artifactURL) { - this.artifactURL = artifactURL; - } - - public String getArtifactDescription() { - return artifactDescription; - } - - public void setArtifactDescription(String artifactDescription) { - this.artifactDescription = artifactDescription; - } - - public String getArtifactLabel() { - return artifactLabel; - } - - public void setArtifactLabel(String artifactLabel) { - this.artifactLabel = artifactLabel; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Data.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Data.java deleted file mode 100644 index 267c296..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Data.java +++ /dev/null @@ -1,21 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.items; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Data { - - @SerializedName("element") - @Expose - private Element element; - - public Element getElement() { - return element; - } - - public void setElement(Element element) { - this.element = element; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/DcaeComponents.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/DcaeComponents.java deleted file mode 100644 index 26a7000..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/DcaeComponents.java +++ /dev/null @@ -1,54 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.items; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class DcaeComponents { - - @SerializedName("id") - @Expose - private Object id; - @SerializedName("timestamp") - @Expose - private Integer timestamp; - @SerializedName("data") - @Expose - private Data data; - @SerializedName("error") - @Expose - private Error error; - - public Object getId() { - return id; - } - - public void setId(Object id) { - this.id = id; - } - - public Integer getTimestamp() { - return timestamp; - } - - public void setTimestamp(Integer timestamp) { - this.timestamp = timestamp; - } - - public Data getData() { - return data; - } - - public void setData(Data data) { - this.data = data; - } - - public Error getError() { - return error; - } - - public void setError(Error error) { - this.error = error; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Element.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Element.java deleted file mode 100644 index f681587..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Element.java +++ /dev/null @@ -1,55 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.items; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Element { - - @SerializedName("itemId") - @Expose - private String itemId; - @SerializedName("name") - @Expose - private String name; - @SerializedName("id") - @Expose - private String id; - @SerializedName("items") - @Expose - private List items = null; - - public String getItemId() { - return itemId; - } - - public void setItemId(String itemId) { - this.itemId = itemId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Error.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Error.java deleted file mode 100644 index b1a1f49..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Error.java +++ /dev/null @@ -1,8 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.items; - - -public class Error { - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Item.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Item.java deleted file mode 100644 index 777e4aa..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Item.java +++ /dev/null @@ -1,220 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.items; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Item { - - @SerializedName("lifecycleState") - @Expose - private String lifecycleState; - @SerializedName("models") - @Expose - private List models = null; - @SerializedName("subCategory") - @Expose - private String subCategory; - @SerializedName("catalog") - @Expose - private String catalog; - @SerializedName("lastUpdaterUserId") - @Expose - private String lastUpdaterUserId; - @SerializedName("description") - @Expose - private String description; - @SerializedName("uuid") - @Expose - private String uuid; - @SerializedName("version") - @Expose - private String version; - @SerializedName("itemId") - @Expose - private String itemId; - @SerializedName("catalogId") - @Expose - private Integer catalogId; - @SerializedName("toscaModelURL") - @Expose - private String toscaModelURL; - @SerializedName("name") - @Expose - private String name; - @SerializedName("invariantUUID") - @Expose - private String invariantUUID; - @SerializedName("id") - @Expose - private Integer id; - @SerializedName("category") - @Expose - private String category; - @SerializedName("lastUpdaterFullName") - @Expose - private String lastUpdaterFullName; - @SerializedName("toscaResourceName") - @Expose - private String toscaResourceName; - @SerializedName("resourceType") - @Expose - private String resourceType; - @SerializedName("artifacts") - @Expose - private List artifacts = null; - - public String getLifecycleState() { - return lifecycleState; - } - - public void setLifecycleState(String lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public List getModels() { - return models; - } - - public void setModels(List models) { - this.models = models; - } - - public String getSubCategory() { - return subCategory; - } - - public void setSubCategory(String subCategory) { - this.subCategory = subCategory; - } - - public String getCatalog() { - return catalog; - } - - public void setCatalog(String catalog) { - this.catalog = catalog; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getItemId() { - return itemId; - } - - public void setItemId(String itemId) { - this.itemId = itemId; - } - - public Integer getCatalogId() { - return catalogId; - } - - public void setCatalogId(Integer catalogId) { - this.catalogId = catalogId; - } - - public String getToscaModelURL() { - return toscaModelURL; - } - - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getLastUpdaterFullName() { - return lastUpdaterFullName; - } - - public void setLastUpdaterFullName(String lastUpdaterFullName) { - this.lastUpdaterFullName = lastUpdaterFullName; - } - - public String getToscaResourceName() { - return toscaResourceName; - } - - public void setToscaResourceName(String toscaResourceName) { - this.toscaResourceName = toscaResourceName; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public List getArtifacts() { - return artifacts; - } - - public void setArtifacts(List artifacts) { - this.artifacts = artifacts; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Model.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Model.java deleted file mode 100644 index a1b732f..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/items/Model.java +++ /dev/null @@ -1,65 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.items; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Model { - - @SerializedName("itemId") - @Expose - private String itemId; - @SerializedName("name") - @Expose - private String name; - @SerializedName("description") - @Expose - private String description; - @SerializedName("id") - @Expose - private String id; - @SerializedName("version") - @Expose - private String version; - - public String getItemId() { - return itemId; - } - - public void setItemId(String itemId) { - this.itemId = itemId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Artifact.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Artifact.java deleted file mode 100644 index 413fda7..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Artifact.java +++ /dev/null @@ -1,109 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Artifact { - - @SerializedName("artifactChecksum") - @Expose - private String artifactChecksum; - @SerializedName("artifactType") - @Expose - private String artifactType; - @SerializedName("artifactUUID") - @Expose - private String artifactUUID; - @SerializedName("artifactVersion") - @Expose - private String artifactVersion; - @SerializedName("artifactName") - @Expose - private String artifactName; - @SerializedName("artifactGroupType") - @Expose - private String artifactGroupType; - @SerializedName("artifactURL") - @Expose - private String artifactURL; - @SerializedName("artifactDescription") - @Expose - private String artifactDescription; - @SerializedName("artifactLabel") - @Expose - private String artifactLabel; - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public String getArtifactType() { - return artifactType; - } - - public void setArtifactType(String artifactType) { - this.artifactType = artifactType; - } - - public String getArtifactUUID() { - return artifactUUID; - } - - public void setArtifactUUID(String artifactUUID) { - this.artifactUUID = artifactUUID; - } - - public String getArtifactVersion() { - return artifactVersion; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public String getArtifactGroupType() { - return artifactGroupType; - } - - public void setArtifactGroupType(String artifactGroupType) { - this.artifactGroupType = artifactGroupType; - } - - public String getArtifactURL() { - return artifactURL; - } - - public void setArtifactURL(String artifactURL) { - this.artifactURL = artifactURL; - } - - public String getArtifactDescription() { - return artifactDescription; - } - - public void setArtifactDescription(String artifactDescription) { - this.artifactDescription = artifactDescription; - } - - public String getArtifactLabel() { - return artifactLabel; - } - - public void setArtifactLabel(String artifactLabel) { - this.artifactLabel = artifactLabel; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Item.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Item.java deleted file mode 100644 index f0b5cfa..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Item.java +++ /dev/null @@ -1,220 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Item { - - @SerializedName("lifecycleState") - @Expose - private String lifecycleState; - @SerializedName("models") - @Expose - private List models = null; - @SerializedName("subCategory") - @Expose - private String subCategory; - @SerializedName("catalog") - @Expose - private String catalog; - @SerializedName("lastUpdaterUserId") - @Expose - private String lastUpdaterUserId; - @SerializedName("description") - @Expose - private String description; - @SerializedName("uuid") - @Expose - private String uuid; - @SerializedName("version") - @Expose - private String version; - @SerializedName("itemId") - @Expose - private String itemId; - @SerializedName("catalogId") - @Expose - private Integer catalogId; - @SerializedName("toscaModelURL") - @Expose - private String toscaModelURL; - @SerializedName("name") - @Expose - private String name; - @SerializedName("invariantUUID") - @Expose - private String invariantUUID; - @SerializedName("id") - @Expose - private Integer id; - @SerializedName("category") - @Expose - private String category; - @SerializedName("lastUpdaterFullName") - @Expose - private String lastUpdaterFullName; - @SerializedName("toscaResourceName") - @Expose - private String toscaResourceName; - @SerializedName("resourceType") - @Expose - private String resourceType; - @SerializedName("artifacts") - @Expose - private List artifacts = null; - - public String getLifecycleState() { - return lifecycleState; - } - - public void setLifecycleState(String lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public List getModels() { - return models; - } - - public void setModels(List models) { - this.models = models; - } - - public String getSubCategory() { - return subCategory; - } - - public void setSubCategory(String subCategory) { - this.subCategory = subCategory; - } - - public String getCatalog() { - return catalog; - } - - public void setCatalog(String catalog) { - this.catalog = catalog; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getItemId() { - return itemId; - } - - public void setItemId(String itemId) { - this.itemId = itemId; - } - - public Integer getCatalogId() { - return catalogId; - } - - public void setCatalogId(Integer catalogId) { - this.catalogId = catalogId; - } - - public String getToscaModelURL() { - return toscaModelURL; - } - - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getLastUpdaterFullName() { - return lastUpdaterFullName; - } - - public void setLastUpdaterFullName(String lastUpdaterFullName) { - this.lastUpdaterFullName = lastUpdaterFullName; - } - - public String getToscaResourceName() { - return toscaResourceName; - } - - public void setToscaResourceName(String toscaResourceName) { - this.toscaResourceName = toscaResourceName; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public List getArtifacts() { - return artifacts; - } - - public void setArtifacts(List artifacts) { - this.artifacts = artifacts; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java deleted file mode 100644 index f1fce3e..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java +++ /dev/null @@ -1,55 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class ItemsElement { - - @SerializedName("itemId") - @Expose - private String itemId; - @SerializedName("name") - @Expose - private String name; - @SerializedName("id") - @Expose - private Integer id; - @SerializedName("items") - @Expose - private List items = null; - - public String getItemId() { - return itemId; - } - - public void setItemId(String itemId) { - this.itemId = itemId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Model.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Model.java deleted file mode 100644 index b5e7fad..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Model.java +++ /dev/null @@ -1,65 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Model { - - @SerializedName("itemId") - @Expose - private String itemId; - @SerializedName("name") - @Expose - private String name; - @SerializedName("description") - @Expose - private String description; - @SerializedName("id") - @Expose - private String id; - @SerializedName("version") - @Expose - private String version; - - public String getItemId() { - return itemId; - } - - public void setItemId(String itemId) { - this.itemId = itemId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Service.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Service.java deleted file mode 100644 index 7001293..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/element/Service.java +++ /dev/null @@ -1,21 +0,0 @@ - -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.element; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Service { - - @SerializedName("element") - @Expose - private ItemsElement element; - - public ItemsElement getElement() { - return element; - } - - public void setElement(ItemsElement element) { - this.element = element; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Element.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Element.java deleted file mode 100644 index eb8e592..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Element.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.elements; - -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Element { - -@SerializedName("itemId") -@Expose -private String itemId; -@SerializedName("catalogId") -@Expose -private Integer catalogId; -@SerializedName("catalog") -@Expose -private String catalog; -@SerializedName("name") -@Expose -private String name; -@SerializedName("id") -@Expose -private Integer id; -@SerializedName("labels") -@Expose -private List labels = null; - -public String getItemId() { -return itemId; -} - -public void setItemId(String itemId) { -this.itemId = itemId; -} - -public Integer getCatalogId() { -return catalogId; -} - -public void setCatalogId(Integer catalogId) { -this.catalogId = catalogId; -} - -public String getCatalog() { -return catalog; -} - -public void setCatalog(String catalog) { -this.catalog = catalog; -} - -public String getName() { -return name; -} - -public void setName(String name) { -this.name = name; -} - -public Integer getId() { -return id; -} - -public void setId(Integer id) { -this.id = id; -} - -public List getLabels() { -return labels; -} - -public void setLabels(List labels) { -this.labels = labels; -} - -} \ No newline at end of file diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Elements.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Elements.java deleted file mode 100644 index aea6e20..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/rightMenu/elements/Elements.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.composition.rightMenu.elements; -import java.util.List; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Elements { - @SerializedName("elements") - @Expose - private List elements = null; - - public List getElements() { - return elements; - } - - public void setElements(List elements) { - this.elements = elements; - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/CiService.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/CiService.java deleted file mode 100644 index 7921965..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/CiService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.composition.services; - -import org.onap.sdc.dcae.composition.services.Service; -import org.openecomp.d2.ci.datatypes.ServiceReqDetails; - -public class CiService extends Service { - // converts from ui-api-ci object to dcae-ci object (partial construction) - public CiService(ServiceReqDetails service) { - super(service.getName(), service.getUUID(), service.getVersion()); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/Vfi.java b/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/Vfi.java deleted file mode 100644 index dcf74cb..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/composition/services/Vfi.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.composition.services; - -import org.openecomp.d2.ci.datatypes.ServiceReqDetails; - -public class Vfi { - private String name; - private ServiceReqDetails container; - - public Vfi(String name, ServiceReqDetails container) { - this.name = name; - this.container = container; - } - - public String getName() { - return name; - } - - public ServiceReqDetails getContainer() { - return container; - } -} \ No newline at end of file diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/rule_editor/SaveRuleError.java b/src/main/java/com/att/ecomp/dcae/ci/entities/rule_editor/SaveRuleError.java deleted file mode 100644 index 7af5e51..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/rule_editor/SaveRuleError.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.rule_editor; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class SaveRuleError { - private Map requestError; - private String notes; - - @JsonCreator - public SaveRuleError( - @JsonProperty("requestError") Map requestError, @JsonProperty("notes") String notes) { - this.requestError = requestError; - this.notes = notes; - } - - - - public List getFormattedErrors() { - List> errors = (List>)requestError.get("serviceExceptions"); - return errors.stream().map(e -> e.get("formattedErrorMessage")).collect(Collectors.toList()); - } -} \ No newline at end of file diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcCategory.java b/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcCategory.java deleted file mode 100644 index dd82f7d..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcCategory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.sdc; - -import java.util.List; - -public class SdcCategory { - - private String name; - private List subcategories; - - - public String getName() { - return name; - } - - public List getSubcategories() { - return subcategories; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponent.java b/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponent.java deleted file mode 100644 index 386d3de..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.sdc; - -import java.util.List; -import java.util.Map; - -public class SdcComponent { - - private String lastUpdaterUserId; - private String uniqueId; - private String version; - private String resourceType; - private List categories; - private Map allVersions; - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public String getUniqueId() { - return uniqueId; - } - - public String getVersion() { - return version; - } - - public String getResourceType() { - return resourceType; - } - - public List getCategories() { - return categories; - } - - public Map getAllVersions() { - return allVersions; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponentMetadata.java b/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponentMetadata.java deleted file mode 100644 index 0ebf94c..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/entities/sdc/SdcComponentMetadata.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.att.ecomp.dcae.ci.entities.sdc; - - -public class SdcComponentMetadata { - - private SdcComponent metadata; - - public SdcComponent getMetadata() { - return metadata; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/run/RunTestSuite.java b/src/main/java/com/att/ecomp/dcae/ci/run/RunTestSuite.java deleted file mode 100644 index 67639a2..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/run/RunTestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.att.ecomp.dcae.ci.run; - -import org.openecomp.d2.ci.run.RunTest; - -public class RunTestSuite { - - public static void main(String[] args) { - RunTest.runTestSuite(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java deleted file mode 100644 index 9098d23..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.tests.verificator.CompositionVerificator; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class DCAECompositionPage { - - public static WebElement expandList(String listname) - { - ExtentTestActions.log(Status.INFO,String.format("Expand %s list", listname)); - GeneralUIUtils.clickOnElementByTestId(listname); - GeneralUIUtils.ultimateWait(); - WebDriver driver = GeneralUIUtils.getDriver(); - WebDriverWait wait = new WebDriverWait(driver, 10); - WebElement categoryElement = driver.findElement(ByTest.id(listname)).findElement(By.xpath("./..")); - return wait.until(Locator.from(categoryElement).findVisible(By.cssSelector(".draggable"), 0)); - } - - public static void addItemFromList(WebElement item) - { - ExtentTestActions.log(Status.INFO,String.format("Click on %s item", item.getText())); - item.click(); - GeneralUIUtils.ultimateWait(); - - } - - public static void clickSave() - { - ExtentTestActions.log(Status.INFO,"Click save button"); - GeneralUIUtils.clickOnElementByTestId("SaveButton"); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.waitForElementInVisibilityByTestId("saveMsg"); - String actualSaveRes = GeneralUIUtils.getWebElementByTestID("saveMsg").getText(); - CompositionVerificator.verifySaveSuccessfully(actualSaveRes); - GeneralUIUtils.ultimateWait(); - } - - public static void clickSubmit() - { - ExtentTestActions.log(Status.INFO,"Click submit button"); - GeneralUIUtils.clickOnElementByTestId("SubmitButton"); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.waitForElementInVisibilityByTestId("submitMsg"); - String actualSubmitRes = GeneralUIUtils.getWebElementByTestID("submitMsg").getText(); - CompositionVerificator.verifySubmitSuccessfully(actualSubmitRes); - GeneralUIUtils.ultimateWait(); - } - - public static void SelectFlowType(String flowType) { - Report.log(Status.INFO, "Selecting flow type '%s'", flowType); - WebDriver driver = GeneralUIUtils.getDriver(); - Select flowTypeSelect = new Select(driver.findElement(ByTest.id("flowTypeSelect"))); - flowTypeSelect.selectByVisibleText(flowType); - } -} - - - - diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java deleted file mode 100644 index f1f947a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - -import java.util.UUID; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.WebElement; -import com.aventstack.extentreports.Status; - -public class DCAEGeneralPage { - - public static String addAssetName(String name) - { - WebElement nameTextbox = GeneralUIUtils.getWebElementByTestID("name"); - String assetName = name + UUID.randomUUID(); - nameTextbox.clear(); - nameTextbox.sendKeys(assetName); - GeneralUIUtils.ultimateWait(); - ExtentTestActions.log(Status.INFO,String.format("Add asset name: %s.", assetName)); - return assetName; - } - - public static void addAssetDescription(String description) - { - ExtentTestActions.log(Status.INFO,"Add asset description"); - WebElement descriptionTextbox = GeneralUIUtils.getWebElementByTestID("description"); - descriptionTextbox.clear(); - descriptionTextbox.sendKeys(description); - GeneralUIUtils.ultimateWait(); - } - - - public static void clickSaveAsset() throws Exception - { - ExtentTestActions.log(Status.INFO,"Click Save asset"); - GeneralUIUtils.waitForElementInVisibilityByTestId("Save-General"); - GeneralUIUtils.clickOnElementByTestId("Save-General"); - GeneralUIUtils.ultimateWait(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java deleted file mode 100644 index 17ee026..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; - -import com.aventstack.extentreports.Status; - - -public class DCAEHomePage { - - - - public static void clickOnDcaeTab() - { - ExtentTestActions.log(Status.INFO,"Clicking on DCAE Tab"); - GeneralUIUtils.clickOnElementByTestId("main-menu-button-dcae"); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnCreateNewAsset() - { - ExtentTestActions.log(Status.INFO,"Clicking on Create new asset button"); - GeneralUIUtils.clickOnElementByTestId("AddButtonsArea"); - GeneralUIUtils.ultimateWait(); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java deleted file mode 100644 index 563c42b..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - - - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; - -import com.aventstack.extentreports.Status; - -public class DCAELeftPanel { - - public static void navigateToServices() - { - ExtentTestActions.log(Status.INFO,"Navigate to Services internal tab"); - GeneralUIUtils.clickOnElementByTestId("dcae-menu-item-Services"); - GeneralUIUtils.ultimateWait(); - } - - public static void navigateToComposition() - { - ExtentTestActions.log(Status.INFO,"Navigate to Composition internal tab"); - GeneralUIUtils.clickOnElementByTestId("dcae-menu-item-Composition"); - GeneralUIUtils.ultimateWait(); - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java deleted file mode 100644 index f935715..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; - -import com.aventstack.extentreports.Status; - -public class DCAEServicesPage { - - public static void selectService(String serviceName) - { - GeneralUIUtils.ultimateWait(); - ExtentTestActions.log(Status.INFO,String.format("Select Service: %s from services dropdown", serviceName)); - GeneralUIUtils.getSelectList(serviceName, "Service Name SelectList"); - GeneralUIUtils.ultimateWait(); - } - - public static void selectVNFI(String VNFIName) - { - GeneralUIUtils.ultimateWait(); - VNFIName = VNFIName + " 0"; - ExtentTestActions.log(Status.INFO,String.format("Select VNFI: %s from VNFIs dropdown", VNFIName)); - GeneralUIUtils.getSelectList(VNFIName, "VNFI Name SelectList"); - GeneralUIUtils.ultimateWait(); - } - - - public static void clickAttach(String VNFIName) - { - ExtentTestActions.log(Status.INFO,"Click attach button"); - GeneralUIUtils.clickOnElementByTestId("Attach Button"); - GeneralUIUtils.ultimateWait(); - VNFIName = VNFIName + " 0"; - GeneralUIUtils.waitForElementInVisibilityByTestId(VNFIName); // Element to wait for after object is attached. - GeneralUIUtils.ultimateWait(); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java deleted file mode 100644 index 4bf9fc4..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - -import java.util.UUID; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Action; -import org.openqa.selenium.interactions.Actions; - -import com.aventstack.extentreports.Status; - -public class SDCCreateServicePage -{ - public static String addServiceName() - { - GeneralUIUtils.waitForElementInVisibilityByTestId("name"); - WebElement serviceNameTextbox = GeneralUIUtils.getWebElementByTestID("name"); - serviceNameTextbox.clear(); - String serviceName = "Service" + UUID.randomUUID(); - ExtentTestActions.log(Status.INFO, String.format("Add Service Name: %s", serviceName)); - serviceNameTextbox.sendKeys(serviceName); - GeneralUIUtils.ultimateWait(); - return serviceName; - } - - public static void addServiceCategory(String category) - { - ExtentTestActions.log(Status.INFO, String.format("Add %s Category", category)); - GeneralUIUtils.waitForElementInVisibilityByTestId("selectGeneralCategory"); - GeneralUIUtils.getSelectList(category, "selectGeneralCategory"); - GeneralUIUtils.ultimateWait(); - } - - public static void addServiceDescription() - { - ExtentTestActions.log(Status.INFO,"Add Service Desc"); - GeneralUIUtils.waitForElementInVisibilityByTestId("description"); - WebElement serviceDescTextbox = GeneralUIUtils.getWebElementByTestID("description"); - serviceDescTextbox.clear(); - String serviceDesc = "Desc"; - serviceDescTextbox.sendKeys(serviceDesc); - GeneralUIUtils.ultimateWait(); - } - - public static void addServiceDescriptionProjectCode() - { - ExtentTestActions.log(Status.INFO,"Add Service Project Code"); - GeneralUIUtils.waitForElementInVisibilityByTestId("projectCode"); - WebElement projectCodeTextbox = GeneralUIUtils.getWebElementByTestID("projectCode"); - projectCodeTextbox.clear(); - String projectCode = "12345"; - projectCodeTextbox.sendKeys(projectCode); - GeneralUIUtils.ultimateWait(); - } - - public static String addAllServiceMandtoryFields(String category) - { - String serviceName = addServiceName(); - addServiceCategory(category); - addServiceDescription(); - addServiceDescriptionProjectCode(); - - return serviceName; - } - - public static void clickOnCreateServiceButton() - { - ExtentTestActions.log(Status.INFO,"Click on Create Service Button"); - GeneralUIUtils.waitForElementInVisibilityByTestId("create/save"); - GeneralUIUtils.clickOnElementByTestId("create/save"); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnCheckInServiceButton() - { - ExtentTestActions.log(Status.INFO,"Click on Check In Service Button"); - GeneralUIUtils.waitForElementInVisibilityByTestId("check_in"); - GeneralUIUtils.clickOnElementByTestId("check_in"); - GeneralUIUtils.ultimateWait(); - } - - public static void addCheckInMessage() - { - ExtentTestActions.log(Status.INFO,"Add check in message in pop window"); - GeneralUIUtils.waitForElementInVisibilityByTestId("checkindialog"); - WebElement checkInDialogTextbox = GeneralUIUtils.getWebElementByTestID("checkindialog"); - checkInDialogTextbox.clear(); - String vfCheckInDialog = "Text"; - checkInDialogTextbox.sendKeys(vfCheckInDialog); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnCheckInOKFButton() - { - ExtentTestActions.log(Status.INFO,"Click OK in check in pop up window"); - GeneralUIUtils.waitForElementInVisibilityByTestId("OK"); - GeneralUIUtils.clickOnElementByTestId("OK"); - GeneralUIUtils.ultimateWait(); - } - - public static void checkInService() - { - clickOnCheckInServiceButton(); - addCheckInMessage(); - clickOnCheckInOKFButton(); - } - - public static void clickOnServiceCompsitionTab() - { - ExtentTestActions.log(Status.INFO,"Click on Service composition tab"); - GeneralUIUtils.waitForElementInVisibilityByTestId("CompositionLeftSideMenu"); - GeneralUIUtils.clickOnElementByTestId("CompositionLeftSideMenu"); - GeneralUIUtils.ultimateWait(); - } - - - public static void searchAssetOnCompsitionTab(String assetName) - { - ExtentTestActions.log(Status.INFO,String.format("Search for %s in Service composition", assetName)); - GeneralUIUtils.waitForElementInVisibilityByTestId("searchAsset"); - WebElement compositionSearchTextbox = GeneralUIUtils.getWebElementByTestID("searchAsset"); - compositionSearchTextbox.clear(); - compositionSearchTextbox.sendKeys(assetName); - GeneralUIUtils.ultimateWait(); - } - - public static void dragAndDropAssetToCanvas(String assetName) - { - ExtentTestActions.log(Status.INFO,String.format("Drag and drop %s to Canvas", assetName)); - GeneralUIUtils.waitForElementInVisibilityByTestId("searchAsset"); - WebElement vfElementFrom = GeneralUIUtils.getWebElementByTestID("leftbar-section-content-item-" + assetName); - WebElement canvasElementTo = GeneralUIUtils.getWebElementByTestID("canvas"); - GeneralUIUtils.ultimateWait(); - WebDriver driver = GeneralUIUtils.getDriver(); - Actions builder = new Actions(driver); - Action dragAndDrop = builder.clickAndHold(vfElementFrom).moveToElement(canvasElementTo).release(canvasElementTo).build(); - dragAndDrop.perform(); - GeneralUIUtils.ultimateWait(); - } - - public static void addAssetToCanvas(String assetName) - { - searchAssetOnCompsitionTab(assetName); - dragAndDropAssetToCanvas(assetName); - } - - public static void clickOnElementInCanavs() - { - ExtentTestActions.log(Status.INFO,"Click on VF in Canavs"); - GeneralUIUtils.waitForElementInVisibilityByTestId("canvas"); - WebElement canvasElement = GeneralUIUtils.getWebElementByTestID("canvas"); - GeneralUIUtils.ultimateWait(); - WebDriver driver = GeneralUIUtils.getDriver(); - Actions actions = new Actions(driver); - actions.moveToElement(canvasElement, 1316, 661); - actions.clickAndHold(); - actions.moveToElement(canvasElement, 1316, 661); - actions.release(); - actions.perform(); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnArtifactTab() - { - ExtentTestActions.log(Status.INFO,"Click on Artifcat"); - GeneralUIUtils.getWebElementByTestID("deployment-artifact-tab"); - GeneralUIUtils.clickOnElementByTestId("deployment-artifact-tab"); - } - - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java deleted file mode 100644 index d7a30ba..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - -import java.util.UUID; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.WebElement; - -import com.aventstack.extentreports.Status; - -public class SDCCreateVFPage -{ - public static String addVFName() - { - GeneralUIUtils.waitForElementInVisibilityByTestId("name"); - WebElement vfNameTextbox = GeneralUIUtils.getWebElementByTestID("name"); - vfNameTextbox.clear(); - String vfName = "VF" + UUID.randomUUID(); - vfNameTextbox.sendKeys(vfName); - ExtentTestActions.log(Status.INFO, String.format("Add VF Name: %s",vfName)); - GeneralUIUtils.ultimateWait(); - return vfName; - } - - public static void addVFCategory(String category) - { - ExtentTestActions.log(Status.INFO, String.format("Add %s Category", category)); - GeneralUIUtils.waitForElementInVisibilityByTestId("selectGeneralCategory"); - GeneralUIUtils.getSelectList(category, "selectGeneralCategory"); - GeneralUIUtils.ultimateWait(); - } - - public static void addVFDescription() - { - ExtentTestActions.log(Status.INFO,"Add VF Desc"); - GeneralUIUtils.waitForElementInVisibilityByTestId("description"); - WebElement vfdescTextbox = GeneralUIUtils.getWebElementByTestID("description"); - vfdescTextbox.clear(); - String vfDesc = "Desc"; - vfdescTextbox.sendKeys(vfDesc); - GeneralUIUtils.ultimateWait(); - } - - public static void addVFVendorName() - { - ExtentTestActions.log(Status.INFO,"Add VF Vendor Name"); - GeneralUIUtils.waitForElementInVisibilityByTestId("vendorName"); - WebElement vendorTextbox = GeneralUIUtils.getWebElementByTestID("vendorName"); - vendorTextbox.clear(); - String vfVendorName = "Vendor"; - vendorTextbox.sendKeys(vfVendorName); - GeneralUIUtils.ultimateWait(); - } - - public static void addVFVendorRelease() - { - ExtentTestActions.log(Status.INFO,"Add VF Vendor Release"); - GeneralUIUtils.waitForElementInVisibilityByTestId("vendorRelease"); - WebElement vendorReleaseTextbox = GeneralUIUtils.getWebElementByTestID("vendorRelease"); - vendorReleaseTextbox.clear(); - String vfVendorRelease = "1"; - vendorReleaseTextbox.sendKeys(vfVendorRelease); - GeneralUIUtils.ultimateWait(); - } - - public static String addAllVFMandtoryFields(String category) - { - String vfName = addVFName(); - addVFCategory(category); - addVFDescription(); - addVFVendorName(); - addVFVendorRelease(); - - return vfName; - } - - public static void clickOnCreateVFButton() - { - ExtentTestActions.log(Status.INFO,"Click on Create VF Button"); - GeneralUIUtils.waitForElementInVisibilityByTestId("create/save"); - GeneralUIUtils.clickOnElementByTestId("create/save"); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnCheckInVFButton() - { - ExtentTestActions.log(Status.INFO,"Click on Check In VF Button"); - GeneralUIUtils.waitForElementInVisibilityByTestId("check_in"); - GeneralUIUtils.clickOnElementByTestId("check_in"); - GeneralUIUtils.ultimateWait(); - } - - public static void addCheckInMessage() - { - ExtentTestActions.log(Status.INFO,"Add check in message in pop window"); - GeneralUIUtils.waitForElementInVisibilityByTestId("checkindialog"); - WebElement checkInDialogTextbox = GeneralUIUtils.getWebElementByTestID("checkindialog"); - checkInDialogTextbox.clear(); - String vfCheckInDialog = "Text"; - checkInDialogTextbox.sendKeys(vfCheckInDialog); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnCheckInOKFButton() - { - ExtentTestActions.log(Status.INFO,"Click OK in check in pop up window"); - GeneralUIUtils.waitForElementInVisibilityByTestId("OK"); - GeneralUIUtils.clickOnElementByTestId("OK"); - GeneralUIUtils.ultimateWait(); - } - - public static void checkInVF() - { - clickOnCheckInVFButton(); - addCheckInMessage(); - clickOnCheckInOKFButton(); - } - - - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java deleted file mode 100644 index 00a4e4e..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.pages; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.setup.SetupCDTest; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.WebElement; - -import com.att.ecomp.dcae.ci.utilities.ConfigurationReader; -import com.aventstack.extentreports.Status; - -public class SDCHomePage -{ - - public static void clickOnAddVf() - { - ExtentTestActions.log(Status.INFO,"Clicking on Add VF button"); - GeneralUIUtils.waitForElementInVisibilityByTestId("AddButtonsArea"); - GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea"); - GeneralUIUtils.waitForElementInVisibilityByTestId("createResourceButton"); - GeneralUIUtils.clickOnElementByTestId("createResourceButton"); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnAddsService() - { - ExtentTestActions.log(Status.INFO,"Clicking on Add Service button"); - GeneralUIUtils.waitForElementInVisibilityByTestId("AddButtonsArea"); - GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea"); - GeneralUIUtils.waitForElementInVisibilityByTestId("createServiceButton"); - GeneralUIUtils.clickOnElementByTestId("createServiceButton"); - GeneralUIUtils.ultimateWait(); - } - - public static void searchForElement(String name) - { - ExtentTestActions.log(Status.INFO,"Search for element in Homepage"); - GeneralUIUtils.waitForElementInVisibilityByTestId("main-menu-input-search"); - WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID("main-menu-input-search"); - searchTextbox.clear(); - searchTextbox.sendKeys(name); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnElement(String name) - { - ExtentTestActions.log(Status.INFO,"Clicking on Add VF button"); - GeneralUIUtils.waitForElementInVisibilityByTestId(name); - GeneralUIUtils.clickOnElementByTestId(name); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnHomeTab() throws Exception { - ExtentTestActions.log(Status.INFO,"Navigate to SDC Homepage"); - GeneralUIUtils.clickOnElementByCSS("div[class=triangle] span"); // Temp workaround... need to click by data-tests-id - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.clickOnElementByTestId("sub-menu-button-home"); - GeneralUIUtils.ultimateWait(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java deleted file mode 100644 index a197dd3..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor; - -import java.io.File; -import java.util.Map; - -import org.openecomp.d2.ci.datatypes.Configuration; -import org.openecomp.d2.ci.datatypes.UserCredentials; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.setup.DriverFactory; -import org.openecomp.d2.ci.utilities.FileHandling; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.web.util.UriComponentsBuilder; -import org.testng.annotations.BeforeMethod; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.LoginPage; -import com.att.ecomp.dcae.ci.utilities.ConfigurationReader; -import com.att.ecomp.dcae.ci.utilities.DcaeEntityClient; -import com.att.ecomp.dcae.ci.utilities.DcaeRestClient; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class BaseTest extends DriverFactory { - - private String baseUrl = ConfigurationReader.getConfiguration().getRuleEditorUrl(); - private final long defaultTimeout = 90; - protected WebDriverWait defaultTimeoutWait; - - @BeforeMethod - protected void setupTest(){ - try { - /** - * this is surrounded by a try block because of a bug in TestNg that causes 'afterMethod' to not be called - * when an exception is thrown in the 'beforeMethod' - this prevents the ExtentReport from producing a report - */ - - Report.log(Status.INFO, "Setting up..."); - LinkedMultiValueMap params = arrangeRequiredParams(); - String url = UriComponentsBuilder.fromHttpUrl(baseUrl).queryParams(params).build().toUriString(); - Report.log(Status.INFO, "Deleting cookies..."); - WebDriver driver = getDriver(); - driver.manage().deleteAllCookies(); - Report.log(Status.INFO, "Navigating to URL: %s", url); - driver.navigate().to(url); - Report.log(Status.INFO, "Checking if diverted to login page..."); - defaultTimeoutWait = new WebDriverWait(driver, defaultTimeout); - if (LoginPage.isCurrentPage(driver)) { - Report.log(Status.INFO, "Preforming login..."); - WebElement root = driver.findElement(By.cssSelector("body")); - LoginPage loginPage = new LoginPage(defaultTimeoutWait, root); - loginPage.login(getUserCredentials()); - Report.log(Status.INFO, "Refreshing..."); - driver.navigate().refresh(); // refresh fixes missing cookies after login - Report.log(Status.INFO, "Logged-in successfully."); - } else { - Report.log(Status.INFO, "Not in login page."); - } - Report.log(Status.INFO, "Setup done."); - } catch (Exception err) { - Report.fatal("Error during setup", err); - } - } - - protected LinkedMultiValueMap arrangeRequiredParams() throws Exception { - String userId = getUserCredentials().getUserId(); - DcaeEntityClient dcaeEntityClient = new DcaeEntityClient(); - Report.log(Status.INFO, "Creating vfcmt..."); - Vfcmt vfcmt = dcaeEntityClient.createVfcmt(userId); -// Report.log(Status.INFO, "Generating cdump of snmp (simulated drag of snmp component)..."); - String cdump = getFakeCdump(); - Report.log(Status.INFO, "Saving composition..."); - RestResponse saveResponse = DcaeRestClient.saveComposition(vfcmt.getUuid(), userId, cdump); - if (saveResponse.getStatusCode() != 200) { - throw new Exception("Save composition failed.\nDetails: " + saveResponse.toString()); - } - LinkedMultiValueMap params = new LinkedMultiValueMap(); - params.add("vfcmtUuid", vfcmt.getUuid()); - params.add("nodeName", "map"); - params.add("nodeId", "map"); - params.add("fieldName", "fake"); - params.add("userId", userId); - params.add("flowType", "FOI"); - return params; - } - - protected LinkedMultiValueMap arrangeFakeParams() { - LinkedMultiValueMap params = new LinkedMultiValueMap(); - params.add("vfcmtUuid", "aece8152-a97f-4ec4-9a42-941d8e586f97"); - params.add("nodeName", "map"); - params.add("nodeId", "map"); - params.add("fieldName", "fake"); - params.add("userId", "fakeo"); - params.add("flowType", "FOI"); - return params; - } - - private static String getFakeCdump() { - return "{\"nid\":\"map\"}"; - } - - protected UserRoleEnum getUserRole() - { - return UserRoleEnum.DESIGNER; - } - - @Override - protected Configuration getEnvConfiguration() { - return ConfigurationReader.getConfiguration(); - } - - @Override - protected UserCredentials getUserCredentials() { - try { - String userRole = getUserRole().name().toLowerCase(); - String credentialsFile = System.getProperty("credentials.file"); - if (credentialsFile == null) - credentialsFile = ConfigurationReader.confPath() + "credentials.yaml"; - File file = new File(credentialsFile); - if (!file.exists()){ - throw new Exception("Please provide a credentails file"); - } - Map credentialsParsedFile = FileHandling.parseYamlFile(credentialsFile); - Map credentialsMap = (Map) credentialsParsedFile.get(userRole); - String userId = (String) credentialsMap.get("username"); - String password = (String) credentialsMap.get("password"); - String firstname = (String) credentialsMap.get("firstname"); - String lastname = (String) credentialsMap.get("lastname"); - - return new UserCredentials(userId, password, firstname, lastname, null); - - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java deleted file mode 100644 index 22545b9..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor; - -import com.fasterxml.jackson.annotation.*; - -public class TranslateResult { - - public enum Status { - ok, - error - } - - private Status status; - private String data; - - @JsonCreator - public TranslateResult( - @JsonProperty("status") Status status, - @JsonProperty("data") String data) { - - this.status = status; - this.data = data; - } - - public Status getStatus() { - return status; - } - - public String getData() { - return data; - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java deleted file mode 100644 index c159af9..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -public class BaseComponenet { - - protected WebDriverWait wait; - protected WebElement root; - - public BaseComponenet(WebDriverWait timeout, WebElement element) { - this.wait = timeout; - this.root = element; - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java deleted file mode 100644 index 47ab468..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import static org.testng.Assert.fail; - -import java.util.Arrays; - -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.TranslateResult; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class HomePage extends BaseComponenet { - - public HomePage(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void waitForLoaderFinish() { - Report.log(Status.INFO, "Wait for loader finish..."); - ByTest loaderTestId = ByTest.id("loader"); - WebElement loader = wait.until(Locator.from(root).find(loaderTestId, 0)); // wait until loader appears - wait.until(ExpectedConditions.invisibilityOfAllElements(Arrays.asList(loader))); // wait until loader disappears - } - - public void load(String version, String eventType) { - Report.log(Status.INFO, "Selecting version..."); - select(ByTest.id("selectVersion"), version); - Report.log(Status.INFO, "Selecting event-type..."); - select(ByTest.id("selectEventType"), eventType); - } - - public RuleComponent getRule(int index) { - WebElement ruleElement = wait.until(Locator.from(root).findVisible(ByTest.id("ruleElement"), index)); - return new RuleComponent(wait, ruleElement); - } - - private WebElement getRulePopupElem() { - return wait.until(Locator.from(root).findVisible(ByTest.id("popupRuleEditor"), 0)); - } - - public WebElement getRoot() { - return root; - } - - public RulePopup clickAddFirstRule() { - Report.log(Status.INFO, "Clicking add-rule..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnAddFirstRule"), 0)).click(); - WebElement popupAddRule = getRulePopupElem(); - Report.log(Status.INFO, "Rule popup visible"); - return new RulePopup(wait, popupAddRule); - } - - public RulePopup clickAddMoreRule() { - Report.log(Status.INFO, "Clicking add-rule..."); - wait.until(Locator.from(root).findVisible(ByTest.id("addMoreRule"), 0)).click(); - WebElement popupAddRule = getRulePopupElem(); - Report.log(Status.INFO, "Rule popup visible"); - return new RulePopup(wait, popupAddRule); - } - - public void clickOnRuleDeleteConfirmPopup (){ - Report.log(Status.INFO, "Click on delete on popup confirmation"); - WebElement deletePopup = wait.until(Locator.from(root).findVisible(ByTest.id("delete-popup"), 0)); - wait.until(Locator.from(root).findVisible(ByTest.id("btnDelete"), 0)).click(); - waitForLoaderFinish(); - } - - public void clickTranslate() { - Report.log(Status.INFO, "Clicking Translate..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnTranslate"), 0)).click(); - waitForLoaderFinish(); - } - - public void clickCancel() { - Report.log(Status.INFO, "Clicking Cancel..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnCancel"), 0)).click(); - } - - public String getTranslation(WebDriver driver) throws Exception { - Report.log(Status.INFO, "Retriving translation result..."); - Object result = (Object) ((JavascriptExecutor) driver).executeScript("return window.translateResult;"); - ObjectMapper mapper = new ObjectMapper(); - TranslateResult parsedResult = mapper.convertValue(result, TranslateResult.class); - switch(parsedResult.getStatus()) { - case error: - fail(String.format("translate error: %s", parsedResult.getData())); - break; - case ok: - Report.logDebug("translation:", parsedResult.getData()); - return parsedResult.getData(); - } - throw new Exception(String.format("invalid status argument. expected (ok/error) but got %s", parsedResult.getData())); - } - - /* Private Methods */ - - private void select(ByTest by, String option) { - WebElement selectElement = wait.until(Locator.from(root).findVisible(by, 0)); - wait.until(Locator.from(selectElement).find(ByTest.id("option"), 0)); // wait for dynamic options - Select versionSelect = new Select(selectElement); - versionSelect.selectByVisibleText(option); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java deleted file mode 100644 index cc17481..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import org.openecomp.d2.ci.datatypes.UserCredentials; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class LoginPage extends BaseComponenet { - - public LoginPage(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void login(String userId, String password) { - Report.log(Status.INFO, "Filling input userid..."); - root.findElement(By.name("userid")).sendKeys(userId); - Report.log(Status.INFO, "Filling input password..."); - root.findElement(By.name("password")).sendKeys(password); - Report.log(Status.INFO, "Clicking submit..."); - root.findElement(By.name("btnSubmit")).click(); - Report.log(Status.INFO, "Waiting for login success page..."); - wait.until(ExpectedConditions.titleIs("AT&T - Log On Successful")); - Report.log(Status.INFO, "Clicking OK..."); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("successOK"))).click(); - } - - public void login(UserCredentials credentials) { - login(credentials.getUserId(), credentials.getPassword()); - } - - public static boolean isCurrentPage(WebDriver driver) { - return driver.getTitle().equals("AT&T Security Server: Login"); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java deleted file mode 100644 index 94bf547..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class RuleComponent extends BaseComponenet { - - public RuleComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public String getDescription(){ - Report.log(Status.INFO, "Get rule description"); - return root.getText(); - } - - public RulePopup clickEdit(WebDriver driver, WebElement homePageRoot){ - Report.log(Status.INFO, "Click on edit..."); - Actions action = new Actions(driver); - action.moveToElement(root).perform(); - wait.until(Locator.from(root).findVisible(ByTest.id("editRule"), 0)).click(); - WebElement rulePopupElem = wait.until(Locator.from(homePageRoot).findVisible(ByTest.id("popupRuleEditor"), 0)); - return new RulePopup(wait, rulePopupElem); - } - - public void clickDelete(WebDriver driver){ - Report.log(Status.INFO, "Click on delete..."); - Actions action = new Actions(driver); - action.moveToElement(root).perform(); - wait.until(Locator.from(root).findVisible(ByTest.id("deleteRule"), 0)).click(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java deleted file mode 100644 index 1cde952..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components; - -import java.util.Arrays; - -import org.apache.commons.lang3.NotImplementedException; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionType; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ConcatActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.CopyActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.MapActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.condition.ConditionComponent; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class RulePopup extends BaseComponenet { - - public RulePopup(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public String getDescription() { - Report.log(Status.INFO, "get input description..."); - return wait.until(Locator.from(root).findVisible(ByTest.id("inputDescription"), 0)).getAttribute("value"); - } - - public void setDescription(String text) { - Report.log(Status.INFO, "Filling input description..."); - wait.until(Locator.from(root).findVisible(ByTest.id("inputDescription"), 0)).sendKeys(text); - } - - public ActionComponent getAction(ActionType actionType, int index) { - WebElement actionElement = wait.until(Locator.from(root).findVisible(ByTest.id("action"), index)); - ActionComponent newActionComponent = createAction(actionType, wait, actionElement); - return newActionComponent; - } - - public CopyActionComponent addCopyAction(int index) { - return (CopyActionComponent) addAction(ActionType.Copy, index); - } - - public ConcatActionComponent addConcatAction(int index) { - return (ConcatActionComponent) addAction(ActionType.Concat, index); - } - - public MapActionComponent addMapAction(int index) { - return (MapActionComponent) addAction(ActionType.Map, index); - } - - public WebElement getErrorList(){ - return wait.until(Locator.from(root).findVisible(ByTest.id("errorList"), 0)); - } - - public void clickOnAddCondition(){ - wait.until(Locator.from(root).find(ByTest.id("isCondition"), 0)).click(); - } - - public void addSimpleCondition(){ - clickOnAddCondition(); - Report.log(Status.INFO, "Create and fill simple condition"); - ConditionComponent condition = new ConditionComponent(wait,root); - condition.setLeftField(0, "A"); - condition.setRightField(0, "B"); - condition.selectOperator(0, "Contains"); - } - - public void addComplexCondition(){ - Report.log(Status.INFO, "Click on add condition checkbox"); - clickOnAddCondition(); - Report.log(Status.INFO, "Create and fill top condition"); - ConditionComponent condition1 = new ConditionComponent(wait,root); - condition1.setLeftField(0, "A"); - condition1.setRightField(0, "B"); - condition1.selectOperator(0, "Contains"); - Report.log(Status.INFO, "Click on add group condition"); - wait.until(Locator.from(root).findVisible(ByTest.id("addConditionGroup"), 0)).click(); - Report.log(Status.INFO, "Create and fill first nested condition"); - ConditionComponent innerCondition1 = new ConditionComponent(wait,root); - condition1.setLeftField(1, "C"); - condition1.setRightField(1, "D"); - condition1.selectOperator(1, "Contains"); - Report.log(Status.INFO, "Create and fill second nested condition"); - ConditionComponent innerCondition2 = new ConditionComponent(wait,root); - condition1.setLeftField(2, "E"); - condition1.setRightField(2, "F"); - condition1.selectOperator(2, "Contains"); - } - - public void clickSave() { - Report.log(Status.INFO, "Clicking Save (changes on rule-editor)..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnSave"), 0)).click(); - waitForLoaderFinish(); - } - - public void clickCancel() { - Report.log(Status.INFO, "Clicking Cancel (changes on rule-editor)..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnCancel"), 0)).click(); - } - - - /* Private Methods */ - - private void waitForLoaderFinish() { - Report.log(Status.INFO, "Wait for loader finish..."); - ByTest loaderTestId = ByTest.id("loader"); - WebElement loader = root.findElement(loaderTestId); - wait.until(ExpectedConditions.invisibilityOfAllElements(Arrays.asList(loader))); // wait until loader disappears - } - - private ActionComponent addAction(ActionType actionType, int index) { - Report.log(Status.INFO, "Selecting action..."); - WebElement actionElement = wait.until(Locator.from(root).findVisible(ByTest.id("selectAction"), 0)); - Select actionSelect = new Select(actionElement); - actionSelect.selectByVisibleText(actionType.toString()); - Report.log(Status.INFO, "Clicking Add Action..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnAddAction"), 0)).click(); - return getAction(actionType, index); - } - - private static ActionComponent createAction(ActionType actionType, WebDriverWait wait, WebElement newActionElement) { - switch (actionType) { - case Concat: - return new ConcatActionComponent(wait, newActionElement); - case Copy: - return new CopyActionComponent(wait, newActionElement); - case Map: - return new MapActionComponent(wait, newActionElement); - default: - throw new IllegalArgumentException(String.format("action type '%s' not supported", actionType)); - } - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java deleted file mode 100644 index c12931a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class ActionComponent extends BaseComponenet { - - public ActionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void delete() { - Report.log(Status.INFO, "click on delete action"); - wait.until(Locator.from(root).findVisible(ByTest.id("deleteAction"), 0)).click(); - } - - public void setTarget(String target) { - Report.log(Status.INFO, "Filling input target..."); - getTargetElement().clear(); - getTargetElement().sendKeys(target); - } - - public void setTargetFromTree(){ - Report.log(Status.INFO, "Pick target from tree"); - wait.until(Locator.from(root).findVisible(ByTest.id("openTargetTree"), 0)).click(); - Report.log(Status.INFO, "Click on tree toggle"); - wait.until(Locator.from(root).findVisible(ByTest.cssSelector(".toggle-children-wrapper"),0)).click(); - Report.log(Status.INFO, "Click on first target node"); - wait.until(Locator.from(root).findVisible(ByTest.id("targetNode"), 1)).click(); - } - - public String getTarget() { - Report.log(Status.INFO, "get input target..."); - return getTargetElement().getAttribute("value"); - } - - /* Private Methods */ - - private WebElement getTargetElement() { - return wait.until(Locator.from(root).findVisible(ByTest.id("inputTarget"), 0)); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java deleted file mode 100644 index 4cb4a28..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -public enum ActionType { - Copy, - Concat, - Map -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java deleted file mode 100644 index 435441e..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.DeleteableFromComponent; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - - -public class ConcatActionComponent extends ActionComponent { - - public ConcatActionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public DeleteableFromComponent clickAddInput(int index) { - Report.log(Status.INFO, "Clicking on add input (another from)..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnAddInput"), 0)).click(); - return getFromComponent(index); - } - - public DeleteableFromComponent getFromComponent(int index) { - Report.log(Status.INFO, "Getting from component at index %d...", index); - WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), index)); - return new DeleteableFromComponent(wait, fromElement); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java deleted file mode 100644 index 3241ce6..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class CopyActionComponent extends ActionComponent { - - public CopyActionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public RegexFromComponent getFromComponent() { - Report.log(Status.INFO, "Getting fromComponent..."); - WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), 0)); - return new RegexFromComponent(wait, fromElement); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java deleted file mode 100644 index 37efe17..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.SimpleFromComponent; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class MapActionComponent extends ActionComponent { - - public MapActionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public SimpleFromComponent getFromComponent() { - Report.log(Status.INFO, "getting simple from component"); - WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), 0)); - return new SimpleFromComponent(wait, fromElement); - } - - public void openDefaultOption(){ - Report.log(Status.INFO, "open default opention by click on checkbox"); - wait.until(Locator.from(root).find(ByTest.id("defaultCheckbox"), 0)).click(); - } - - public void setDefaultData(String value){ - Report.log(Status.INFO, "set default field with a value"); - wait.until(Locator.from(root).findVisible(ByTest.id("defaultInput"), 0)).sendKeys(value); - } - - public void setKeyData(String value){ - Report.log(Status.INFO, "set map key with a value"); - wait.until(Locator.from(root).findVisible(ByTest.id("key"), 0)).sendKeys(value); - } - - public void setValueData(String value){ - Report.log(Status.INFO, "set map value with a value"); - wait.until(Locator.from(root).findVisible(ByTest.id("value"), 0)).sendKeys(value); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java deleted file mode 100644 index 4037419..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from; - -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class DeleteableFromComponent extends SimpleFromComponent { - - public DeleteableFromComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void clickDelete(WebDriver driver) { - Report.log(Status.INFO, "Click on delete from..."); - Actions action = new Actions(driver); - action.moveToElement(root).perform(); - wait.until(Locator.from(root).findVisible(ByTest.id("btnDelete"), 0)).click(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java deleted file mode 100644 index 159d0c9..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class RegexFromComponent extends SimpleFromComponent { - - public RegexFromComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void clickRegex() { - Report.log(Status.INFO, "Clicking regex button..."); - wait.until(Locator.from(root).findVisible(ByTest.id("btnFromRegex"), 0)).click(); - } - - public String getRegex() { - Report.log(Status.INFO, "Getting regex from..."); - return getRegexElement().getAttribute("value"); - } - - public void setRegex(String value) { - Report.log(Status.INFO, "Setting regex from..."); - getRegexElement().clear(); - getRegexElement().sendKeys(value); - } - - /* Private Methods */ - - private WebElement getRegexElement() { - return wait.until(Locator.from(root).findVisible(ByTest.id("inputFromRegex"), 0)); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java deleted file mode 100644 index a7cba3d..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class SimpleFromComponent extends BaseComponenet { - - public SimpleFromComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public String getValue() { - Report.log(Status.INFO, "Getting input from..."); - return getFromValueElement().getAttribute("value"); - } - - public void setValue(String value) { - Report.log(Status.INFO, "Setting input from..."); - getFromValueElement().clear(); - getFromValueElement().sendKeys(value); - } - - /* Private Methods */ - - private WebElement getFromValueElement() { - return wait.until(Locator.from(root).findVisible(ByTest.id("valueInput"), 0)); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java deleted file mode 100644 index 12ab277..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.components.condition; - -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.Select; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet; -import com.att.ecomp.dcae.ci.ui.utils.ByTest; -import com.att.ecomp.dcae.ci.ui.utils.Locator; - -public class ConditionComponent extends BaseComponenet{ - - public ConditionComponent(WebDriverWait timeout, WebElement element) { - super(timeout, element); - } - - public void setLeftField(int index, String value){ - WebElement left = wait.until(Locator.from(root).findVisible(ByTest.id("left"), index)); - left.clear(); - left.sendKeys(value); - } - - public void setRightField(int index, String value){ - WebElement right = wait.until(Locator.from(root).findVisible(ByTest.id("right"), index)); - right.clear(); - right.sendKeys(value); - } - - public void selectOperator(int index, String value){ - WebElement operatorElement = wait.until(Locator.from(root).findVisible(ByTest.id("selectOperator"), index)); - Select operatorSelect = new Select(operatorElement); - operatorSelect.selectByVisibleText(value); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java deleted file mode 100644 index 9f31ddd..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.rule_editor.tests; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.ui.rule_editor.BaseTest; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.HomePage; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.RuleComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.RulePopup; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionType; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ConcatActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.CopyActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.MapActionComponent; -import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public class SanityTest extends BaseTest { - - @Test - public void testTranslateOfSingleCopyAction() throws Exception { - WebDriver driver = getDriver(); - ExtentTestActions.log(Status.INFO, "test start"); - List findElements = driver.findElements(By.cssSelector("[data-tests-id*=\"map\" i]")); - - - WebElement appElement; - HomePage homePage = initHomePage(driver); - homePage.load("5.3", "syslog"); - setRule1(homePage.clickAddFirstRule()); - setRule2(homePage.clickAddMoreRule(), driver); - RulePopup editRule1 = homePage.getRule(0).clickEdit(driver, homePage.getRoot()); - validateRule1(editRule1); - editRule1 = homePage.getRule(0).clickEdit(driver, homePage.getRoot()); - editRule1(editRule1); - RuleComponent firstRuleinList = verifyRuleListDescription(homePage); - deleteRuleFromRuleList(driver, homePage, firstRuleinList); - translateRuleList(driver, homePage); - refreshAndVerifyGetRules(driver); - } - - private void refreshAndVerifyGetRules(WebDriver driver) { - Report.log(Status.INFO, "Refresh and verify getting rule list"); - HomePage homePage; - RuleComponent firstRuleinList; - driver.navigate().refresh(); - homePage = initHomePage(driver); - firstRuleinList = homePage.getRule(0); - assertThat(firstRuleinList.getDescription()).contains("Yanir Manor"); - } - - private void translateRuleList(WebDriver driver, HomePage homePage) throws Exception { - Report.log(Status.INFO, "Translate rule list"); - homePage.clickTranslate(); - String translation = homePage.getTranslation(driver); - assertThat(translation).isNotEmpty(); - } - - private void deleteRuleFromRuleList(WebDriver driver, HomePage homePage, RuleComponent firstRuleinList) { - Report.log(Status.INFO, "Delete the first rule from list"); - firstRuleinList.clickDelete(driver); - homePage.clickOnRuleDeleteConfirmPopup(); - } - - private RuleComponent verifyRuleListDescription(HomePage homePage) { - Report.log(Status.INFO, "Verify Rule List Description"); - RuleComponent firstRuleinList = homePage.getRule(0); - assertThat(firstRuleinList.getDescription()).contains("Oren Levi"); - return firstRuleinList; - } - - private HomePage initHomePage(WebDriver driver) { - WebElement appElement = driver.findElement(By.cssSelector("body")); - HomePage homePage = new HomePage(defaultTimeoutWait, appElement); - homePage.waitForLoaderFinish(); - return homePage; - } - - private void setRule1(RulePopup rulePopup) { - Report.log(Status.INFO, "Set first rule"); - rulePopup.setDescription("Oren Levi"); - CopyActionComponent copyAction = rulePopup.addCopyAction(0); - rulePopup.clickSave(); - WebElement errorList = rulePopup.getErrorList(); - assertThat(errorList.getText()).isNotEmpty(); - rulePopup.addSimpleCondition(); - RegexFromComponent fromComponent = copyAction.getFromComponent(); - fromComponent.setValue("Argentina"); - fromComponent.clickRegex(); - fromComponent.setRegex("*"); - copyAction.setTarget("Mexico"); - rulePopup.clickSave(); - } - - private void validateRule1(RulePopup rulePopup) { - Report.log(Status.INFO, "Validate first rule"); - assertThat(rulePopup.getDescription()).isEqualTo("Oren Levi"); - CopyActionComponent copyAction = (CopyActionComponent) rulePopup.getAction(ActionType.Copy, 0); - RegexFromComponent fromComponent = copyAction.getFromComponent(); - assertThat(fromComponent.getValue()).isEqualTo("Argentina"); - assertThat(fromComponent.getRegex()).isEqualTo("*"); - assertThat(copyAction.getTarget()).isEqualTo("Mexico"); - rulePopup.clickCancel(); - } - - private void editRule1(RulePopup rulePopup) { - Report.log(Status.INFO, "Edit first rule"); - CopyActionComponent copyAction = (CopyActionComponent) rulePopup.getAction(ActionType.Copy, 0); - RegexFromComponent fromComponent = copyAction.getFromComponent(); - fromComponent.setValue("Brazil"); - fromComponent.setRegex("**"); - copyAction.setTarget("Canada"); - rulePopup.clickSave(); - } - - private void setRule2(RulePopup rulePopup, WebDriver driver) { - Report.log(Status.INFO, "Set second rule"); - rulePopup.setDescription("Yanir Manor"); - - Report.log(Status.INFO, "Add complex condition"); - rulePopup.addComplexCondition(); - - Report.log(Status.INFO, "Add concat action"); - ConcatActionComponent concatAction = rulePopup.addConcatAction(0); - concatAction.getFromComponent(0).setValue("Oren"); - concatAction.getFromComponent(1).setValue("Levi"); - concatAction.clickAddInput(2).setValue("yanir"); - concatAction.getFromComponent(1).clickDelete(driver); - concatAction.setTargetFromTree(); - - Report.log(Status.INFO, "Add map action"); - MapActionComponent mapAction = rulePopup.addMapAction(1); - mapAction.getFromComponent().setValue("Mapfrom"); - mapAction.setTarget("MapTarget"); - mapAction.openDefaultOption(); - mapAction.setDefaultData("default data"); - mapAction.setKeyData("A"); - mapAction.setValueData("B"); - - rulePopup.clickSave(); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java deleted file mode 100644 index 1f6f59a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.setup; - -import java.io.File; -import java.util.Map; - -import org.openecomp.d2.ci.datatypes.Configuration; -import org.openecomp.d2.ci.datatypes.UserCredentials; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.setup.SetupCDTest; -import org.openecomp.d2.ci.utilities.FileHandling; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openecomp.d2.ci.utilities.LoginUtils; -import org.openqa.selenium.WebElement; -import org.testng.annotations.BeforeMethod; - -import com.att.ecomp.dcae.ci.utilities.ConfigurationReader; -import com.att.ecomp.dcae.ci.utilities.Report; -import com.aventstack.extentreports.Status; - -public abstract class ConfigTest extends SetupCDTest { - - protected abstract UserRoleEnum getUserRole(); - - @Override - protected Configuration getEnvConfiguration() { - return ConfigurationReader.getConfiguration(); - } - - @Override - protected UserCredentials getUserCredentials() { - try { - String userRole = getUserRole().name().toLowerCase(); - String credentialsFile = System.getProperty("credentials.file"); - if (credentialsFile == null) - credentialsFile = ConfigurationReader.confPath() + "credentials.yaml"; - File file = new File(credentialsFile); - if (!file.exists()){ - throw new Exception("Please provide a credentails file"); - } - Map credentialsParsedFile = FileHandling.parseYamlFile(credentialsFile); - Map credentialsMap = (Map) credentialsParsedFile.get(userRole); - String userId = (String) credentialsMap.get("username"); - String password = (String) credentialsMap.get("password"); - String firstname = (String) credentialsMap.get("firstname"); - String lastname = (String) credentialsMap.get("lastname"); - - UserCredentials userCredentials = new UserCredentials(userId, password, firstname, lastname, null); - Report.log(Status.INFO, "Using user Credentials="+userCredentials); - return userCredentials; - - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - @Override - protected void loginToLocalSimulator(UserCredentials user) { - LoginUtils.loginToLocalWebsealSimulator(user); - } - - @BeforeMethod - public void beforeTest(){ - try{ - if(getEnvConfiguration().getUrl().contains("localhost")) - { - GeneralUIUtils.ultimateWait(); - } - else - { - WebElement close = GeneralUIUtils.getWebElementByClassName("sdc-welcome-close"); - close.click(); - GeneralUIUtils.ultimateWait(); - } - } - catch(Exception e){ - Report.logDebug("Exception has occured in beforeTest - unable to proceed to test ", e); - e.printStackTrace(); - } - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java b/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java deleted file mode 100644 index 2eee2b4..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.setup; - -import org.openecomp.d2.ci.datatypes.Configuration; - -public class DcaeConfiguration extends Configuration { - - private String apiPath; - private String dcaeBeHost; - private String dcaeBePort; - private String ruleEditorUrl; - - - - public String getApiPath() { - return apiPath; - } - - public void setApiPath(String apiPath) { - this.apiPath = apiPath; - } - - public String getDcaeBeHost() { - return dcaeBeHost; - } - - public void setDcaeBeHost(String dcaeBeHost) { - this.dcaeBeHost = dcaeBeHost; - } - - public String getDcaeBePort() { - return dcaeBePort; - } - - public void setDcaeBePort(String dcaeBePort) { - this.dcaeBePort = dcaeBePort; - } - - public String getRuleEditorUrl() { - return ruleEditorUrl; - } - - public void setRuleEditorUrl(String ruleEditorUrl) { - this.ruleEditorUrl = ruleEditorUrl; - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java deleted file mode 100644 index b7f2441..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests; - -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.ui.pages.DCAECompositionPage; -import com.att.ecomp.dcae.ci.ui.pages.DCAEGeneralPage; -import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage; -import com.att.ecomp.dcae.ci.ui.pages.DCAELeftPanel; -import com.att.ecomp.dcae.ci.ui.pages.DCAEServicesPage; -import com.att.ecomp.dcae.ci.ui.pages.SDCCreateServicePage; -import com.att.ecomp.dcae.ci.ui.pages.SDCCreateVFPage; -import com.att.ecomp.dcae.ci.ui.pages.SDCHomePage; -import com.att.ecomp.dcae.ci.ui.setup.ConfigTest; -import com.att.ecomp.dcae.ci.ui.tests.verificator.ServiceVerificator; -import com.aventstack.extentreports.Status; - -public class DCAESanity extends ConfigTest{ - - @Override - protected UserRoleEnum getUserRole() { - // TODO Auto-generated method stub - return UserRoleEnum.DESIGNER; - } - - @Test (description = "DCAE Main scenario", groups={"Sanity"}) - public void sanityTestSDCSection() throws Exception - { - String vfName; - String serviceName; - - // ------------------ SDC-Side: Create VF -------------------------- - - System.out.println("Start Test"); - - SDCHomePage.clickOnAddVf(); - vfName = SDCCreateVFPage.addAllVFMandtoryFields("Utility"); //Creates VF, need to send only the desired category name - SDCCreateVFPage.clickOnCreateVFButton(); - SDCCreateVFPage.checkInVF(); - - // ------------------ SDC-Side: Create Service --------------------- - SDCHomePage.clickOnAddsService(); - serviceName = SDCCreateServicePage.addAllServiceMandtoryFields("Network L1-3"); - SDCCreateServicePage.clickOnCreateServiceButton(); - SDCCreateServicePage.clickOnServiceCompsitionTab(); - SDCCreateServicePage.addAssetToCanvas(vfName); - SDCCreateServicePage.checkInService(); - - // ------------------ DCAE-Side: Create Asset ------------------- - - DCAEHomePage.clickOnDcaeTab(); - DCAEHomePage.clickOnCreateNewAsset(); - - String assetName = DCAEGeneralPage.addAssetName("Asset Name"); - DCAEGeneralPage.addAssetDescription("Asset Description"); - DCAEGeneralPage.clickSaveAsset(); - - DCAELeftPanel.navigateToServices(); - - DCAEServicesPage.selectService(serviceName); - DCAEServicesPage.selectVNFI(vfName); - DCAEServicesPage.clickAttach(vfName); - - DCAELeftPanel.navigateToComposition(); - - WebElement item = DCAECompositionPage.expandList("Microservice"); - DCAECompositionPage.addItemFromList(item); - DCAECompositionPage.SelectFlowType("Syslog"); - DCAECompositionPage.clickSave(); - DCAECompositionPage.clickSubmit(); - - //------------------ Verify Blue Print - - SDCHomePage.clickOnHomeTab(); - SDCHomePage.searchForElement(serviceName); - SDCHomePage.clickOnElement(serviceName); - try - { - SDCCreateServicePage.clickOnServiceCompsitionTab(); - } - catch(Exception e) - { - GeneralUIUtils.getDriver().navigate().refresh(); - SDCCreateServicePage.clickOnServiceCompsitionTab(); - ExtentTestActions.log(Status.WARNING,"SDC UI known Bug - Blank page with text: {{getStatus()}}, the browser was refreshed to bypass this bug."); - } - - SDCCreateServicePage.clickOnElementInCanavs(); - SDCCreateServicePage.clickOnArtifactTab(); - ServiceVerificator.verifyBluePrintArtifactExist(assetName); - - ExtentTestActions.log(Status.INFO, "Test Ended."); - - System.out.println("End Test"); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java deleted file mode 100644 index a13a12e..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests; - -import org.openecomp.d2.ci.datatypes.Configuration; -import org.openecomp.d2.ci.datatypes.UserCredentials; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; -import com.att.ecomp.dcae.ci.ui.pages.DCAECompositionPage; -import com.att.ecomp.dcae.ci.ui.pages.DCAEGeneralPage; -import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage; -import com.att.ecomp.dcae.ci.ui.pages.DCAELeftPanel; -import com.att.ecomp.dcae.ci.ui.pages.DCAEServicesPage; -import com.att.ecomp.dcae.ci.ui.pages.SDCCreateServicePage; -import com.att.ecomp.dcae.ci.ui.pages.SDCCreateVFPage; -import com.att.ecomp.dcae.ci.ui.pages.SDCHomePage; -import com.att.ecomp.dcae.ci.ui.setup.ConfigTest; - -public class SanityTest extends ConfigTest{ - - - public Configuration configuration = ConfigTest.getConfiguration(); - - - @Override - protected UserRoleEnum getUserRole() { - return UserRoleEnum.DESIGNER; - } - - - // Only when running locally - @Override - public void navigateAndLogin(UserCredentials userCredentials) throws Exception { - - navigateToUrl(configuration.getUrl()); - } - - - @Test (description = "DCAE Main scenario", groups={"Sanity"}) - public void sanityTestDCAESection() throws InterruptedException{ - - //HomePage.clickOnDcaeTab(); // not needed on local - - - - - - - - ////------TO DELETE - String vfName; - String serviceName; - - // ------------------ SDC-Side: Create VF -------------------------- - - System.out.println("Start Test"); - - SDCCreateServicePage.clickOnElementInCanavs(); - - SDCHomePage.clickOnAddVf(); - vfName = SDCCreateVFPage.addAllVFMandtoryFields("Microservice"); //Creates VF, need to send only the desired category name - SDCCreateVFPage.clickOnCreateVFButton(); - SDCCreateVFPage.checkInVF(); - - // ------------------ SDC-Side: Create Service --------------------- - SDCHomePage.clickOnAddsService(); - serviceName = SDCCreateServicePage.addAllServiceMandtoryFields("Network L1-3"); - SDCCreateServicePage.clickOnCreateServiceButton(); - SDCCreateServicePage.clickOnServiceCompsitionTab(); - SDCCreateServicePage.addAssetToCanvas(vfName); - SDCCreateServicePage.checkInService(); - - - ////------TO DELETE - - - - - - - - - - - System.out.println("Start Test"); - - DCAEHomePage.clickOnCreateNewAsset(); - - DCAEGeneralPage.addAssetName("Asset Name"); - DCAEGeneralPage.addAssetDescription("Asset Description"); -// DCAEGeneralPage.clickSaveAsset(); - - DCAELeftPanel.navigateToServices(); - - DCAEServicesPage.selectService("Servicedbb463a1-50bb-4aef-b84c-8c2bb9a8f866"); - DCAEServicesPage.selectVNFI("VF30ca7676-35c5-4c3c-9cc8-a06c23b17872"); - DCAEServicesPage.clickAttach("VF30ca7676-35c5-4c3c-9cc8-a06c23b17872"); - - DCAELeftPanel.navigateToComposition(); - - WebElement item = DCAECompositionPage.expandList("Microservice"); - DCAECompositionPage.addItemFromList(item); - DCAECompositionPage.clickSave(); - DCAECompositionPage.clickSubmit(); - - System.out.println("End Test"); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java deleted file mode 100644 index bc99033..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests; - -import java.util.UUID; - -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; - -import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage; -import com.att.ecomp.dcae.ci.ui.setup.ConfigTest; - -public class ServiceTest extends ConfigTest { - - @Override - protected UserRoleEnum getUserRole() { - return UserRoleEnum.DESIGNER; - } - - @Test - public void createServiceTest(){ - DCAEHomePage.clickOnDcaeTab(); - - GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea"); - GeneralUIUtils.findByText("Add Service Assurance Template").click(); - GeneralUIUtils.ultimateWait(); - - WebElement nameTextbox = GeneralUIUtils.getWebElementByTestID("name"); - nameTextbox.clear(); - nameTextbox.sendKeys("autoServicer" + UUID.randomUUID()); - - WebElement descriptionTextbox = GeneralUIUtils.getWebElementByTestID("description"); - descriptionTextbox.clear(); - descriptionTextbox.sendKeys("new service"); - - GeneralUIUtils.findByText("Create").click(); - GeneralUIUtils.ultimateWait(); - } - - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java deleted file mode 100644 index 59faa2a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests.verificator; - -import static org.testng.Assert.assertTrue; - -public class CompositionVerificator { - - public static void verifySaveSuccessfully(String actualSaveRes) - { - assertTrue(actualSaveRes.startsWith("Composition Created")); - } - - public static void verifySubmitSuccessfully(String actualSubmitRes) { - assertTrue(actualSubmitRes.equalsIgnoreCase("Blueprint Created")); - - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java deleted file mode 100644 index 99957cf..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.tests.verificator; - -import org.openecomp.d2.ci.report.ExtentTestActions; -import org.openecomp.d2.ci.utilities.GeneralUIUtils; - -import com.aventstack.extentreports.Status; - -import static org.testng.Assert.assertTrue; - -public class ServiceVerificator -{ - public static void verifyBluePrintArtifactExist(String name) - { - ExtentTestActions.log(Status.INFO,"Verifying Blue Print artifact exist"); - String artifactName = "Foi" + "." + name.replaceAll("\\s+","").replaceAll("-", "") + ".event_proc_bp.yaml"; - GeneralUIUtils.waitForElementInVisibilityByTestId("artifactName-blueprint-foi"); - String actualBluePrintFileName = GeneralUIUtils.getWebElementByTestID("artifactName-blueprint-foi").getText(); - assertTrue(artifactName.equalsIgnoreCase(actualBluePrintFileName)); - ExtentTestActions.log(Status.INFO, String.format("Actual Blue print file name is: %s.", actualBluePrintFileName)); - GeneralUIUtils.ultimateWait(); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java deleted file mode 100644 index ab59b28..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.utils; - -import org.openqa.selenium.By.ByCssSelector; - -public class ByTest extends ByCssSelector { - - private static final long serialVersionUID = 7435597710732625685L; // auto generated - does nothing - - protected ByTest(String cssSelector) { - super(cssSelector); - } - - public static ByTest id(String id) { - return new ByTest(String.format("[data-tests-id=\"%s\"]", id)); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java deleted file mode 100644 index 7e625d5..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.utils; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -public class Locator { - - private WebElement element; - - private Locator(WebElement element) { - this.element = element; - } - - public static Locator from(WebElement element) { - return new Locator(element); - } - - public ExpectedCondition find(By by, int index) { - return new NestedFinder(this.element, by) { - @Override - protected WebElement predicate(List elements) { - return (elements.size() > index) ? elements.get(index) : null; - } - - @Override - public String toString() { - return "element located by " + by; - } - }; - } - - public ExpectedCondition findVisible(By by, int index) { - return new NestedFinder(this.element, by) { - @Override - protected WebElement predicate(List elements) { - return visibleElementsOrNull(elements, index); - } - - @Override - public String toString() { - return "visibility of element located by " + by; - } - }; - } - - public ExpectedCondition> findNoVisible(By by) { - return new NestedFilter(this.element, by) { - @Override - protected List predicate(List elements) { - WebElement visible = visibleElementsOrNull(elements, 0); - return (visible != null) ? null : new ArrayList(); - } - - @Override - public String toString() { - return "no visible elements located by " + by; - } - }; - } - - private static WebElement visibleElementsOrNull(List elements, int index) { - List visibles = elements.stream() - .filter(elem -> elem.isDisplayed()) - .collect(Collectors.toList()); - return (visibles.size() > index) ? visibles.get(index) : null; - } - - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java deleted file mode 100644 index 925fea5..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.utils; - -import java.util.List; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -public abstract class NestedFilter implements ExpectedCondition> { - - private WebElement parent; - private By by; - - public NestedFilter(WebElement parent, By by) { - this.parent = parent; - this.by = by; - } - - abstract protected List predicate(List elements); - - @Override - public List apply(WebDriver input) { - List elements = parent.findElements(by); - return predicate(elements); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java deleted file mode 100644 index ead2bef..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.att.ecomp.dcae.ci.ui.utils; - -import java.util.List; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -public abstract class NestedFinder implements ExpectedCondition { - - private WebElement parent; - private By by; - - public NestedFinder(WebElement parent, By by) { - this.parent = parent; - this.by = by; - } - - abstract protected WebElement predicate(List elements); - - @Override - public WebElement apply(WebDriver input) { - List elements = parent.findElements(by); - return predicate(elements); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/ConfigurationReader.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/ConfigurationReader.java deleted file mode 100644 index 1736d9a..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/ConfigurationReader.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import java.io.File; - -import org.openecomp.d2.ci.datatypes.Configuration; - -import com.att.ecomp.dcae.ci.ui.setup.DcaeConfiguration; - -public class ConfigurationReader { - - private static DcaeConfiguration config; - - public static DcaeConfiguration getConfiguration() { - if (config == null){ - File file = getConfigFile(); - config = Configuration.loadConfigFile(file, DcaeConfiguration.class); - } - return config; - } - - public static File getConfigFile() { - String configFile = System.getProperty("config.resource"); - if (configFile == null){ - configFile = configurationFile(); - } - File file = new File(configFile); - if (false == file.exists()) { - throw new RuntimeException("The config file " + configFile + " cannot be found."); - } - return file; - } - - private static String configurationFile() { - return confPath() + File.separator + "conf.yaml"; - } - - public static String confPath() { - return System.getProperty("user.dir") + File.separator + "src" + File.separator + "main" + File.separator + "resources" - + File.separator + "conf" + File.separator ; - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeEntityClient.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeEntityClient.java deleted file mode 100644 index c2a401d..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeEntityClient.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import org.openecomp.d2.ci.datatypes.devObjects.LifecycleStateEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.openecomp.d2.ci.report.ExtentTestActions; - -import com.aventstack.extentreports.Status; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import org.onap.sdc.dcae.composition.model.Requirement; -import org.onap.sdc.dcae.composition.model.Value; -import org.onap.sdc.dcae.composition.model.deserializer.RequirementDeserializer; -import org.onap.sdc.dcae.composition.model.deserializer.ValueDeserializer; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; - -public class DcaeEntityClient { - - protected Gson gson; - - public DcaeEntityClient() { - super(); - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapter(Requirement.class, new RequirementDeserializer()); - gsonBuilder.registerTypeAdapter(Value.class, new ValueDeserializer()); - gson = gsonBuilder.create(); - } - - /* VFCMT */ - - /** - * - * @param name - * @param description - * @param userId - * @return - * @throws Exception - */ - public Vfcmt createVfcmt(String name, String description, String userId) throws Exception { - RestResponse response = DcaeRestClient.createVfcmt(name, description, userId); - ExtentTestActions.log(Status.DEBUG, "Create VFCMT Response: " + StringUtils.truncate(response)); - if (response.getStatusCode() != 200) { - throw new Exception("Response: " + StringUtils.truncate(response)); - } - return gson.fromJson(response.getResponse(), Vfcmt.class); - } - - /** - * - * @param userId - * @return - * @throws Exception - */ - public Vfcmt createVfcmt(String userId) throws Exception { - String name = StringUtils.randomString("CI-", 20); - String description = "This vfcmt was created by automated ci tests"; - Vfcmt createVfcmt = createVfcmt(name, description, userId); - Report.log(Status.INFO, "createVfcmt result="+createVfcmt); - return createVfcmt; - } - - /** - * - * @return - * @throws Exception - */ - public Vfcmt createVfcmt() throws Exception { - return createVfcmt(DcaeRestClient.getDefaultUser().getUserId()); - } - - /** - * - * @return - * @throws Exception - */ - public Vfcmt[] getAllVfcmts() throws Exception { - ExtentTestActions.log(Status.INFO, "Fetching all vfcmt resources"); - RestResponse response = DcaeRestClient.getAllVfcmts(); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - if (response.getStatusCode() != 200) { - throw new Exception("Response: " + StringUtils.truncate(response)); - } - return gson.fromJson(response.getResponse(), Vfcmt[].class); - } - - /** - * - * @param userId - * @return - * @throws Exception - */ - public Vfcmt createCheckedoutVfcmt(String userId) throws Exception { - ExtentTestActions.log(Status.INFO, "Creating vfcmt..."); - Vfcmt vfcmt = createVfcmt(userId); - if (vfcmt.getLifecycleState().equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name()) == false) { - throw new Exception("created vfcmt is not in checkout state!"); - } - return vfcmt; - } - - /** - * - * @return - * @throws Exception - */ - public Vfcmt createCheckedoutVfcmt() throws Exception { - String userId = DcaeRestClient.getDefaultUser().getUserId(); - Report.log(Status.INFO, "Going to create checked out VFCMT with user="+userId); - return createCheckedoutVfcmt(userId); - } - - /** - * - * @param userId - * @return - * @throws Exception - */ - public Vfcmt createCheckedinVfcmt(String userId) throws Exception { - ExtentTestActions.log(Status.INFO, "Creating vfcmt"); - Vfcmt vfcmt = createVfcmt(userId); - ExtentTestActions.log(Status.INFO, "Checkin the vfcmt"); - RestResponse response = DcaeRestClient.checkinVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); - ExtentTestActions.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); - Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); - if (response.getStatusCode() != 200) { - throw new Exception("Unable to checkin newly created vfcmt"); - } - return vfcmtAfterCheckin; - } - - /** - * - * @return - * @throws Exception - */ - public Vfcmt createCheckedinVfcmt() throws Exception { - String userId = DcaeRestClient.getDefaultUser().getUserId(); - return createCheckedinVfcmt(userId); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeRestClient.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeRestClient.java deleted file mode 100644 index a776d20..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeRestClient.java +++ /dev/null @@ -1,247 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import com.att.ecomp.dcae.ci.ui.setup.DcaeConfiguration; -import com.aventstack.extentreports.Status; -import com.google.common.net.UrlEscapers; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import org.json.simple.JSONObject; -import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import org.openecomp.d2.ci.api.BaseRestUtils; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.datatypes.User; -import org.openecomp.d2.ci.datatypes.UserRoleEnum; -import org.openecomp.d2.ci.datatypes.http.RestResponse; - -import java.io.IOException; - -public class DcaeRestClient extends BaseRestUtils { - - private static User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - - public static User getDefaultUser() { - return defaultUser; - } - - protected static String getApiUrl(String path) { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - - String dcaeBePort = configuration.getDcaeBePort(); - String dcaeBeHost = configuration.getDcaeBeHost(); - String apiPath = configuration.getApiPath(); - if(System.getProperty("dcaeBeHost")!=null){ - dcaeBeHost = System.getProperty("dcaeBeHost"); - System.out.println("dcaeBeHost was configured via system property: "+dcaeBeHost); - } - if(System.getProperty("dcaeBePort")!=null){ - dcaeBePort = System.getProperty("dcaeBePort"); - System.out.println("dcaeBePort was configured via system property: "+dcaeBePort); - } - if(System.getProperty("apiPath")!=null){ - apiPath = System.getProperty("apiPath"); - System.out.println("apiPath was configured via system property: "+apiPath); - } - - return String.format("%s:%s%s%s", dcaeBeHost, dcaeBePort, apiPath, path); - } - - /* HealthCheck */ - - public static RestResponse getHealthcheck() throws IOException { - return sendGet(getApiUrl("/healthCheck"), null); - } - - /* VFCMT */ - - public static RestResponse getAllVfcmts() throws IOException { - return sendGet(getApiUrl("/getResourcesByCategory"), defaultUser.getUserId()); - } - - public static RestResponse getAllMonitoringTemplatesVfcmts() throws IOException { - return sendGet(getApiUrl("/getResourcesByMonitoringTemplateCategory"), defaultUser.getUserId()); - } - - public static RestResponse getVfcmtsForMigration(String contextType,String serviceUuid, String serviceVersion) throws IOException{ - - return sendGet(getApiUrl("/" + contextType + "/" + serviceUuid + "/" + serviceVersion + "/getVfcmtsForMigration"), defaultUser.getUserId()); - } - - public static RestResponse createVfcmt(String name, String description, String userId) throws IOException { - JSONObject newVfcmtJSON = newVfcmtJSON(name, description); - return sendPost(getApiUrl("/createVFCMT"), newVfcmtJSON.toString(), userId, "application/json"); - } - - public static RestResponse createMc(String request) throws IOException { - return sendPost(getApiUrl("/createMC"), request, defaultUser.getUserId(), "application/json"); - } - - public static RestResponse createMc(String request,String userId) throws IOException { - return sendPost(getApiUrl("/createMC"), request, userId, "application/json"); - } - - public static RestResponse createVfcmt(String name, String description) throws IOException{ - return createVfcmt(name, description, defaultUser.getUserId()); - } - - public static RestResponse importMc(String request) throws IOException { - return sendPost(getApiUrl("/importMC"), request, defaultUser.getUserId(), "application/json"); - } - - public static RestResponse getAttachedService(String vfcmtUuid) throws IOException { - Report.log(Status.INFO, "getAttachedService for VFCMT uuid="+vfcmtUuid); - RestResponse res = sendGet(getApiUrl("/" + vfcmtUuid + "/attachment"), defaultUser.getUserId()); - Report.log(Status.INFO, "getAttachedService result=%s", res); - return res; - } - - public static RestResponse getServiceExternalReferences(String serviceUuid, String version) throws IOException { - Report.log(Status.INFO, "getServiceExternalReferences for service uuid="+serviceUuid); - RestResponse res = sendGet(getApiUrl("/services/" + serviceUuid + "/" + version + "/monitoringComponents"), defaultUser.getUserId()); - Report.log(Status.INFO, "getServiceExternalReferences result=%s", res); - return res; - } - - /* VF */ - - public static RestResponse getServices(String VFCMTId, String userId) throws IOException{ - return sendGet(getApiUrl("/services/"+VFCMTId), userId); - } - - public static RestResponse getServicesInstance(String uuid) throws IOException{ - return sendGet(getApiUrl("/service/"+uuid), defaultUser.getUserId()); - } - - public static RestResponse attachVfiRef(String vfcmtUuid, String serviceId, String vfiName) throws IOException{ - Report.log(Status.INFO, "attachVfiRef start"); - JSONObject jsonAttachObj = new JSONObject(); - jsonAttachObj.put("serviceUuid", serviceId); - jsonAttachObj.put("instanceName", vfiName); - - return sendPost(getApiUrl("/" + vfcmtUuid + "/attachment"), jsonAttachObj.toString(), defaultUser.getUserId(), "application/json"); - } - - public static RestResponse getResourceDetails(String componentId) throws IOException{ - return sendGet(getApiUrl("/resource/"+ componentId), defaultUser.getUserId()); - } - - - public static RestResponse getElements() throws IOException{ - return sendGet(getApiUrl("/elements"), defaultUser.getUserId()); - } - public static RestResponse getItem(String element) throws IOException{ - return sendGet(getApiUrl("/"+ element +"/elements"), defaultUser.getUserId()); - } - public static RestResponse getItemModel(String elementId) throws IOException{ - return sendGet(getApiUrl("/"+ elementId +"/model"), defaultUser.getUserId()); - } - public static RestResponse getItemType(String elementId, String type) throws IOException{ - return sendGet(getApiUrl("/"+ elementId +"/type/"+ type +"/"), defaultUser.getUserId()); - } - public static RestResponse saveComposition(String componentId, String userId) throws IOException{ - JsonObject json = generateCdumpInput(componentId); - return saveComposition(componentId, userId, json.toString()); - } - - // edit composition new flow - service context - public static RestResponse saveComposition(String serviceUuid, String vfiName, String vfcmtUuid, String body) throws IOException{ - return sendPost(getApiUrl(String.format("/services/%s/%s/saveComposition/%s", serviceUuid, UrlEscapers.urlFragmentEscaper().escape(vfiName), vfcmtUuid)), body, defaultUser.getUserId(), "application/json"); - } - - // submit composition new flow - service context - public static RestResponse submitComposition(String serviceUuid, String vfiName, String vfcmtUuid) throws IOException { - return sendPost(getApiUrl(String.format("/services/createBluePrint/%s/%s/%s", vfcmtUuid, serviceUuid, UrlEscapers.urlFragmentEscaper().escape(vfiName))), "", defaultUser.getUserId(), "application/json"); - } - - public static RestResponse saveComposition(String componentId, String userId, String body) throws IOException{ - return sendPost(getApiUrl("/saveComposition/"+componentId), body, userId, "application/json"); - } - - public static RestResponse getComposition(String componentId) throws IOException{ - return sendGet(getApiUrl("/getComposition/"+ componentId), defaultUser.getUserId()); - } - public static RestResponse submitComposition(String componentId, String serviceUuid, String vnfiName, String monitoringType) throws IOException{ - return sendPost(getApiUrl("/createBluePrint/"+ componentId +"/"+ serviceUuid +"/"+ UrlEscapers.urlFragmentEscaper().escape(vnfiName) + "/"+ UrlEscapers.urlFragmentEscaper().escape(monitoringType)), "" ,defaultUser.getUserId(), "application/json"); - } - - /* Life Cycle */ - - public static RestResponse checkinVfcmt(String vfcmtUuid, String userId) throws IOException { - return checkinGeneral("vfcmt", vfcmtUuid, userId); - } - - public static RestResponse checkinGeneral(String assetType, String vfcmtUuid, String userId) throws IOException { - return sendPut(getApiUrl(String.format("/checkin/%s/%s", assetType, vfcmtUuid)), null, userId, null); - } - - public static RestResponse checkoutVfcmt(String vfcmtUuid, String userId) throws IOException { - return checkoutGeneral("vfcmt", vfcmtUuid, userId); - } - - private static RestResponse checkoutGeneral(String assetType, String vfcmtUuid, String userId) throws IOException { - return sendPut(getApiUrl(String.format("/checkout/%s/%s", assetType, vfcmtUuid)), null, userId, null); - } - - public static RestResponse certifyVfcmt(String vfcmtUuid, String userId) throws IOException { - return sendPut(getApiUrl(String.format("/certify/vfcmt/%s", vfcmtUuid)), null, userId, null); - } - - /* Rule Editor */ - - public static RestResponse getVesEventTypes() throws IOException { - return sendGet(getApiUrl("/rule-editor/list-events-by-versions"), defaultUser.getUserId()); - } - - public static RestResponse getVesDataTypes(String vesVersion, String eventType) throws IOException { - return sendGet(getApiUrl(String.format("/rule-editor/definition/%s/%s", vesVersion, eventType)), defaultUser.getUserId()); - } - - public static RestResponse saveRule(String vfcmtUid, String dcaeCompName, String nid, String configParam, String body) throws IOException { - return sendPost(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam)), body, defaultUser.getUserId(), "application/json" ); - } - - public static RestResponse getRules(String vfcmtUid, String dcaeCompName, String nid, String configParam) throws IOException { - return sendGet(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam)), defaultUser.getUserId()); - } - - public static RestResponse deleteRule(String vfcmtUid, String dcaeCompName, String nid, String configParam, String ruleUid) throws IOException { - return sendDelete(getApiUrl(String.format("/rule-editor/rule/%s/%s/%s/%s/%s", vfcmtUid, dcaeCompName, nid, configParam, ruleUid)), defaultUser.getUserId()); - } - - public static RestResponse translateRules(String vfcmtUid, String dcaeCompName, String nid, String configParam, String flowType) throws IOException { - return sendGet(getApiUrl(String.format("/rule-editor/rule/translate/%s/%s/%s/%s?flowType=%s", vfcmtUid, dcaeCompName, nid, configParam, flowType)), defaultUser.getUserId()); - } - - - private static JSONObject newVfcmtJSON(String name, String description) { - JSONObject json = new JSONObject(); - json.put("name", name); - json.put("description", description); - return json; - } - - public static void fillCreateMcRequestMandatoryFields(T request) { - request.setFlowType("flowType_xxx"); - request.setContextType("services"); - request.setName(StringUtils.randomString("CI-", 20)); - request.setDescription("create test vfcmt"); - if(null == request.getVfiName()) { - request.setVfiName("whatsInAName"); - } - if(null == request.getServiceUuid()) { - request.setServiceUuid("service5659860"); - } - } - - public static JsonObject generateCdumpInput(String componentId) { - JsonObject json = new JsonObject(); - json.addProperty("cid", componentId); - json.addProperty("version", 0); - json.add("nodes", new JsonArray()); - json.add("relations", new JsonArray()); - json.add("inputs", new JsonArray()); - json.add("outputs", new JsonArray()); - return json; - - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeTestConstants.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeTestConstants.java deleted file mode 100644 index 355a687..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeTestConstants.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -public class DcaeTestConstants { - - public class Composition{ - public static final String Microservice = "Microservice"; - public static final String EMPTY_OBJECT = "{}"; - } - - public class Sdc{ - public class State{ - public static final String NOT_CERTIFIED_CHECKOUT = "NOT_CERTIFIED_CHECKOUT"; - public static final String NOT_CERTIFIED_CHECKIN = "NOT_CERTIFIED_CHECKIN"; - public static final String CONFLICT = "Conflict"; - public static final String CERTIFIED = "CERTIFIED"; - - } - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeUtil.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeUtil.java deleted file mode 100644 index 9999b3d..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/DcaeUtil.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import com.google.gson.*; -import org.apache.commons.lang3.RandomStringUtils; - -import org.json.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.ParseException; -import org.openecomp.d2.ci.datatypes.http.RestResponse; -import org.testng.Assert; - -import com.att.ecomp.dcae.ci.entities.composition.items.DcaeComponents; -import org.onap.sdc.dcae.composition.services.Resource; -import org.onap.sdc.dcae.composition.services.Service; -import org.onap.sdc.dcae.composition.services.ThinService; -import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; -import com.aventstack.extentreports.Status; - - -public class DcaeUtil { - public static Gson gson = new Gson(); - - public static class CatalogReources { - public static Vfcmt[] getAllReourcesFromAsdc() throws IOException{ - RestResponse allResources = DcaeRestClient.getAllVfcmts(); - return gson.fromJson(allResources.getResponse(), Vfcmt[].class); - } - - public static Vfcmt getResourceByName(String resName) throws IOException{ - Vfcmt[] vfcmts = getAllReourcesFromAsdc(); - List vfcmtsStr = Arrays.stream(vfcmts). - filter(item -> item.getName().equals(resName)). - collect(Collectors.toList()); - - return vfcmtsStr.get(0); - } - - public static Vfcmt getOneResourceFromList(int index) throws IOException{ - Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); - return vfcmtList[index]; - } - - public static String getComponentID(int index) throws IOException{ - Vfcmt vfcmt = getOneResourceFromList(0); - return vfcmt.getUuid(); - } - - public static Resource createNewVfcmtObject() throws IOException{ - Resource res = new Resource(); - res.setResourceInstanceName("LiavNewVFCMT" + RandomStringUtils.randomAlphanumeric(20)); - res.setDescription("This is a test VFCMT"); - return res; - } - - public static Vfcmt notCheckoutVFCMT() throws IOException{ /* TODO: remove this function and use instead in DcaeEntityClient.getCheckedoutVfcmt() */ - Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); - List vfcmtsStr = Arrays.stream(vfcmtList). - filter(item -> (item.getLifecycleState().equals(DcaeTestConstants.Sdc.State.NOT_CERTIFIED_CHECKOUT) == false)). - collect(Collectors.toList()); - - return vfcmtsStr.get(0); - } - - public static Vfcmt vfcmtNotUserOwner(String user) throws IOException{ - Vfcmt[] vfcmtList = getAllReourcesFromAsdc(); - List vfcmtsStr = Arrays.stream(vfcmtList) - .filter(item -> (item.getLastUpdaterUserId().equals(user) == false)) - .collect(Collectors.toList()); - - return vfcmtsStr.get(0); - } - - } - - public static class Services{ - public static ThinService[] getServices(String VFCMTId, String userId) throws IOException{ - RestResponse services = null; - try{ - services = DcaeRestClient.getServices(VFCMTId, userId); - }catch(Exception e){ - System.err.println("Exception occurred while trying to fetch all resources from SDC: "+e); - return null; - } - Assert.assertTrue(services.getStatusCode().intValue() == 200); - String response = services.getResponse(); - ThinService[] serviceList = gson.fromJson(response, ThinService[].class); - return serviceList.length > 0 ? serviceList : null; - } - - public static ThinService getOneService(String VFCMTId,int index, String userId) throws IOException { - ThinService[] services = getServices(VFCMTId, userId); - return services[index]; - } - - - public static List getVfListInstance(ThinService thinService) throws IOException { - RestResponse serviceInstancRes = null; - try{ - serviceInstancRes = DcaeRestClient.getServicesInstance(thinService.getUuid()); - }catch(Exception e){ - System.err.println("Exception occurred while trying to fetch List of VF instances from SDC service ("+thinService+"). Exception: "+e); - return null; - } - Assert.assertTrue(serviceInstancRes.getStatusCode().intValue() == 200); - String serviceInstancList = serviceInstancRes.getResponse(); - Service service = gson.fromJson(serviceInstancList, Service.class); - return service.getResources(); - } - - public static Resource getOneVfInstance(ThinService thinService,int index) throws IOException { - List resources = getVfListInstance(thinService); - return resources.get(index); - } - - } - - - public static class SdcElementsModelType{ - public static RestResponse getMsElements() throws IOException{ - return DcaeRestClient.getItem(DcaeTestConstants.Composition.Microservice); - } - - - - public static JsonArray getSNMPModelItemFromSdc() throws Exception{ - RestResponse resMsElements = getMsElements(); - JsonParser jsonParser = new JsonParser(); - JsonObject responseJson = (JsonObject)jsonParser.parse(resMsElements.getResponse()); - JsonArray itemJsonArray = responseJson.get("data").getAsJsonObject().get("element").getAsJsonObject().get("items").getAsJsonArray(); - Report.logDebug("DCAE Components items", itemJsonArray); - Service[] services = gson.fromJson(itemJsonArray, Service[].class); - Report.log(Status.DEBUG, "Trying to find a certified VF which its name starts with supplement/map/enrich"); - List collectIds = Arrays.stream(services) - .filter(x -> x.getLifecycleState().equals("CERTIFIED") && x.getModels().size() > 0 && (x.getName().startsWith("supplement") || x.getName().startsWith("map") || x.getName().startsWith("enrich"))) - .map(Service::getUuid) - .collect(Collectors.toList()); - if(collectIds==null || collectIds.size()==0){ - Report.log(Status.ERROR, "Could find any SNMP DCAE Component"); - } - JsonArray models = new JsonArray(); - for (String id : collectIds) { - RestResponse res = DcaeRestClient.getItemModel(id); - models.addAll(parseNodesFromDcaeModelAndAssignUiNid(res.getResponse())); - } - - return models; - } - - public static RestResponse getItemModelFromSdc(int itemNumber) throws IOException{ - String uuid = getItemUuid(itemNumber); - return DcaeRestClient.getItemModel(uuid); - } - - public static String getItemUuid(int itemNumber) throws IOException{ - DcaeComponents dcaeComponents = getDcaeComponents(); - return dcaeComponents.getData().getElement().getItems().get(itemNumber).getUuid(); - } - - public static DcaeComponents getDcaeComponents() throws IOException{ - RestResponse services = getMsElements(); - String response = services.getResponse(); - return gson.fromJson(response, DcaeComponents.class); - } - } - - public static JsonArray parseNodesFromDcaeModelAndAssignUiNid(String response) throws ParseException { - JsonParser parser = new JsonParser(); - JsonObject data = parser.parse(response).getAsJsonObject().get("data").getAsJsonObject(); - JsonObject model = data.get("model").getAsJsonObject(); - JsonArray nodes = model.get("nodes").getAsJsonArray(); - nodes.forEach((n) -> - n.getAsJsonObject().add("nid", n.getAsJsonObject().get("name")) - ); - Report.logDebug("nodes after adding ui nid", nodes); - return nodes; - } - - public static String generateCdumpFromSnmpModels(String vfcmtId) throws Exception { - JsonArray snmpModelItemFromSdc = SdcElementsModelType.getSNMPModelItemFromSdc(); - JsonObject cdump = DcaeRestClient.generateCdumpInput(vfcmtId); - cdump.add("nodes", snmpModelItemFromSdc); - Report.logDebug("cdump", cdump); - return cdump.toString(); - } - - - - /* private JSONObject getServiceInstance(JSONObject service) throws IOException { - RestResponse serviceInstancRes = DcaeRestClient.getServicesInstance(service.get("uuid").toString()); - Assert.assertTrue(serviceInstancRes.getStatusCode().intValue() == 200); - String serviceInstancList = serviceInstancRes.getResponse(); - return (JSONObject) JSONValue.parse(serviceInstancList); -}*/ - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/Report.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/Report.java deleted file mode 100644 index f2fe6fb..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/Report.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import org.openecomp.d2.ci.report.ExtentTestActions; - -import com.aventstack.extentreports.Status; - -public class Report { - - public static void log(Status status, String format, Object... args) { - ExtentTestActions.log(status, String.format(format, args)); - } - - public static void logDebug(String message, Object obj) { - log(Status.DEBUG, "%s %s", message, wrapWithTextareaRO(obj.toString())); - } - - public static void fatal(String message, Exception err) { - log(Status.FATAL, "%s %s", message, wrapWithTextareaRO(err.toString())); - } - - /* Private members */ - - private static String wrapWithTextareaRO(String str) { - return String.format("", str); - } -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/SdcInternalApiClient.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/SdcInternalApiClient.java deleted file mode 100644 index 4adade1..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/SdcInternalApiClient.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import com.att.ecomp.dcae.ci.entities.composition.services.Vfi; -import com.att.ecomp.dcae.ci.entities.sdc.SdcComponent; -import com.att.ecomp.dcae.ci.entities.sdc.SdcComponentMetadata; -import com.att.ecomp.dcae.ci.ui.setup.DcaeConfiguration; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; -import org.openecomp.d2.ci.api.BaseRestUtils; -import org.openecomp.d2.ci.api.ElementFactory; -import org.openecomp.d2.ci.api.ServiceRestUtils; -import org.openecomp.d2.ci.api.VfRestUtils; -import org.openecomp.d2.ci.datatypes.*; -import org.openecomp.d2.ci.datatypes.http.RestResponse; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class SdcInternalApiClient extends BaseRestUtils { - - private static Gson gson = (new GsonBuilder()).create(); - private static User defaultUser = DcaeRestClient.getDefaultUser(); - - /** - * - * @return - * @throws Exception - */ - public static ServiceReqDetails createService() throws Exception { - ServiceReqDetails defaultService = ElementFactory.getDefaultService(); - RestResponse response = ServiceRestUtils.createService(defaultService, defaultUser); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 201) { - throw new Exception("Unable to create service.\nResponse: " + response.toString()); - } - return gson.fromJson(response.getResponse(), ServiceReqDetails.class); - } - - /** - * - * @return - * @throws Exception - */ - public static ResourceReqDetails createVf() throws Exception { - ResourceReqDetails defaultVf = ElementFactory.getDefaultResource(ResourceTypeEnum.VF); - RestResponse response = VfRestUtils.createResource(defaultVf, defaultUser); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 201) { - throw new Exception("Unable to create vf.\nResponse: " + response.toString()); - } - return gson.fromJson(response.getResponse(), ResourceReqDetails.class); - } - - /** - * - * @param vf - * @return - * @throws Exception - */ - public static ResourceReqDetails checkinVf(ResourceReqDetails vf) throws Exception { - RestResponse response = VfRestUtils.changeResourceState(vf, defaultUser, LifeCycleStatesEnum.CHECKIN); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 200) { - throw new Exception("Unable to checkin vf.\nResponse: " + response.toString()); - } - return gson.fromJson(response.getResponse(), ResourceReqDetails.class); - } - - /** - * - * @param service - * @param vf - * @return - * @throws Exception - */ - public static Vfi createVfi(ServiceReqDetails service, ResourceReqDetails vf) throws Exception { - RestResponse response = ServiceRestUtils.createComponentInstance(service, vf, defaultUser, ComponentTypeEnum.RESOURCE, true); - Report.logDebug("Response:", response); - if (response.getStatusCode() != 201) { - throw new Exception("Unable to create vfi.\nResponse: " + response.toString()); - } - try { - JsonObject resBody = new JsonParser().parse(response.getResponse()).getAsJsonObject(); - String vfiName = resBody.get("name").getAsString(); - return new Vfi(vfiName, service); - } catch (Exception err) { - throw new Exception(String.format("Unable to parse vfi name\nResponse: %s\n", response), err); - } - } - - // DELETE - Clean up // - - public static RestResponse deleteAssetFromSdc(String context, String uniqueId) throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/catalog/%s/%s", configuration.getBeHost(), configuration.getBePort(), context, uniqueId); - return sendDelete(url, ElementFactory.getDefaultUser(UserRoleEnum.ADMIN).getUserId()); - } - - public static RestResponse deleteMarkedResources() throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/inactiveComponents/resource", configuration.getBeHost(), configuration.getBePort()); - return sendDelete(url, ElementFactory.getDefaultUser(UserRoleEnum.ADMIN).getUserId()); - } - - public static RestResponse deleteMarkedServices() throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/inactiveComponents/service", configuration.getBeHost(), configuration.getBePort()); - return sendDelete(url, ElementFactory.getDefaultUser(UserRoleEnum.ADMIN).getUserId()); - } - - public static Map> getAssetsByUser(String userId) throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/followed", configuration.getBeHost(), configuration.getBePort()); - RestResponse restResponse = sendGet(url, userId); - return 200 == restResponse.getStatusCode() ? gson.fromJson(restResponse.getResponse(), new TypeToken>>(){}.getType()) : new HashMap<>(); - } - - - public static SdcComponentMetadata getAssetMetadata(String context, String uniqueId, String userId) throws IOException { - DcaeConfiguration configuration = ConfigurationReader.getConfiguration(); - String url = String.format("%s:%s/sdc2/rest/v1/catalog/%s/%s/filteredDataByParams?include=metadata", configuration.getBeHost(), configuration.getBePort(), context, uniqueId); - RestResponse restResponse = sendGet(url, userId); - return gson.fromJson(restResponse.getResponse(), SdcComponentMetadata.class); - } - -} diff --git a/src/main/java/com/att/ecomp/dcae/ci/utilities/StringUtils.java b/src/main/java/com/att/ecomp/dcae/ci/utilities/StringUtils.java deleted file mode 100644 index 90c5602..0000000 --- a/src/main/java/com/att/ecomp/dcae/ci/utilities/StringUtils.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.att.ecomp.dcae.ci.utilities; - -import org.apache.commons.lang3.RandomStringUtils; - -import com.google.common.base.Ascii; - -public class StringUtils { - - public static String randomString(String prefix, int length) { - return prefix + RandomStringUtils.randomAlphanumeric(length - prefix.length()); - } - - public static String truncate(Object obj) { - return Ascii.truncate(obj.toString(), 160, "..."); - } -} diff --git a/src/main/java/org/onap/dcae/ci/api/healthcheck/HealthcheckTest.java b/src/main/java/org/onap/dcae/ci/api/healthcheck/HealthcheckTest.java new file mode 100644 index 0000000..cce54bf --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/healthcheck/HealthcheckTest.java @@ -0,0 +1,59 @@ +package org.onap.dcae.ci.api.healthcheck; + +import com.aventstack.extentreports.Status; +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.restmodels.health.ComponentsInfo; +import org.onap.sdc.dcae.composition.restmodels.health.HealthResponse; + +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class HealthcheckTest extends DcaeRestBaseTest { + + @Test + public void getHealthcheck_statusOK() throws IOException { + Report.log(Status.INFO, "Starting Health Check test"); + RestResponse response = DcaeRestClient.getHealthcheck(); + Report.log(Status.INFO, "Health Check response=%s", response); + assertThat(response.getStatusCode().intValue()) + .as("response status") + .isEqualTo(200); + } + + @Test + public void getHealthcheck_validDataStructure() throws IOException { + Report.log(Status.INFO, "Starting getHealthcheck_validDataStructure"); + RestResponse response = DcaeRestClient.getHealthcheck(); + Report.log(Status.INFO, "Response=%s", response); + HealthResponse hcData = gson.fromJson(response.getResponse(), HealthResponse.class); + + SoftAssertions.assertSoftly(softly -> { + assertHealthStructure(softly, hcData, "DCAE Designer"); + List componentsInfo = hcData.getComponentsInfo(); + softly.assertThat(componentsInfo).extracting("healthCheckComponent").contains("BE", "TOSCA_LAB"); + assertHealthComponentStructure(softly, hcData.getComponentsInfo().get(0)); + assertHealthComponentStructure(softly, hcData.getComponentsInfo().get(1)); + }); + } + + private void assertHealthStructure(SoftAssertions softly, HealthResponse hcData, String name) { + softly.assertThat(hcData.getHealthCheckComponent()).isEqualTo(name); + softly.assertThat(hcData.getHealthCheckStatus()).isEqualTo("UP"); + softly.assertThat(hcData.getSdcVersion()).isNotEmpty(); + softly.assertThat(hcData.getDescription()).isNotEmpty(); + } + + private void assertHealthComponentStructure(SoftAssertions softly, ComponentsInfo hcData) { + softly.assertThat(hcData.getHealthCheckStatus()).isEqualTo("UP"); + softly.assertThat(hcData.getVersion()).isNotEmpty(); + softly.assertThat(hcData.getDescription()).isNotEmpty(); + } +} \ No newline at end of file diff --git a/src/main/java/org/onap/dcae/ci/api/tests/DcaeRestBaseTest.java b/src/main/java/org/onap/dcae/ci/api/tests/DcaeRestBaseTest.java new file mode 100644 index 0000000..6bd8b51 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/DcaeRestBaseTest.java @@ -0,0 +1,166 @@ +package org.onap.dcae.ci.api.tests; + +import com.aventstack.extentreports.Status; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.apache.commons.lang3.RandomStringUtils; +import org.onap.dcae.ci.config.Configuration; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.entities.composition.services.CiService; +import org.onap.dcae.ci.entities.composition.services.Vfi; +import org.onap.dcae.ci.entities.sdc.SdcComponent; +import org.onap.dcae.ci.entities.sdc.SdcResource; +import org.onap.dcae.ci.entities.sdc.SdcService; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.*; +import org.onap.sdc.dcae.composition.model.Requirement; +import org.onap.sdc.dcae.composition.model.Value; +import org.onap.sdc.dcae.composition.model.deserializer.RequirementDeserializer; +import org.onap.sdc.dcae.composition.model.deserializer.ValueDeserializer; +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.ActionDeserializer; +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.BaseAction; +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.BaseCondition; +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.ConditionDeserializer; +import org.onap.sdc.dcae.composition.services.Artifact; +import org.onap.sdc.dcae.composition.services.Resource; +import org.onap.sdc.dcae.composition.services.Service; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import org.testng.annotations.AfterSuite; + +import java.io.IOException; +import java.util.*; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; + + +public class DcaeRestBaseTest extends SetupReport { + + public static Gson gson = null; + protected DcaeEntityClient client = new DcaeEntityClient(); + + public DcaeRestBaseTest() { + super(); + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.registerTypeAdapter(Requirement.class, new RequirementDeserializer()); + gsonBuilder.registerTypeAdapter(Value.class, new ValueDeserializer()); + gsonBuilder.registerTypeAdapter(BaseAction.class, new ActionDeserializer()); + gsonBuilder.registerTypeAdapter(BaseCondition.class, new ConditionDeserializer()); + gson = gsonBuilder.create(); + } + + @Override + protected Configuration getEnvConfiguration() { + return ConfigurationReader.getConfiguration(); + } + + protected Service createServiceWithVFiAsSdcDesigner() throws IOException { + Report.log(Status.INFO, "Create Service with VFi as SDC Designer method started"); + + SdcResource vf = SdcInternalApiClient.createVf(); + vf = SdcInternalApiClient.checkinVf(vf); + SdcService service = SdcInternalApiClient.createService(); + Vfi vfi = SdcInternalApiClient.createVfi(service, vf); + return convertToDcaeServiceWithVfi(service, vfi.getName()); + + } + + + // converts from ui-api-ci object to dcae-ci object (partial construction) + private Service convertToDcaeServiceWithVfi(SdcService service, String vfiName){ + Service newService = new CiService(service); + Resource newVfi = new Resource(); + newVfi.setResourceInstanceName(vfiName); + newService.setResources(Arrays.asList(newVfi)); + return newService; + } + + protected Vfcmt createVfcmt() throws IOException { + String newName = "CI" + RandomStringUtils.randomAlphanumeric(4); + Report.log(Status.INFO, "createVfcmt start"); + RestResponse res = DcaeRestClient.createVfcmt(newName, "description"); + Report.log(Status.INFO, "createVfcmt response=%s", res); + assertThat(res.getStatusCode()).isEqualTo(200); + return gson.fromJson(res.getResponse(), Vfcmt.class); + } + + protected Artifact fetchVfcmtArtifactMetadataByName(String vfcmtUid, String artifactName) throws IOException { + Report.log(Status.INFO, "fetchVfcmtArtifactMetadataByName, vfcmtUid="+vfcmtUid+", artifactName"+artifactName); + RestResponse res = DcaeRestClient.getResourceDetails(vfcmtUid); + Resource vfcmt = gson.fromJson(res.getResponse(), Resource.class); + return vfcmt.getArtifacts().stream() + .filter(a -> artifactName.equalsIgnoreCase(a.getArtifactName())) + .findAny() + .orElse(null); + } + + //***** delete all assets created by test users - uses internal SDC API ****// + + @AfterSuite(alwaysRun = true) + public static void cleanup() throws IOException { + + final String resources = "resources"; + final String services = "services"; + List testUsers = Collections.synchronizedList(Arrays.asList(DcaeRestClient.getDefaultUserId(), DcaeRestClient.getDesigner2UserId())); + Map> testComponents = testUsers.parallelStream() + .map(DcaeRestBaseTest::getSafeComponentByUser) + .flatMap(m -> m.entrySet().stream()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (v1, v2) -> { + v1.addAll(v2); + return v1; + })); + collectAllResourceIds(Collections.synchronizedList(testComponents.get(resources))).parallelStream().forEach(id -> deleteAsset(resources, id)); + collectAllServiceIds(Collections.synchronizedList(testComponents.get(services))).parallelStream().forEach(id -> deleteAsset(services, id)); + SdcInternalApiClient.deleteMarkedResources(); + SdcInternalApiClient.deleteMarkedServices(); + } + + private static Set getUidsToDelete(String context, SdcComponent component) { + try { + return Arrays.asList("0.1", "1.0").contains(component.getVersion()) ? Collections.singleton(component.getUniqueId()) : + new HashSet<>(SdcInternalApiClient.getAssetMetadata(context, component.getUniqueId(), component.getLastUpdaterUserId()).getMetadata().getAllVersions().values()); + } catch (Exception e) { + Report.log(Status.ERROR, "failed to fetch sdc component: %s, Error: %s", component.getUniqueId(), e); + return Collections.emptySet(); + } + } + + private static Set collectAllResourceIds(List resources) { + Predicate deleteResource = p -> Arrays.asList("VF", "VFCMT").contains(p.getResourceType()) && !"Base Monitoring Template".equals(p.getCategories().get(0).getSubcategories().get(0).getName()); + Set resourceIds = Collections.synchronizedSet(resources.parallelStream() + .filter(deleteResource) + .map(r -> getUidsToDelete("resources", r)) + .flatMap(Set::stream) + .collect(Collectors.toSet())); + Report.log(Status.INFO, "collected %s resourceIds", resourceIds.size()); + return resourceIds; + } + + private static Set collectAllServiceIds(List services) { + Set serviceIds = Collections.synchronizedSet(services.parallelStream() + .map(c -> getUidsToDelete("services", c)) + .flatMap(Set::stream) + .collect(Collectors.toSet())); + Report.log(Status.INFO, "collected %s serviceIds", serviceIds.size()); + return serviceIds; + } + + private static Map> getSafeComponentByUser(String userId) { + try { + return SdcInternalApiClient.getAssetsByUser(userId); + } catch (Exception e){ + Report.log(Status.ERROR, "failed to fetch followed components. Error: %s", e); + return new HashMap<>(); + } + } + + private static void deleteAsset(String context, String id) { + try { + Report.log(Status.INFO, "about to delete sdc asset(%s): %s", context, id); + SdcInternalApiClient.deleteAssetFromSdc(context, id); + } catch (Exception e){ + Report.log(Status.ERROR, "failed to delete sdc asset(%s): %s, Error: %s" ,context, id, e); + } + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java b/src/main/java/org/onap/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java new file mode 100644 index 0000000..b5f37f8 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/blueprint/SaveCompositionPositve.java @@ -0,0 +1,109 @@ +package org.onap.dcae.ci.api.tests.blueprint; + +import com.aventstack.extentreports.Status; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.text.WordUtils; +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeUtil; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; +import org.onap.sdc.dcae.composition.services.Service; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +import org.testng.annotations.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class SaveCompositionPositve extends DcaeRestBaseTest { + + private RestResponse response; + private static final String VFCMT_NAME = "teSt.__.monitoring---TempLATE."; + + private Vfcmt createVFCMTAndServiceWithVFIAndAttach() throws Exception{ + Report.log(Status.INFO, "createVFCMTAndServiceWithVFIAndAttach start"); + Vfcmt newVfcmt = createNewVfcmt(); + + // create a service in sdc + Service newService = createServiceWithVFiAsSdcDesigner(); + + String serviceUuid = newService.getUuid(); + String vfiName = newService.getResources().get(0).getResourceInstanceName(); + String vfcmtId = newVfcmt.getUuid(); + + // attach VFCMT to vfi and service (creation of svc_reference file in the BE) + Report.log(Status.INFO, "Going to attach the created service and VFi to the VFCMT"); + RestResponse res = DcaeRestClient.attachVfiRef(vfcmtId, serviceUuid, vfiName); + Report.log(Status.INFO, "attachment result="+res); + + return newVfcmt; + } + + private Vfcmt createNewVfcmtWithoutArtifact() throws Exception{ + Report.log(Status.INFO, "createNewVfcmtWithoutArtifact"); + Vfcmt newVfcmt = createNewVfcmt(); + return newVfcmt; + } + + private Vfcmt createNewVfcmt() throws Exception { + String randomSuffix = WordUtils.capitalize(RandomStringUtils.randomAlphanumeric(4).toLowerCase()); + Vfcmt newVfcmt = createVfcmtInstance(randomSuffix); + return newVfcmt; + } + + private Vfcmt createVfcmtInstance(String randomSuffix) throws Exception{ + String newName = VFCMT_NAME + randomSuffix; + RestResponse res = DcaeRestClient.createVfcmt(newName,"description"); + assertThat(res.getStatusCode()).isEqualTo(200); + return gson.fromJson(res.getResponse(), Vfcmt.class); + } + + + + @Test + public void test_responseStatusOkAndCreateMode() throws Exception{ + // assert + Report.log(Status.INFO, "Save Composition init"); + Vfcmt vfcmtWithoutArtifactUuid = createNewVfcmtWithoutArtifact(); + String uuid = vfcmtWithoutArtifactUuid.getUuid(); + String lastUpdaterUserId = vfcmtWithoutArtifactUuid.getLastUpdaterUserId(); + response = DcaeRestClient.saveComposition(uuid, lastUpdaterUserId); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + Report.log(Status.INFO, "Verifing response status is 200"); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat((gson.fromJson(response.getResponse(), Resource.class)).getVersion()) + .as("version") + .isEqualTo("0.1"); + }); + } + + @Test + public void test_updateMode() throws Exception { + // assert + Report.log(Status.INFO, "Save Composition init"); + Vfcmt vfcmtWithArtifactUuid = createVFCMTAndServiceWithVFIAndAttach(); + String uuid = vfcmtWithArtifactUuid.getUuid(); + String lastUpdaterUserId = vfcmtWithArtifactUuid.getLastUpdaterUserId(); + Report.log(Status.INFO, "New VFCMT uuid="+uuid+", lastUpdaterUserId="+lastUpdaterUserId); + //generate cdump + String cdump = DcaeUtil.generateCdumpFromSnmpModels(uuid); + // save composition.yml + Report.log(Status.INFO, "Going to Save the composition now"); + DcaeRestClient.saveComposition(uuid, lastUpdaterUserId, cdump); + // update + response = DcaeRestClient.saveComposition(uuid, lastUpdaterUserId, cdump); + Report.log(Status.DEBUG, "Save composition Response: " + StringUtils.truncate(response)); + Report.log(Status.INFO, "Verifying response status is 200"); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat((gson.fromJson(response.getResponse(), Resource.class)).getVersion()) + .as("version") + .isEqualTo("0.3"); + }); + } + + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionControllerApiTests.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionControllerApiTests.java new file mode 100644 index 0000000..a6e1525 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionControllerApiTests.java @@ -0,0 +1,201 @@ +package org.onap.dcae.ci.api.tests.composition; + +import com.aventstack.extentreports.Status; +import com.google.gson.JsonObject; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.text.WordUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.json.simple.parser.ParseException; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeUtil; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.services.Artifact; +import org.onap.sdc.dcae.composition.services.Resource; +import org.onap.sdc.dcae.composition.services.Service; +import org.onap.sdc.dcae.composition.util.DcaeBeConstants; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CompositionControllerApiTests extends DcaeRestBaseTest { + + private static final String EVENT_PROC_BP_YAML = "event_proc_bp.yaml"; + private static final String CREATE_BLUEPRINT_DESCRIPTION = "creating new artifact blueprint on the service vfi"; + private static final String UPDATE_BLUEPRINT_DESCRIPTION = "updating artifact blueprint on the service vfi"; + private static final String VFCMT_NAME = "teSt.__.monitoring---TempLATE."; + private static final String NORMALIZED_VFCMT_NAME = "TestMonitoringTemplate"; + + @Test + public void createMultipleBlueprintsTest() throws Exception { + Report.log(Status.INFO, "createMultipleBlueprintsTest start"); + String randomSuffix = WordUtils.capitalize(RandomStringUtils.randomAlphanumeric(4).toLowerCase()); + Vfcmt newVfcmt = createVfcmt(randomSuffix); + + // create a service in sdc + Service newService = createServiceWithVFiAsSdcDesigner(); + + String serviceUuid = newService.getUuid(); + String vfiName = newService.getResources().get(0).getResourceInstanceName(); + String vfcmtId = newVfcmt.getUuid(); + + // attach VFCMT to vfi + Report.log(Status.INFO, "Trying to attach the service+vfi to the vfcmt. serviceUuid="+serviceUuid+", vfiName="+vfiName+", vfcmtId="+vfcmtId); + RestResponse res = DcaeRestClient.attachVfiRef(vfcmtId, serviceUuid, vfiName); + assertThat(res.getStatusCode()).isEqualTo(200); + + //generate and save composition.yml(cdump) + generateAndSaveCdump(vfcmtId); + + String bpType1 = "bpType t1"; + String bpType2 = "bpType T2"; + String normalizedVfcmtName = NORMALIZED_VFCMT_NAME + randomSuffix; + List> expectedBpDetails = Arrays.asList(buildBlueprintDetails(bpType1, normalizedVfcmtName), buildBlueprintDetails(bpType2, normalizedVfcmtName)); + + // submit - generate and save type1 blueprint artifact + Report.log(Status.INFO, "Going to Submit the composition with vfcmtId="+vfcmtId+", serviceUuid="+serviceUuid+", vfiName="+vfiName+", TYPE1="+bpType1); + res = DcaeRestClient.submitComposition(vfcmtId, serviceUuid, vfiName, bpType1); + assertBlueprintSuccessResponse(res); + + // 1806 US 374593 assert vfcmt is certified + res = DcaeRestClient.getResourceDetails(vfcmtId); + newVfcmt = gson.fromJson(res.getResponse(), Vfcmt.class); + Report.log(Status.INFO, "Checking lifecycle state of vfcmt after first blueprint submission. State = {}", newVfcmt.getLifecycleState()); + assertThat(newVfcmt.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.CERTIFIED.name()); + Report.log(Status.INFO, "Checking version of vfcmt after first blueprint submission. Version = {}", newVfcmt.getVersion()); + assertThat(newVfcmt.getVersion()).isEqualTo("1.0"); + + res = DcaeRestClient.checkoutVfcmt(vfcmtId, newVfcmt.getLastUpdaterUserId()); + newVfcmt = gson.fromJson(res.getResponse(), Vfcmt.class); + vfcmtId = newVfcmt.getUuid(); + // submit - generate and save type2 blueprint artifact + Report.log(Status.INFO, "Going to Submit the composition with vfcmtId="+vfcmtId+", serviceUuid="+serviceUuid+", vfiName="+vfiName+", TYPE2="+bpType2); + res = DcaeRestClient.submitComposition(vfcmtId, serviceUuid, vfiName, bpType2); + assertBlueprintSuccessResponse(res); + res = DcaeRestClient.getResourceDetails(vfcmtId); + newVfcmt = gson.fromJson(res.getResponse(), Vfcmt.class); + Report.log(Status.INFO, "Checking lifecycle state of vfcmt after checkout and second blueprint submission. State = {}", newVfcmt.getLifecycleState()); + assertThat(newVfcmt.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.CERTIFIED.name()); + Report.log(Status.INFO, "Checking version of vfcmt after checkout and second blueprint submission. Version = {}", newVfcmt.getVersion()); + assertThat(newVfcmt.getVersion()).isEqualTo("2.0"); + assertBlueprintsExistOnVfiAfterUpload(expectedBpDetails, serviceUuid, vfiName); + } + + + @Test + public void updateBlueprintTest() throws Exception { + Report.log(Status.INFO, "updateBlueprintTest start"); + String randomSuffix = WordUtils.capitalize(RandomStringUtils.randomAlphanumeric(4).toLowerCase()); + Vfcmt newVfcmt = createVfcmt(randomSuffix); + + // create a service in sdc + Service newService = createServiceWithVFiAsSdcDesigner(); + + String serviceUuid = newService.getUuid(); + String vfiName = newService.getResources().get(0).getResourceInstanceName(); + String vfcmtId = newVfcmt.getUuid(); + + // attach VFCMT to vfi + RestResponse res = DcaeRestClient.attachVfiRef(vfcmtId, serviceUuid, vfiName); + assertThat(res.getStatusCode()).isEqualTo(200); + + generateAndSaveCdump(vfcmtId); + + String normalizedVfcmtName = NORMALIZED_VFCMT_NAME + randomSuffix; + String bpType1 = "bpType 1"; + ImmutablePair expectedBpDetails = buildBlueprintDetails(bpType1, normalizedVfcmtName); + + // submit - generate and save type1 blueprint artifact + Report.log(Status.INFO, "Going to Submit the composition with vfcmtId="+vfcmtId+", serviceUuid="+serviceUuid+", vfiName="+vfiName+", bpType1="+bpType1); + res = DcaeRestClient.submitComposition(vfcmtId, serviceUuid, vfiName, bpType1); + assertBlueprintSuccessResponse(res); + // assert initial version exists + assertBlueprintExistsOnVfi(expectedBpDetails, serviceUuid, vfiName, CREATE_BLUEPRINT_DESCRIPTION); + + // submit - regenerate and save type1 blueprint artifact + Report.log(Status.INFO, "Going to Submit the composition with vfcmtId="+vfcmtId+", serviceUuid="+serviceUuid+", vfiName="+vfiName+", bpType1="+bpType1); + res = DcaeRestClient.submitComposition(vfcmtId, serviceUuid, vfiName, bpType1); + assertBlueprintSuccessResponse(res); + // assert blueprint updated + assertBlueprintExistsOnVfi(expectedBpDetails, serviceUuid, vfiName, UPDATE_BLUEPRINT_DESCRIPTION); + + } + + + private void assertBlueprintSuccessResponse(RestResponse response){ + assertThat(response.getStatusCode()).isEqualTo(200); + assertThat(DcaeUtil.getValueFromJsonResponse(response.getResponse(), "successResponse")).isNotNull(); + } + + private void assertBlueprintsExistOnVfiAfterUpload(List> expectedBpDetails, String serviceId, String vfiName) throws IOException{ + List vfiArtifact = fetchVfiArtifacts(serviceId, vfiName); + List> vfiArtifactDetails = vfiArtifact.stream() + .map(a -> new ImmutablePair<>(a.getArtifactLabel(), a.getArtifactName())) + .collect(Collectors.toList()); + for(ImmutablePair bp : expectedBpDetails){ + assertThat(vfiArtifactDetails).contains(bp); + } + } + + private void assertBlueprintExistsOnVfi(ImmutablePair expectedBpDetails, String serviceId, String vfiName, String description) throws IOException{ + List vfiArtifact = fetchVfiArtifacts(serviceId, vfiName); + Predicate artifactPredicate = p -> expectedBpDetails.getLeft().equals(p.getArtifactLabel()) && expectedBpDetails.getRight().equals(p.getArtifactName()) && description.equals(p.getArtifactDescription()); + Artifact artifact = vfiArtifact.stream() + .filter(artifactPredicate) + .findAny() + .orElse(null); + assertThat(artifact).isNotNull(); + } + + + private List fetchVfiArtifacts(String serviceId, String vfiName) throws IOException { + Report.log(Status.INFO, "fetchVfiArtifacts start"); + RestResponse serviceRes = DcaeRestClient.getServicesInstance(serviceId); + Report.log(Status.INFO, "fetchVfiArtifacts response=%s", serviceRes); + Service service = gson.fromJson(serviceRes.getResponse(), Service.class); + Resource vfi = service.getResources().stream() + .filter(p -> p.getResourceInstanceName().equals(vfiName)) + .findAny() + .orElse(null); + assertThat(vfi).isNotNull(); + return vfi.getArtifacts(); + } + + private ImmutablePair buildBlueprintDetails(String bpType, String normalizedVfcmtName) { + return new ImmutablePair<>("blueprint"+(bpType.replaceAll(" ", "")+normalizedVfcmtName).toLowerCase(),bpType.replaceAll(" ", "-")+"."+normalizedVfcmtName+"."+EVENT_PROC_BP_YAML); + } + + + private Vfcmt createVfcmt(String randomSuffix) throws IOException { + String newName = VFCMT_NAME + randomSuffix; + Report.log(Status.DEBUG, "createVfcmt start. VFCMT Name="+newName); + RestResponse res = DcaeRestClient.createVfcmt(newName,"description"); + Report.log(Status.DEBUG, "Create VFCMT response=%s", res); + assertThat(res.getStatusCode()).isEqualTo(200); + return gson.fromJson(res.getResponse(), Vfcmt.class); + } + + private void generateAndSaveCdump(String vfcmtId) throws ParseException, IOException { + Report.log(Status.DEBUG, "generateAndSaveCdump start"); + RestResponse res = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(0); + assertThat(res.getStatusCode()).isEqualTo(200); + JsonObject cdump = DcaeRestClient.generateCdumpInput(vfcmtId); + Report.log(Status.DEBUG, "Generated cdump="+cdump); + cdump.add("nodes", DcaeUtil.parseNodesFromDcaeModelAndAssignUiNid(res.getResponse())); + Report.log(Status.DEBUG, "save composition - generate and save composition.yml artifact"); + res = DcaeRestClient.saveComposition(vfcmtId, DcaeRestClient.getDefaultUserId(), cdump.toString()); + Report.log(Status.DEBUG, "Save composition result="+res); + assertThat(res.getStatusCode()).isEqualTo(200); + } + + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java new file mode 100644 index 0000000..0193df1 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionElementsControllerTests.java @@ -0,0 +1,200 @@ +package org.onap.dcae.ci.api.tests.composition; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.List; +import java.util.stream.Collectors; + +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; + +import org.onap.dcae.ci.entities.composition.rightMenu.element.Item; +import org.onap.dcae.ci.entities.composition.rightMenu.elements.Element; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.model.Model; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import com.aventstack.extentreports.Status; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; + +public class CompositionElementsControllerTests extends DcaeRestBaseTest { + + JsonParser parser = new JsonParser(); + + @Test + public void test_getAllElements() throws IOException{ + Report.log(Status.INFO, "test_getAllElements start"); + RestResponse response = DcaeRestClient.getElements(); + Report.log(Status.INFO, "getElements response=%s", response); + JsonElement getElementJsonResponse = getElementsJson(response); + Type listType = new TypeToken>(){}.getType(); + List responseData = gson.fromJson(getElementJsonResponse, listType); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat(getElementJsonResponse.toString()).isNotEmpty(); + softly.assertThat(responseData).extracting("itemId") + .containsExactlyInAnyOrder("Policy","Utility","Microservice","Database","Collector","Analytics","Source"); + }); + } + + + @DataProvider(name="item") + public static Object[][] allElementsItems() throws IOException{ + RestResponse response = DcaeRestClient.getElements(); + JsonElement getElementJsonResponse = getElementsJson(response); + Type listType = new TypeToken>(){}.getType(); + List responseData = gson.fromJson(getElementJsonResponse, listType); + return responseData + .stream() + .map(x -> new Object[]{ x.getItemId() } ) + .collect(Collectors.toList()) + .toArray(new Object[responseData.size()][1]); + } + + @Test(dataProvider ="item") + public void test_getAllElementsByItemId(String itemName) throws IOException{ + Report.log(Status.INFO, "test_getAllElementsByItemId start"); + RestResponse response = DcaeRestClient.getItem(itemName); + Report.log(Status.INFO, "getItem response=%s", response); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + }); + } + + @Test + public void test_getModelData() throws IOException{ + Report.log(Status.INFO, "test_getModelData start"); + RestResponse responseGetElements = DcaeRestClient.getElements(); + JsonElement obj = getElementsJson(responseGetElements); + String elementItemName = getElementItemName(obj); + + RestResponse responseElementsItem = DcaeRestClient.getItem(elementItemName); + JsonElement elementsById = parser.parse(responseElementsItem.getResponse()); + JsonElement itemData = elementsById.getAsJsonObject().get("data").getAsJsonObject().get("element").getAsJsonObject().get("items"); + + String elemId = getElementItemID(itemData); + Report.log(Status.INFO, "test_getModelData start"); + + RestResponse response = DcaeRestClient.getItemModel(elemId); + Report.log(Status.INFO, "getItemModel response=%s", response); + JsonElement responseJson = parser.parse(response.getResponse()); + JsonElement itemModelData = responseJson.getAsJsonObject().get("data").getAsJsonObject().get("model"); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat(itemModelData.toString()).isNotEmpty(); + }); + } + + @Test + public void test_getTypeData() throws IOException{ + Report.log(Status.INFO, "test_getTypeData start"); + RestResponse responseGetElements = DcaeRestClient.getElements(); + JsonElement obj = getElementsJson(responseGetElements); + String elementItemName = getElementItemName(obj); + + RestResponse responseElementsItem = DcaeRestClient.getItem(elementItemName); + JsonElement elementsById = parser.parse(responseElementsItem.getResponse()); + JsonElement itemData = elementsById.getAsJsonObject().get("data").getAsJsonObject().get("element").getAsJsonObject().get("items"); + + String elemId = getElementItemID(itemData); + RestResponse responseModel = DcaeRestClient.getItemModel(elemId); + JsonElement jsonRes = parser.parse(responseModel.getResponse()); + JsonElement jsonModel = jsonRes.getAsJsonObject().get("data").getAsJsonObject().get("model").getAsJsonObject(); + Model model = gson.fromJson(jsonModel, Model.class); + List nodesDataTypes = model.getNodes().stream() + .map(y -> y.getType()) + .collect(Collectors.toList()); + + nodesDataTypes.forEach(z -> Report.log(Status.INFO, "All types inside model: " + z)); + String nodeType = nodesDataTypes.get(0); + RestResponse response = DcaeRestClient.getItemType(elemId, nodeType); + JsonElement elementsById2 = parser.parse(response.getResponse()); + JsonElement data2 = elementsById2.getAsJsonObject().get("data").getAsJsonObject().get("type").getAsJsonObject(); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat(data2.toString()).isNotEmpty(); + }); + } + + /**************** nagative ***************/ + @Test + public void test_getAllElementsByNonExistItemId() throws IOException{ + Report.log(Status.INFO, "test_getAllElementsByNonExistItemId start"); + RestResponse response = DcaeRestClient.getItem("notExist"); + JsonElement elementsById = parser.parse(response.getResponse()); + JsonElement exception = elementsById.getAsJsonObject().get("error").getAsJsonObject().get("exception"); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat(exception.toString()).isNotEmpty(); + }); + } + + @Test + public void test_getErrorNonExistingModelData() throws IOException{ + Report.log(Status.INFO, "test_getErrorNonExistingModelData start"); + RestResponse response = DcaeRestClient.getItemModel("notExist"); + JsonElement elementsById = parser.parse(response.getResponse()); + JsonElement exception = elementsById.getAsJsonObject().get("error"); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(500); + softly.assertThat(exception.toString()).isNotEmpty(); + }); + } + + @Test + public void test_getErrorNonExistingItemType() throws IOException{ + Report.log(Status.INFO, "test_getErrorNonExistingItemType start"); + RestResponse response = DcaeRestClient.getItemType("notExistId","nonType"); + JsonElement elementsById = parser.parse(response.getResponse()); + JsonElement exception = elementsById.getAsJsonObject().get("error"); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(500); + softly.assertThat(exception.toString()).isNotEmpty(); + }); + } + + /******************** private ********************/ + private static JsonElement getElementsJson(RestResponse response) { + JsonParser parser = new JsonParser(); + JsonElement element = parser.parse(response.getResponse()); + JsonElement obj = element.getAsJsonObject().get("data").getAsJsonObject().get("elements"); + return obj; + } + + private String getElementItemName(JsonElement obj) { + Type listType = new TypeToken>(){}.getType(); + List fromJson = gson.fromJson(obj, listType); + List collect = fromJson.stream().filter(x->x.getName().equals("Microservice")).collect(Collectors.toList()); + Element element = collect.get(0); + String elementItemName = element.getName(); + return elementItemName; + } + + private String getElementItemID(JsonElement data) { + Type listType = new TypeToken>(){}.getType(); + List elementsItemFoi = gson.fromJson(data, listType); + Report.log(Status.INFO, "getElementItemID for map"); + List foiItemData = elementsItemFoi.stream().filter(x->x.getName().equalsIgnoreCase("map")).collect(Collectors.toList()); + if(foiItemData!=null && foiItemData.size()>0){ + Item item = foiItemData.get(0); + String elemId = item.getItemId(); + return elemId; + }else{ + Report.log(Status.ERROR, "getElementItemID for map failed. Does the CI environment has map component in it??"); + return null; + } + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java new file mode 100644 index 0000000..9808400 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/CompositionMicroServicesApiTests.java @@ -0,0 +1,90 @@ +package org.onap.dcae.ci.api.tests.composition; + +import static org.assertj.core.api.Assertions.*; + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeTestConstants; +import org.onap.dcae.ci.utilities.DcaeUtil; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.model.ModelDcae; +import org.testng.annotations.*; + +import java.io.IOException; + +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + + +import com.aventstack.extentreports.Status; + + +public class CompositionMicroServicesApiTests extends DcaeRestBaseTest { + + @Test + public void getAllElementsTest() throws IOException, ParseException{ + Report.log(Status.INFO, "getAllElementsTest start"); + RestResponse services = DcaeRestClient.getElements(); + Report.log(Status.INFO, "getAllElementsTest response=%s", services); + assertThat(services.getStatusCode().intValue()).isEqualTo(200); + String response = services.getResponse(); + JSONParser parser = new JSONParser(); + JSONObject o = (JSONObject) parser.parse(response); + JSONObject ele = (JSONObject) o.get("data"); + String arrString = ele.get("elements").toString(); + assertThat(arrString) + .as("Check that elements not empty") + .isNotEmpty(); + } + + @Test + public void getMsElementsTest() throws IOException, ParseException{ + Report.log(Status.INFO, "getMsElementsTest start"); + RestResponse services = DcaeUtil.SdcElementsModelType.getMsElements(); + Report.log(Status.INFO, "getMsElementsTest response=%s", services); + assertThat(services.getStatusCode().intValue()).isEqualTo(200); + String response = services.getResponse(); + JSONParser parser = new JSONParser(); + JSONObject o = (JSONObject) parser.parse(response); + JSONObject ele = (JSONObject) o.get("data"); + String arrString = ele.get("element").toString(); + assertThat(arrString) + .as("Check that elements not empty") + .isNotEmpty(); + } + + @Test + public void getItemModelTest() throws IOException{ + Report.log(Status.INFO, "getItemModelTest start"); + RestResponse itemModelRes = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(0); + Report.log(Status.INFO, "getItemModelTest response=%s", itemModelRes); + assertThat(itemModelRes.getStatusCode().intValue()).isEqualTo(200); + + String response = itemModelRes.getResponse(); + JSONObject object = (JSONObject) JSONValue.parse(response); + String errorMsg = object.get("error").toString(); + assertThat(errorMsg).isEqualTo(DcaeTestConstants.Composition.EMPTY_OBJECT); + } + + @Test + public void getItemTypeTest() throws IOException{ + Report.log(Status.INFO, "getItemModelTest start"); + RestResponse itemModelRes = DcaeUtil.SdcElementsModelType.getItemModelFromSdc(0); + Report.log(Status.INFO, "itemModelRes response=%s", itemModelRes); + String response = itemModelRes.getResponse(); + + String uuid = DcaeUtil.SdcElementsModelType.getItemUuid(0); + + ModelDcae model = gson.fromJson(response, ModelDcae.class); + Report.log(Status.INFO, "model "+model); + String type = model.getData().getModel().getNodes().get(0).getType(); + Report.log(Status.INFO, "type "+type); + + RestResponse services = DcaeRestClient.getItemType(uuid, type); + assertThat(services.getStatusCode().intValue()).isEqualTo(200); + } + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/composition/GetCompositionControllerTests.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/GetCompositionControllerTests.java new file mode 100644 index 0000000..169c5a8 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/GetCompositionControllerTests.java @@ -0,0 +1,105 @@ +package org.onap.dcae.ci.api.tests.composition; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.text.WordUtils; +import org.assertj.core.api.SoftAssertions; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeUtil; +import org.onap.dcae.ci.report.Report; +import org.testng.annotations.Test; + +import org.onap.sdc.dcae.composition.services.Service; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import com.aventstack.extentreports.Status; + +public class GetCompositionControllerTests extends DcaeRestBaseTest { + + private static final String VFCMT_NAME = "teSt.__.monitoring---TempLATE."; + + @Test + public void test_getComposition() throws Exception{ + Report.log(Status.INFO, "test_getComposition start"); + Vfcmt vfcmtWithArtifactUuid = createServiceAndVfiAndVfcmtAndAttach(); + String uuid = vfcmtWithArtifactUuid.getUuid(); + String lastUpdaterUserId = vfcmtWithArtifactUuid.getLastUpdaterUserId(); + Report.log(Status.INFO, "the created VFCMT uuid is:"+uuid+", going to save composition now"); + saveComposition(uuid, lastUpdaterUserId); + Report.log(Status.INFO, "Composition saved"); + + Report.log(Status.INFO, "Get Composition - execute"); + RestResponse response = DcaeRestClient.getComposition(uuid); + JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat(resData.get("successResponse").toString()).isNotEmpty(); + }); + } + + @Test + public void test_getCompositionNoArtifact() throws Exception{ + Report.log(Status.INFO, "test_getCompositionNoArtifact Get Composition - create vfcmt"); + + Vfcmt newVfcmt = createNewVfcmt(); + String uuid = newVfcmt.getUuid(); + + Report.log(Status.INFO, "Get Composition - execute"); + RestResponse response = DcaeRestClient.getComposition(uuid); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(204); + }); + } + + private void saveComposition(String uuid, String lastUpdaterUserId) throws Exception, IOException { + //generate cdump + String cdump = generateAndSaveCdump(uuid); + // save composition.yml + DcaeRestClient.saveComposition(uuid, lastUpdaterUserId, cdump); + } + + private Vfcmt createServiceAndVfiAndVfcmtAndAttach() throws Exception{ + Vfcmt newVfcmt = createNewVfcmt(); + + // create a service in sdc + Service newService = createServiceWithVFiAsSdcDesigner(); + + String serviceUuid = newService.getUuid(); + String vfiName = newService.getResources().get(0).getResourceInstanceName(); + String vfcmtId = newVfcmt.getUuid(); + + // attach VFCMT to vfi + RestResponse res = DcaeRestClient.attachVfiRef(vfcmtId, serviceUuid, vfiName); + + return newVfcmt; + } + + private Vfcmt createNewVfcmt() throws Exception { + String randomSuffix = WordUtils.capitalize(RandomStringUtils.randomAlphanumeric(4).toLowerCase()); + Vfcmt newVfcmt = createVfcmtInstance(randomSuffix); + return newVfcmt; + } + + private Vfcmt createVfcmtInstance(String randomSuffix) throws Exception{ + String newName = VFCMT_NAME + randomSuffix; + RestResponse res = DcaeRestClient.createVfcmt(newName,"description"); + assertThat(res.getStatusCode()).isEqualTo(200); + return gson.fromJson(res.getResponse(), Vfcmt.class); + } + private String generateAndSaveCdump(String vfcmtId) throws Exception{ + JsonArray snmpModelItemFromSdc = DcaeUtil.SdcElementsModelType.getSNMPModelItemFromSdc(); + JsonObject cdump = DcaeRestClient.generateCdumpInput(vfcmtId); + cdump.add("nodes", snmpModelItemFromSdc); + return cdump.toString(); + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java b/src/main/java/org/onap/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java new file mode 100644 index 0000000..566a028 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/composition/SaveAndSubmitCompositionFullFlowTest.java @@ -0,0 +1,116 @@ +package org.onap.dcae.ci.api.tests.composition; + + +import com.aventstack.extentreports.Status; +import com.google.gson.reflect.TypeToken; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; +import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; +import org.onap.sdc.dcae.composition.restmodels.MonitoringComponent; +import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; +import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed; +import org.onap.sdc.dcae.composition.services.Service; +import org.onap.sdc.dcae.composition.util.DcaeBeConstants; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SaveAndSubmitCompositionFullFlowTest extends DcaeRestBaseTest { + + private Resource baseTemplate = null; + + + @BeforeClass + public void setup() { + try { + Report.log(Status.INFO, "running before class - find a base template"); + Resource[] resources = gson.fromJson(DcaeRestClient.getAllMonitoringTemplatesVfcmts().getResponse(), Resource[].class); + if (resources.length > 0){ + baseTemplate = resources[0]; + } + } catch (Exception e) { + Report.log(Status.ERROR, e); + } + } + + + @Test + public void saveAndSubmitCompositionSuccessTest() throws IOException { + + CreateVFCMTRequest request = new CreateVFCMTRequest(); + // If you crashed here (below) it is because your environment has no Base Monitoring Templates + request.setTemplateUuid(baseTemplate.getUuid()); + Service service = createServiceWithVFiAsSdcDesigner(); + request.setVfiName(service.getResources().get(0).getResourceInstanceName()); + request.setServiceUuid(service.getUuid()); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); + + RestResponse response = DcaeRestClient.createMc(gson.toJson(request)); + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + + CreateMcResponse mcResponse = gson.fromJson(response.getResponse(), CreateMcResponse.class); + Report.log(Status.INFO, "Vfcmt created successfully. About to update composition"); + String initialUuid = mcResponse.getVfcmt().getUuid(); + response = DcaeRestClient.saveComposition(request.getServiceUuid(), request.getVfiName(), initialUuid, gson.toJson(mcResponse.getCdump())); + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + + ResourceDetailed mc = gson.fromJson(response.getResponse(), ResourceDetailed.class); + // the save action should check the mc out then in - promoting the version + assertThat(mc.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name()); + assertThat(mc.getVersion()).isEqualTo("0.2"); + + Report.log(Status.INFO, "About to submit the composition"); + response = DcaeRestClient.submitComposition(request.getServiceUuid(), request.getVfiName(), mc.getUuid()); + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + // the submit action should certify the mc. + Report.log(Status.INFO, "Save new composition version after submit"); + response = DcaeRestClient.saveComposition(request.getServiceUuid(), request.getVfiName(), initialUuid, gson.toJson(mcResponse.getCdump())); + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + // the save action should promote the mc version to 1.1 and create a new reference to it - both references should be kept at this point + mc = gson.fromJson(response.getResponse(), ResourceDetailed.class); + assertThat(mc.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name()); + assertThat(mc.getVersion()).isEqualTo("1.1"); + + response = DcaeRestClient.getServiceExternalReferences(service.getUuid(), service.getVersion()); + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + Report.log(Status.INFO, "Verify service vfi has references to both mc versions"); + Type typeToken = new TypeToken>>(){}.getType(); + Map> monitoringComponents = gson.fromJson(response.getResponse(), typeToken); + assertThat(monitoringComponents.get("monitoringComponents").size()).isEqualTo(2); + Report.log(Status.INFO, "About to re-submit the composition"); + response = DcaeRestClient.submitComposition(request.getServiceUuid(), request.getVfiName(), mc.getUuid()); + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + // a successful submission of the new version should result in the deletion of the previous reference + response = DcaeRestClient.getServiceExternalReferences(service.getUuid(), service.getVersion()); + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + monitoringComponents = gson.fromJson(response.getResponse(), typeToken); + List mcList = monitoringComponents.get("monitoringComponents"); + assertThat(mcList.size()).isEqualTo(1); + assertThat(mcList.get(0).getUuid()).isEqualTo(mc.getUuid()); + + } + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/deploy_tool/DeployToolTest.java b/src/main/java/org/onap/dcae/ci/api/tests/deploy_tool/DeployToolTest.java new file mode 100644 index 0000000..46836f2 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/deploy_tool/DeployToolTest.java @@ -0,0 +1,19 @@ +package org.onap.dcae.ci.api.tests.deploy_tool; + + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DeployToolTest extends DcaeRestBaseTest { + + @Test + public void verifyDeployToolVfcmtExist() throws Exception { + Vfcmt[] vfcmts = client.getAllBaseVfcmts(); + assertThat(vfcmts).isNotNull(); + assertThat(vfcmts.length).isGreaterThan(0); + } + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java new file mode 100644 index 0000000..a3631f8 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/ArrangeHelper.java @@ -0,0 +1,68 @@ +package org.onap.dcae.ci.api.tests.lifeCycle; + +import static org.assertj.core.api.Assertions.fail; + +import org.onap.dcae.ci.utilities.DcaeEntityClient; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +public class ArrangeHelper { + + private DcaeEntityClient client; + + public ArrangeHelper(DcaeEntityClient client) { + this.client = client; + } + + /** + * Tries to arrange checkedin vfcmt. + * If unable to do so, fails test with arrange error message + * @param userId - lastUpdater of the returned vfcmt + * @return checkedin vfcmt + */ + public Vfcmt getCheckedinVfcmt(String userId) { + Vfcmt vfcmt = null; + try { + vfcmt = client.createCheckedinVfcmt(userId); + } catch (Exception err) { + fail("could not arrange test: ", err); + } + return vfcmt; + } + + /** + * Tries to arrange checkedin vfcmt. + * If unable to do so, fails test with arrange error message + * @return checkedin vfcmt + */ + public Vfcmt getCheckedinVfcmt() { + String userId = DcaeRestClient.getDefaultUserId(); + return getCheckedinVfcmt(userId); + } + + /** + * Tries to arrange checkedout vfcmt. + * If unable to do so, fails test with arrange error message + * @param userId - lastUpdater of the returned vfcmt + * @return checkedout vfcmt + */ + public Vfcmt getCheckedoutVfcmt(String userId) { + Vfcmt vfcmt = null; + try { + vfcmt = client.createCheckedoutVfcmt(userId); + } catch (Exception err) { + fail("could not arrange test: ", err); + } + return vfcmt; + } + + /** + * Tries to arrange checkedout vfcmt. + * If unable to do so, fails test with arrange error message + * @return checkedout vfcmt + */ + public Vfcmt getCheckedoutVfcmt() { + String userId = DcaeRestClient.getDefaultUserId(); + return getCheckedoutVfcmt(userId); + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCertify.java b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCertify.java new file mode 100644 index 0000000..6fc6bbe --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCertify.java @@ -0,0 +1,34 @@ +package org.onap.dcae.ci.api.tests.lifeCycle; + + +import com.aventstack.extentreports.Status; +import org.assertj.core.api.SoftAssertions; + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import org.testng.annotations.Test; + +public class PutCertify extends DcaeRestBaseTest { + + private ArrangeHelper arrange = new ArrangeHelper(client); + + /* Positive */ + + @Test + public void certifyVfcmt_success() throws Exception { + // arrange + Vfcmt vfcmt = arrange.getCheckedinVfcmt(); + // act + Report.log(Status.INFO, "Calling certify vfcmt with lastUpdater as user (designer role)"); + RestResponse response = DcaeRestClient.certifyVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); + // assert + Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).isEqualTo(200); + softly.assertThat(vfcmtAfterCheckin.getLifecycleState()).isEqualTo("CERTIFIED"); + }); + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckin.java b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckin.java new file mode 100644 index 0000000..6866a0a --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckin.java @@ -0,0 +1,146 @@ +package org.onap.dcae.ci.api.tests.lifeCycle; + +import java.io.IOException; +import java.util.UUID; + +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; + +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.testng.annotations.*; +import static org.assertj.core.api.Assertions.*; + + +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +import com.aventstack.extentreports.Status; + +public class PutCheckin extends DcaeRestBaseTest { + + private ArrangeHelper arrange = new ArrangeHelper(client); + + /* Positive */ + + @Test + public void checkedoutVfcmt_success() throws Exception { + // arrange + Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); + // act + Report.log(Status.INFO, "Checkin the vfcmt with it's lastUpdater user"); + RestResponse response = checkinVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); + // assert + Vfcmt vfcmtAfterCheckin = gson.fromJson(response.getResponse(), Vfcmt.class); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).isEqualTo(200); + softly.assertThat(vfcmtAfterCheckin.getLifecycleState()).contains("CHECKIN"); + }); + } + + /* Negative */ + + @Test + public void alreadyCheckedinVfcmt_statusCode409() throws Exception { + // arrange + Vfcmt vfcmt = arrange.getCheckedinVfcmt(); + // act + Report.log(Status.INFO, "Checkin the vfcmt AGAIN with it's lastUpdater user"); + RestResponse response = checkinVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); + // assert + assertThat(response.getStatusCode()).isEqualTo(409); + } + + @Test + public void invalidVfcmtUuid_statusCode400() throws Exception { + // arrange + String userId = DcaeRestClient.getDefaultUserId(); + // act + Report.log(Status.INFO, "Checkin with an invalid-uuid as vfcmt-uuid"); + RestResponse response = checkinVfcmt("invalid-vfcmt-uuid", userId); + // assert + assertThat(response.getStatusCode()).isEqualTo(400); + } + + @Test + public void nonExistingUuid_statusCode409() throws Exception { + // arrange + String uuid = UUID.randomUUID().toString(); + String userId = DcaeRestClient.getDefaultUserId(); + // act + Report.log(Status.INFO, "Checkin with a non-existing vfcmt-uuid"); + RestResponse response = checkinVfcmt(uuid, userId); + // assert + assertThat(response.getStatusCode()).isEqualTo(409); + } + + @Test + public void nonExistingUser_statusCode403() throws Exception { + // arrange + Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); + // act + Report.log(Status.INFO, "Checkin with a non-existing user"); + RestResponse response = checkinVfcmt(vfcmt.getUuid(), "anonymus"); + // assert + assertThat(response.getStatusCode()).isEqualTo(403); + } + + @Test + public void notLastUser_statusCode403() throws Exception { + // arrange + String user1 = DcaeRestClient.getDefaultUserId(); + String user2 = DcaeRestClient.getDesigner2UserId(); + Vfcmt vfcmt = arrange.getCheckedoutVfcmt(user1); + // act + Report.log(Status.INFO, "Checkin the vfcmt with different user: " + user2); + RestResponse response = checkinVfcmt(vfcmt.getUuid(), user2); + // assert + assertThat(response.getStatusCode()).isEqualTo(403); + } + + @Test + public void invalidAssetType_statusCode400() throws Exception { + // arrange + String assetType = "kengero"; + String userId = DcaeRestClient.getDefaultUserId(); + Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); + // act + Report.log(Status.INFO, "Checkin the vfcmt with invalid asset-type"); + RestResponse response = checkinGeneral(assetType, userId, vfcmt); + // assert + assertThat(response.getStatusCode()).isEqualTo(400); + } + + + /* Private Methods */ + + /** + * Performs checkin on a general vfcmt, use this in test action + * @param assetType + * @param userId + * @param vfcmt + * @return + * @throws IOException + */ + private RestResponse checkinGeneral(String assetType, String userId, Vfcmt vfcmt) throws IOException { + RestResponse response = DcaeRestClient.checkinGeneral(assetType, vfcmt.getUuid(), userId); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + return response; + } + + /** + * Performs checkin on vfcmt, use this in test action + * @param vfcmtUuid + * @param userId + * @return + * @throws IOException + */ + private RestResponse checkinVfcmt(String vfcmtUuid, String userId) throws IOException { + RestResponse response = DcaeRestClient.checkinVfcmt(vfcmtUuid, userId); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + return response; + } + + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckout.java b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckout.java new file mode 100644 index 0000000..b8b7afc --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/lifeCycle/PutCheckout.java @@ -0,0 +1,148 @@ +package org.onap.dcae.ci.api.tests.lifeCycle; + +import java.io.IOException; +import java.util.UUID; + + +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; + +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.testng.annotations.*; +import static org.assertj.core.api.Assertions.*; + +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import com.aventstack.extentreports.Status; + +public class PutCheckout extends DcaeRestBaseTest { + + private ArrangeHelper arrange = new ArrangeHelper(client); + + /* Positive */ + + @Test + public void checkedinVfcmt_success() throws Exception { + // arrange + Vfcmt vfcmt = arrange.getCheckedinVfcmt(); + // act + Report.log(Status.INFO, "Checkout the vfcmt with it's lastUpdater user"); + RestResponse response = checkoutVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); + // assert + Vfcmt vfcmtAfterCheckout = gson.fromJson(response.getResponse(), Vfcmt.class); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).isEqualTo(200); + softly.assertThat(vfcmtAfterCheckout.getLifecycleState()).contains("CHECKOUT"); + }); + } + + @Test + public void notLastUser_success() throws Exception { + // arrange + String user1 = DcaeRestClient.getDefaultUserId(); + String user2 = DcaeRestClient.getDesigner2UserId(); + Vfcmt vfcmt = arrange.getCheckedinVfcmt(user1); + // act + Report.log(Status.INFO, "Checkout the vfcmt with different user: " + user2); + RestResponse response = checkoutVfcmt(vfcmt.getUuid(), user2); + // assert + Vfcmt vfcmtAfterCheckout = gson.fromJson(response.getResponse(), Vfcmt.class); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).isEqualTo(200); + softly.assertThat(vfcmtAfterCheckout.getLifecycleState()).contains("CHECKOUT"); + }); + } + + + /* Negative */ + + @Test + public void alreadyCheckedoutVfcmt_statusCode403() throws Exception { + // arrange + Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); + // act + Report.log(Status.INFO, "Checkout the vfcmt with it's lastUpdater user"); + RestResponse response = checkoutVfcmt(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); + // assert + assertThat(response.getStatusCode()).isEqualTo(403); + } + + @Test + public void invalidVfcmtUuid_statusCode400() throws Exception { + // arrange + String userId = DcaeRestClient.getDefaultUserId(); + // act + Report.log(Status.INFO, "Checkout with an invalid-uuid as vfcmt-uuid"); + RestResponse response = checkoutVfcmt("invalid-vfcmt-uuid", userId); + // assert + assertThat(response.getStatusCode()).isEqualTo(400); + } + + @Test + public void nonExistingUuid_statusCode409() throws Exception { + // arrange + String uuid = UUID.randomUUID().toString(); + String userId = DcaeRestClient.getDefaultUserId(); + // act + Report.log(Status.INFO, "Checkin with a non-existing vfcmt-uuid"); + RestResponse response = checkoutVfcmt(uuid, userId); + // assert + assertThat(response.getStatusCode()).isEqualTo(409); + } + + @Test + public void nonExistingUser_statusCode403() throws Exception { + // arrange + Vfcmt vfcmt = arrange.getCheckedinVfcmt(); + // act + Report.log(Status.INFO, "Checkin with a non-existing user"); + RestResponse response = checkoutVfcmt(vfcmt.getUuid(), "anonymus"); + // assert + assertThat(response.getStatusCode()).isEqualTo(403); + } + + @Test + public void invalidAssetType_statusCode400() throws Exception { + // arrange + String assetType = "kengero"; + String userId = DcaeRestClient.getDefaultUserId(); + Vfcmt vfcmt = arrange.getCheckedoutVfcmt(); + // act + Report.log(Status.INFO, "Checkout the vfcmt with invalid asset-type"); + RestResponse response = checkoutGeneral(assetType, userId, vfcmt); + // assert + assertThat(response.getStatusCode()).isEqualTo(400); + } + + + /* Private Methods */ + + /** + * Performs checkout on a general vfcmt/service and logs the response + * @param assetType + * @param userId + * @param vfcmt + * @return + * @throws IOException + */ + private RestResponse checkoutGeneral(String assetType, String userId, Vfcmt vfcmt) throws IOException { + RestResponse response = DcaeRestClient.checkinGeneral(assetType, vfcmt.getUuid(), userId); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + return response; + } + + /** + * Performs checkout on vfcmt and logs the response + * @param vfcmtUuid + * @param userId + * @return + * @throws IOException + */ + private RestResponse checkoutVfcmt(String vfcmtUuid, String userId) throws IOException { + RestResponse response = DcaeRestClient.checkoutVfcmt(vfcmtUuid, userId); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + return response; + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java new file mode 100644 index 0000000..154d952 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetDefinitionTest.java @@ -0,0 +1,138 @@ +package org.onap.dcae.ci.api.tests.ruleEditor; + +import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; + +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypeDefinitionUI; +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypesByVersionUI; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import com.aventstack.extentreports.Status; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; + +public class GetDefinitionTest extends DcaeRestBaseTest { + + @DataProvider(name = "EventTypes") + public static Object[][] getVesVersions() { + Gson gson = new GsonBuilder().create(); + try { + Report.log(Status.INFO, "Requesting VES event types"); + RestResponse response = DcaeRestClient.getVesEventTypes(); + Report.logDebug("Response", response); + if (response.getStatusCode() != 200) { + throw new Exception(response.toString()); + } + EventTypesByVersionUI[] eventsByVersionList = gson.fromJson(response.getResponse(), EventTypesByVersionUI[].class); + + return Arrays.stream(eventsByVersionList) + .flatMap(version -> version.getEventTypes().stream() + .map( event -> new Object[] {version.getVersion(), event} ) + ).toArray(Object[][]::new); + + } catch (Exception err) { + Report.log(Status.ERROR, "Unable to get ves event types\nException: %s", err.toString()); + return new Object[][] {}; + } + } + + + /* Positive */ + + @Test(dataProvider = "EventTypes") + public void testParameterized(String version, String eventType) throws Exception { + // arrange + + Report.log(Status.INFO, "testParameterized. version="+version+", eventType="+eventType); + + Gson gsonStrict = new GsonBuilder() + .registerTypeAdapter(EventTypeDefinitionUI.class, new StrictJsonDeserializer()) + .create(); + + // act + RestResponse response = DcaeRestClient.getVesDataTypes(version, eventType); + Report.logDebug("Response", response); + // assert + + EventTypeDefinitionUI[] resBody = gson.fromJson(response.getResponse(), EventTypeDefinitionUI[].class); + List resBodyFlat = flatten(Arrays.asList(resBody)); + Report.logDebug("resBodyFlat", gsonStrict.toJson(resBodyFlat)); + + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + + softly.assertThat(resBodyFlat).extracting("name").as("name") + .doesNotContain(StringUtils.EMPTY) + .doesNotContainNull(); + + softly.assertThat(resBodyFlat).extracting("id").as("id") + .doesNotContain(StringUtils.EMPTY) + .doesNotContainNull(); + }); + } + + + /* Negative */ + + + + + /* Private Methods */ + + public class StrictJsonDeserializer implements JsonDeserializer { + private Gson gson = new Gson(); + + @Override + public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + try { + Field[] declaredFields = Class.forName(typeOfT.getTypeName()).getDeclaredFields(); + Arrays.asList(declaredFields).stream() + .map(field -> field.getName()) + .forEach(fieldName -> { + if (json.getAsJsonObject().has(fieldName) == false) { + throw new JsonParseException(String.format("Missing field '%s'", fieldName)); + } + }); + } catch (SecurityException e) { + throw new JsonParseException("unable to parse", e); + } catch (ClassNotFoundException e) { + throw new JsonParseException("unable to parse", e); + } + return gson.fromJson(json, typeOfT); + } + + } + + + private List flatten(List events) { + List result = new ArrayList(); + events.stream().forEach(e -> { + List children = e.getChildren(); + result.add(e); // add this node + if (children != null) { + result.addAll(flatten(children)); // add child nodes recursively + } + }); + return result; + } + + /* Negative */ + + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java new file mode 100644 index 0000000..0764e34 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/GetListEventsAndVersionsTest.java @@ -0,0 +1,49 @@ +package org.onap.dcae.ci.api.tests.ruleEditor; + + +import org.apache.commons.collections4.SetUtils; +import org.apache.commons.lang3.StringUtils; +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; + +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.EventTypesByVersionUI; +import org.testng.annotations.Test; + +import com.aventstack.extentreports.Status; + +public class GetListEventsAndVersionsTest extends DcaeRestBaseTest { + + /* Positive */ + + @Test + public void test_successResponse() throws Exception { + // act + Report.log(Status.INFO, "test_successResponse: Requesting VES event types"); + RestResponse response = DcaeRestClient.getVesEventTypes(); + Report.logDebug("Response", response); + // assert + EventTypesByVersionUI[] resBody = gson.fromJson(response.getResponse(), EventTypesByVersionUI[].class); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + + softly.assertThat(resBody).as("response body").isNotEmpty(); + + softly.assertThat(resBody).extracting("version").as("version") + .doesNotContain(StringUtils.EMPTY) + .doesNotContainNull(); + + softly.assertThat(resBody).extracting("eventTypes").as("eventTypes list") + .doesNotContain(SetUtils.emptySet()) + .doesNotContainNull(); + softly.assertThat(resBody).flatExtracting("eventTypes").as("eventTypes list (flatten)") + .doesNotContainAnyElementsOf(EventTypesByVersionUI.DEFAULT_EVENTS) + .doesNotContain(StringUtils.EMPTY) + .doesNotContainNull(); + }); + } + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java new file mode 100644 index 0000000..45de16a --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/ruleEditor/RuleEditorControllerTest.java @@ -0,0 +1,353 @@ +package org.onap.dcae.ci.api.tests.ruleEditor; + + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.entities.rule_editor.SaveRuleError; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.services.Artifact; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import com.aventstack.extentreports.Status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonObject; +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.MappingRules; +import org.onap.sdc.dcae.composition.restmodels.ruleeditor.Rule; + +import org.testng.annotations.Test; +import org.assertj.core.api.SoftAssertions; + + +import static org.assertj.core.api.Assertions.assertThat; +import static org.testng.Assert.fail; + +import java.util.List; + +public class RuleEditorControllerTest extends DcaeRestBaseTest { + + private String ruleRequestBody = + "{version:4.1,eventType:syslogFields,description:newRule,actions:[{from:{value:fromField,regex:\"\"},target:event.commonEventHeader.target,id:id,actionType:copy}," + + "{actionType:concat,from:{values:[{value:concat1},{value:_concat2}]},target:concatTargetField},{actionType:copy,from:{value:extractFromHere,regex:\"([^:]*):.*\"},target:regexTargetField}," + + "{actionType:\"Log Text\",logText:{text:\"some text\",level:WARN}},{actionType:CLear,from:{values:[{value:first_input},{value:second_input}]}}," + + "{actionType:map,from:{value:fromField},target:mapTargetField,map:{values:[{key:sourceVal1,value:targetVal1},{key:sourceVal2,value:targetVal2}],haveDefault:true,default:'\"\"'}}," + + "{actionType:\"Date Formatter\",id:98908,from:{value:\"${dateFormatterFrom}\"},target:dateFormatterTarget,dateFormatter:{toTimezone:UVW,fromTimezone:XYZ,fromFormat:inputFormat,toFormat:outputFormat}}," + + "{actionType:\"Log Event\",id:465456,logEvent:{title:\"some log title\"}},{actionType:\"Replace Text\",from:{value:fromField},replaceText:{find:findText,replace:replacement}}]," + + "condition:{left:\"${leftOperand}\",operator:contains,right:[rightOperand1,rightOperand2]}}"; + + @Test + public void saveNewMappingRulesArtifactSuccessTest() throws Exception { + Report.log(Status.INFO, "test start"); + Vfcmt vfcmt = createVfcmt(); + RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "n.1.map", "param1", ruleRequestBody); + JsonObject jsonRes = gson.fromJson(res.getResponse(), JsonObject.class); + assertThat(jsonRes.get("version").getAsString()).isEqualTo("4.1"); + assertThat(jsonRes.get("eventType").getAsString()).isEqualTo("syslogFields"); + assertThat(jsonRes.get("uid")).isNotNull(); + String expectedArtifactName = "map_n.1.map_param1_MappingRules.json"; + Artifact savedArtifact = fetchVfcmtArtifactMetadataByName(vfcmt.getUuid(), expectedArtifactName); + assertThat(savedArtifact).isNotNull(); + } + + @Test + public void translateSnmpMappingRuleWithAllActionTypesSuccessTest() throws Exception { + String expectedTranslation = "{\"processing\":[{\"phase\":\"snmp_map\",\"processors\":[{\"array\":\"varbinds\",\"datacolumn\":\"varbind_value\",\"keycolumn\":\"varbind_oid\",\"class\":\"SnmpConvertor\"}," + + "{\"phase\":\"%s\",\"class\":\"RunPhase\"}]},{\"phase\":\"%s\",\"filter\":{\"filters\":[{\"string\":\"${leftOperand}\",\"value\":\"rightOperand1\",\"class\":\"Contains\"}," + + "{\"string\":\"${leftOperand}\",\"value\":\"rightOperand2\",\"class\":\"Contains\"}],\"class\":\"Or\"}," + + "\"processors\":[{\"updates\":{\"event.commonEventHeader.target\":\"fromField\",\"concatTargetField\":\"concat1_concat2\"},\"class\":\"Set\"}," + + "{\"regex\":\"([^:]*):.*\",\"field\":\"regexTargetField\",\"value\":\"extractFromHere\",\"class\":\"ExtractText\"}," + + "{\"logLevel\":\"WARN\",\"logText\":\"some text\",\"class\":\"LogText\"},{\"fields\":[\"first_input\",\"second_input\"],\"class\":\"Clear\"}," + + "{\"map\":{\"sourceVal1\":\"targetVal1\",\"sourceVal2\":\"targetVal2\"},\"field\":\"fromField\",\"toField\":\"mapTargetField\",\"default\":\"\",\"class\":\"MapAlarmValues\"}," + + "{\"fromFormat\":\"inputFormat\",\"fromTz\":\"XYZ\",\"toField\":\"dateFormatterTarget\",\"toFormat\":\"outputFormat\",\"toTz\":\"UVW\",\"value\":\"${dateFormatterFrom}\",\"class\":\"DateFormatter\"}," + + "{\"title\":\"some log title\",\"class\":\"LogEvent\"},{\"field\":\"fromField\",\"find\":\"findText\",\"replace\":\"replacement\",\"class\":\"ReplaceText\"}]}," + + "{\"phase\":\"%s\",\"processors\":[{\"phase\":\"snmp_publish\",\"class\":\"RunPhase\"}]}]}"; + Vfcmt vfcmt = createVfcmt(); + String name = vfcmt.getName(); + saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); + RestResponse res = DcaeRestClient.translateRules(vfcmt.getUuid(),"map", "map", "param1", "SNMP MSE"); + Report.log(Status.INFO, "translateRules response= "+res); + assertThat(res.getStatusCode()).isEqualTo(200); + assertThat(res.getResponse()).isEqualTo(String.format(expectedTranslation, name, name, name)); + } + + @Test + public void addNewRuleToExistingArtifact() throws Exception { + Vfcmt vfcmt = createVfcmt(); + String nid = "n.565663636.0"; + RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", nid, "param1", ruleRequestBody); + Rule rule1 = gson.fromJson(res.getResponse(), Rule.class); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", nid, "param1", ruleRequestBody); + Report.log(Status.INFO, "saveRule response= "+res); + Rule rule2 = gson.fromJson(res.getResponse(), Rule.class); + RestResponse responseGetRules = DcaeRestClient.getRules(vfcmt.getUuid(),"map", nid, "param1"); + Report.log(Status.INFO, "getRules response= "+responseGetRules); + MappingRules rules = gson.fromJson(responseGetRules.getResponse(), MappingRules.class); + Report.log(Status.INFO, "MappingRules="+responseGetRules.getResponse()); + assertThat(rules.getRules()).hasSize(2); + assertThat(rules.getRules().keySet()).containsOnly(rule1.getUid(), rule2.getUid()); + } + + @Test + public void editExistingRuleInArtifact() throws Exception{ + Vfcmt vfcmt = createVfcmt(); + String updated = "This is an update"; + RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); + Rule rule = gson.fromJson(res.getResponse(), Rule.class); + Report.log(Status.INFO, "save rule response=%s", res.getResponse()); + res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); + Report.log(Status.INFO, "getRules3 response= "+res); + MappingRules rules = gson.fromJson(res.getResponse(), MappingRules.class); + Report.log(Status.INFO, "MappingRules1="+res.getResponse()); + assertThat(rules.getRules().get(rule.getUid()).getDescription()).isEqualTo("newRule"); + assertThat(rules.getRules().keySet()).containsOnly(rule.getUid()); + rule.setDescription(updated); + DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", rule.toJson()); + Report.log(Status.INFO, "saveRule response= "+res); + res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); + Report.log(Status.INFO, "getRules2 response= "+res); + rules = gson.fromJson(res.getResponse(), MappingRules.class); + Report.log(Status.INFO, "MappingRules2="+res.getResponse()); + assertThat(rules.getRules()).hasSize(1); + assertThat(rules.getRules().get(rule.getUid()).getDescription()).isEqualTo(updated); + } + + @Test + public void editRuleInArtifactNoSuchIdErrorTest() throws Exception { + String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6036\",\"text\":\"Error - Failed to save rule. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Error - Failed to save rule. Internal persistence error\"}},\"notes\":\"\"}"; + Vfcmt vfcmt = createVfcmt(); + RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); + Rule rule = gson.fromJson(res.getResponse(), Rule.class); + Report.log(Status.INFO, "rule="+rule); + rule.setUid("NoSuchUid"); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", rule.toJson()); + Report.log(Status.INFO, "saveRule response= "+res); + assertThat(res.getStatusCode()).isEqualTo(409); + assertThat(res.getResponse()).isEqualTo(expectedError); + } + + + @Test + public void getAllRules() throws Exception{ + Vfcmt vfcmt = createVfcmt(); + RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); + String uid1 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); + //save two more rules + res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody); + Report.log(Status.INFO, "saveRule1 response= "+res); + String uid2 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody); + Report.log(Status.INFO, "saveRule2 response= "+res); + String uid3 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); + res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); + Report.log(Status.INFO, "getRules response= "+res); + JsonObject jsonRes = gson.fromJson(res.getResponse(), JsonObject.class); + Report.log(Status.INFO, "jsonRes="+jsonRes); + assertThat(jsonRes.get("schema")).isNotNull(); + MappingRules actualRules = gson.fromJson(res.getResponse(), MappingRules.class); + Report.log(Status.INFO, "MappingRules="+res.getResponse()); + assertThat(actualRules.getRules()).hasSize(3); + assertThat(actualRules.getRules().keySet()).containsOnly(uid1, uid2, uid3); + } + + + @Test + public void deleteRuleSuccessTest() throws Exception{ + Vfcmt vfcmt = createVfcmt(); + //save first rule + RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); + String uid1 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); + // save second rule + res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "param1", ruleRequestBody); + Report.log(Status.INFO, "saveRule response= "+res); + String uid2 = gson.fromJson(res.getResponse(), JsonObject.class).get("uid").getAsString(); + res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); + Report.log(Status.INFO, "getRules1 response= "+res); + MappingRules actualRules = gson.fromJson(res.getResponse(), MappingRules.class); + Report.log(Status.INFO, "MappingRules1="+res.getResponse()); + // get all rules should return both + assertThat(actualRules.getRules()).hasSize(2); + assertThat(actualRules.getRules().keySet()).containsOnly(uid1, uid2); + // delete a rule + res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", uid2); + Report.log(Status.INFO, "deleteRule1 response= "+res); + assertThat(res.getStatusCode()).isEqualTo(200); + res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); + Report.log(Status.INFO, "getRules2 response= "+res); + actualRules = gson.fromJson(res.getResponse(), MappingRules.class); + Report.log(Status.INFO, "MappingRules2="+res.getResponse()); + // get rules should return one rule + assertThat(actualRules.getRules()).hasSize(1); + assertThat(actualRules.getRules().keySet()).containsOnly(uid1); + // delete the last rule - artifact should be deleted + res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", uid1); + Report.log(Status.INFO, "deleteRule2 response= "+res); + assertThat(res.getStatusCode()).isEqualTo(200); + String expectedArtifactName = "map_map_param1_MappingRules.json"; + Artifact savedArtifact = fetchVfcmtArtifactMetadataByName(vfcmt.getUuid(), expectedArtifactName); + Report.log(Status.INFO, "savedArtifact= "+savedArtifact); + assertThat(savedArtifact).isNull(); + // get rules should return empty + res = DcaeRestClient.getRules(vfcmt.getUuid(),"map", "map", "param1"); + Report.log(Status.INFO, "getRules3 response= "+res); + assertThat(res.getStatusCode()).isEqualTo(200); + assertThat(res.getResponse()).isEqualTo("{}"); + + } + + @Test + public void invalidJsonRuleFormatTest() throws Exception{ + String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6035\",\"text\":\"Error - Rule format is invalid: %1.\",\"variables\":[\"java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $\"],\"formattedErrorMessage\":\"Error - Rule format is invalid: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $.\"}},\"notes\":\"\"}"; + RestResponse res = DcaeRestClient.saveRule("someId", "someName", "someNid", "someParam", "gibberish" ); + assertThat(res.getStatusCode()).isEqualTo(400); + assertThat(res.getResponse()).isEqualTo(expectedError); + } + + @Test + public void invalidActionTypeTest() throws Exception { + String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6035\",\"text\":\"Error - Rule format is invalid: %1.\",\"variables\":[\"Undefined action type: gibberish\"],\"formattedErrorMessage\":\"Error - Rule format is invalid: Undefined action type: gibberish.\"}},\"notes\":\"\"}"; + RestResponse res = DcaeRestClient.saveRule("someId", "someName", "someNid", "someParam", "{actions:[{actionType:gibberish}]}"); + assertThat(res.getStatusCode()).isEqualTo(400); + assertThat(res.getResponse()).isEqualTo(expectedError); + } + + @Test + public void conflictingUsersErrorTest() throws Exception { + Vfcmt vfcmt = createVfcmt(); + RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); + assertThat(res.getStatusCode()).isEqualTo(200); + //check out by other user then try to save rule by current user + res = DcaeRestClient.checkoutVfcmt(vfcmt.getUuid(), DcaeRestClient.getDesigner2UserId()); + assertThat(res.getStatusCode()).isEqualTo(200); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "someParam", ruleRequestBody); + assertThat(res.getStatusCode()).isEqualTo(403); + } + + @Test + public void uploadArtifactSdcErrorTest() throws Exception { + String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6036\",\"text\":\"Error - Failed to save rule. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Error - Failed to save rule. Internal persistence error\"}},\"notes\":\"Error: Invalid content.\"}"; + Vfcmt vfcmt = createVfcmt(); + RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); + assertThat(res.getStatusCode()).isEqualTo(200); + // Generated artifact label would be invalid and should fail when submitted to SDC + res = DcaeRestClient.saveRule(vfcmt.getUuid(), "map", "map", "()someParam", ruleRequestBody); + assertThat(res.getStatusCode()).isEqualTo(409); + assertThat(res.getResponse()).isEqualTo(expectedError); + } + + @Test + public void saveMappingRuleNoSuchNidErrorTest() throws Exception { + String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6114\",\"text\":\"DCAE component %1 not found in composition\",\"variables\":[\"noSuchComponent\"],\"formattedErrorMessage\":\"DCAE component noSuchComponent not found in composition\"}},\"notes\":\"\"}"; + Vfcmt vfcmt = createVfcmt(); + RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); + assertThat(res.getStatusCode()).isEqualTo(200); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), "noSuchComponent", "noSuchComponent", "someParam", ruleRequestBody); + assertThat(res.getStatusCode()).isEqualTo(400); + assertThat(res.getResponse()).isEqualTo(expectedError); + } + + + @Test + public void deleteRuleNoSuchIdTest() throws Exception { + String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6115\",\"text\":\"Delete rule failed. Internal persistence error\",\"variables\":[],\"formattedErrorMessage\":\"Delete rule failed. Internal persistence error\"}},\"notes\":\"\"}"; + Vfcmt vfcmt = createVfcmt(); + //save rule + saveCompositionAndFirstRuleSuccess(vfcmt, "map", "map", "param1", ruleRequestBody); + RestResponse res = DcaeRestClient.deleteRule(vfcmt.getUuid(),"map", "map", "param1", "noSuchRuleId"); + Report.log(Status.INFO, "deleteRule response=%s", res); + assertThat(res.getStatusCode()).isEqualTo(409); + assertThat(res.getResponse()).isEqualTo(expectedError); + } + + // After first rule is saved the mappingRules.json artifact is available for get/delete/edit tests + private RestResponse saveCompositionAndFirstRuleSuccess(Vfcmt vfcmt, String dcaeCompName, String nid, String configParam, String body) throws Exception { + // generate and save a composition.yml + Report.log(Status.INFO, "saveCompositionAndFirstRuleSuccess start"); + RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), String.format("{\"nid\":\"%s\"}", nid)); + Report.log(Status.INFO, "saveComposition response=%s", res); + assertThat(res.getStatusCode()).isEqualTo(200); + + res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam, body); + Report.log(Status.INFO, "saveRule response=%s", res); + assertThat(res.getStatusCode()).isEqualTo(200); + return res; + } + + + @Test + public void saveMappingRuleNegativeTest_BadResponse() throws Exception { + // arrange + Report.log(Status.INFO, "Arrangeing test..."); + ObjectMapper mapper = new ObjectMapper(); + String badRuleRequestBody = "{\"version\":\"5.3\",\"eventType\":\"syslogFields\",\"uid\":\"\",\"description\":\"map rules\"," + + "\"actions\":[{actionType:\"Date Formatter\",from:{value:whatever}},{\"id\":\"22fdded0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"AAA\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"BBB\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":true,\"default\":\"\"}},{\"id\":\"2d6fab00-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"DDD\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"60bff5a0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"EEE\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"75ea0ce0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"FFF\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"GGG\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"},{\"key\":\"\",\"value\":\"\"}],\"haveDefault\":false,\"default\":\"\"}},{\"id\":\"75ea0ce0-c9eb-11e7-83c1-3592231134a4\",\"actionType\":\"map\",\"from\":{\"value\":\"FFF\",\"regex\":\"\",\"state\":\"closed\",\"values\":[{\"value\":\"\"},{\"value\":\"\"}]},\"target\":\"GGG\",\"map\":{\"values\":[{\"key\":\"foo\",\"value\":\"bar\"},{\"key\":\"foo\",\"value\":\"not bar\"}],\"haveDefault\":false,\"default\":\"\"}}],\"condition\":null}"; + Vfcmt vfcmt = createVfcmt(); + Report.log(Status.INFO, "Saving composition of a fake cdump..."); + RestResponse res = DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"nid\":\"map\"}"); + Report.logDebug("saveComposition response", res); + if (res.getStatusCode() != 200) { + fail("Unable to arrange test, save composition failed\n" + res.toString()); + } + // act + Report.log(Status.INFO, "Executing..."); + Report.logDebug("Request body", badRuleRequestBody); + RestResponse targetRes = DcaeRestClient.saveRule(vfcmt.getUuid(), "noSuchComponent", "map", "someParam", badRuleRequestBody); + Report.logDebug("saveRule response", targetRes); + // assert + Report.log(Status.INFO, "Asserting..."); + List errors = mapper.readValue(targetRes.getResponse(), SaveRuleError.class).getFormattedErrors(); // parse response + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(targetRes.getStatusCode()).isEqualTo(400); + softly.assertThat(errors).containsExactlyInAnyOrder( + "Please fill the default value of map action to BBB", + "Please fill the from field of map action to DDD", + "Please fill the target field of map action to ", + "Please fill all key-value pairs of map action to GGG", + "Error: Duplication in map keys exists, please modify rule configuration", + "Please fill the target field of Date Formatter action to null", + "Please fill the to timezone field of Date Formatter action to null", + "Please fill the from timezone field of Date Formatter action to null", + "Please fill the from format field of Date Formatter action to null", + "Please fill the to format field of Date Formatter action to null" + ); + }); + } + + @Test + public void translateInvalidFlowTypeFailureTest() throws Exception { + String expectedError = "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC6116\",\"text\":\"Translation failed. Reason: %s\",\"variables\":[\"%s\"],\"formattedErrorMessage\":\"Translation failed. Reason: %s\"}},\"notes\":\"\"}"; + RestResponse res = DcaeRestClient.translateRules("someId","map", "map", "param1", "noSuchFlowType"); + assertThat(res.getStatusCode()).isEqualTo(400); + assertThat(res.getResponse()).isEqualTo(String.format(expectedError, "%1", "Flow type noSuchFlowType not found", "Flow type noSuchFlowType not found")); + res = DcaeRestClient.translateRules("someId","map", "map", "param1", null); + assertThat(res.getStatusCode()).isEqualTo(400); + assertThat(res.getResponse()).isEqualTo(String.format(expectedError, "%1", "Flow type null not found", "Flow type null not found")); + } + + @Test + public void getExistingRuleTargetsTest() throws Exception { + String dcaeCompName = "theComponent"; + String nid = "theNid"; + String configParam1 = "ConfigParam1"; + String configParam2 = "ConfigParam2"; + final String UID = "uid"; + + Vfcmt vfcmt = createVfcmt(); + RestResponse res = saveCompositionAndFirstRuleSuccess(vfcmt, dcaeCompName, nid, configParam1, ruleRequestBody); + gson.fromJson(res.getResponse(), JsonObject.class).get(UID).getAsString(); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam2, ruleRequestBody); + Report.log(Status.INFO, "saveRule1 response= "+res); + gson.fromJson(res.getResponse(), JsonObject.class).get(UID).getAsString(); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam1, ruleRequestBody); + Report.log(Status.INFO, "saveRule2 response= "+res); + gson.fromJson(res.getResponse(), JsonObject.class).get(UID).getAsString(); + res = DcaeRestClient.saveRule(vfcmt.getUuid(), dcaeCompName, nid, configParam1, ruleRequestBody); + Report.log(Status.INFO, "saveRule3 response= "+res); + + res = DcaeRestClient.getExistingRuleTargets(vfcmt.getUuid(),dcaeCompName,nid); + if (res.getStatusCode() != 200) { + fail("Unable to arrange test, get existing rule targets test failed\n" + res.toString()); + } + String response = res.getResponse(); + assertThat(response.contains(configParam1)); + assertThat(response.contains(configParam2)); + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/GetAttachment.java b/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/GetAttachment.java new file mode 100644 index 0000000..e9e4d27 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/GetAttachment.java @@ -0,0 +1,62 @@ +package org.onap.dcae.ci.api.tests.services.attachment; + +import static org.assertj.core.api.Assertions.*; + +import java.util.UUID; + +import org.assertj.core.api.SoftAssertions; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +import org.testng.annotations.*; + +import com.aventstack.extentreports.Status; + +public class GetAttachment extends DcaeRestBaseTest { + + /* Positive */ + + @Test + public void testNewVfcmt_noAttachedService() throws Exception { + Report.log(Status.INFO, "testNewVfcmt_noAttachedService start"); + // arrange + Vfcmt vfcmt = client.createVfcmt(); + // act + RestResponse response = DcaeRestClient.getAttachedService(vfcmt.getUuid()); + // assert + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); + softly.assertThat(resData.get("successResponse")) + .as("successResponse") + .isEqualTo("No Artifacts"); + }); + } + + /* Negative */ + + @Test + public void testNonUuidVfcmt_responseStatus404() throws Exception { + // act + RestResponse response = DcaeRestClient.getAttachedService("I am not a uuid"); + // assert + assertThat(response.getStatusCode()).as("status code").isEqualTo(404); + } + + @Test + public void testNonExistingVfcmt_responseStatus404() throws Exception { + // arrange + String fakeUuid = UUID.randomUUID().toString(); + // act + RestResponse response = DcaeRestClient.getAttachedService(fakeUuid); + // assert + assertThat(response.getStatusCode()).as("status code").isEqualTo(404); + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/PostAttachment.java b/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/PostAttachment.java new file mode 100644 index 0000000..e435ee2 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/attachment/PostAttachment.java @@ -0,0 +1,173 @@ +package org.onap.dcae.ci.api.tests.services.attachment; + +import static org.assertj.core.api.Assertions.*; + +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.entities.composition.services.Vfi; +import org.onap.dcae.ci.entities.sdc.SdcResource; +import org.onap.dcae.ci.entities.sdc.SdcService; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.SdcInternalApiClient; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import org.testng.annotations.*; + +import java.util.UUID; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +import com.aventstack.extentreports.Status; + +public class PostAttachment extends DcaeRestBaseTest { + + /* Positive */ + + @Test + public void vfcmtWithVfi_responseStatusOk() throws Exception { + // arrange + Vfcmt vfcmt; + Vfi vfi; + try { + vfcmt = client.createCheckedinVfcmt(); + vfi = arrangeVfi(); + } catch (Exception err) { + throw new Exception("Could not arrange test", err); + } + // act + Report.log(Status.INFO, "Attaching vfcmt [%s] to vfi [%s]", vfcmt.getUuid(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); + Report.logDebug("Response:", response); + // assert + JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat(resData.get("successResponse")) + .as("successResponse") + .isEqualTo("Artifact updated"); + }); + } + + + @Test + public void vfcmtAlreadyAttached_responseStatusOk() throws Exception { + // arrange + Vfcmt vfcmt; + Vfi vfi; + try { + vfcmt = client.createCheckedinVfcmt(); + Report.log(Status.INFO, "Arranging first attachment"); + arrangeAttachmentToNewVfi(vfcmt); + vfi = arrangeVfi(); + } catch (Exception err) { + throw new Exception("Could not arrange test", err); + } + // act + Report.log(Status.INFO, "Updating attachment of vfcmt [%s] to a new vfi [%s]", vfcmt.getUuid(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); + Report.logDebug("Response:", response); + // assert + JSONObject resData = (JSONObject) JSONValue.parse(response.getResponse()); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + softly.assertThat(resData.get("successResponse")) + .as("successResponse") + .isEqualTo("Artifact updated"); + }); + } + + + /* Negative */ + + + @Test + public void vfWithVfi_statusCode400() throws Exception { + // arrange + SdcResource vf; + Vfi vfi; + try { + Report.log(Status.INFO, "Create vf"); + vf = SdcInternalApiClient.createVf(); + vfi = arrangeVfi(); + } catch (Exception err) { + throw new Exception("Could not arrange test", err); + } + // act + Report.log(Status.INFO, "Attaching vf [%s] to vfi [%s]", vf.getUuid(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vf.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); + Report.logDebug("Response:", response); + // assert + assertThat(response.getStatusCode()).as("status code").isEqualTo(400); + } + + + @Test + public void vfcmtWithFakeServiceAndFakeVfi_statusCode404() throws Exception { + // arrange + Vfcmt vfcmt; + String fakeServiceUuid = UUID.randomUUID().toString(); + String fakeVfiName = "fakeVfi"; + try { + vfcmt = client.createCheckedinVfcmt(); + fakeServiceUuid = UUID.randomUUID().toString(); + fakeVfiName = "fakeVfi"; + } catch (Exception err) { + throw new Exception("Could not arrange test", err); + } + // act + Report.log(Status.INFO, "Attaching real vfcmt [%s] to fake service [%s] (random uuid) and fake vfi [%s]", vfcmt.getUuid(), fakeServiceUuid, fakeVfiName); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), fakeServiceUuid, fakeVfiName); + Report.logDebug("Response:", response); + // assert + assertThat(response.getStatusCode()).as("status code").isEqualTo(404); + } + + + @Test + public void vfcmtWithFakeVfi_statusCode404() throws Exception { + // arrange + Vfcmt vfcmt; + Vfi vfi; + try { + vfcmt = client.createCheckedinVfcmt(); + Report.log(Status.INFO, "Create service"); + SdcService service = SdcInternalApiClient.createService(); + vfi = new Vfi("fakeVfi", service); + } catch (Exception err) { + throw new Exception("Could not arrange test", err); + } + // act + Report.log(Status.INFO, "Attaching vfcmt [%s] to real service [%s] and fake vfi [%s]", vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); + Report.logDebug("Response:", response); + // assert + assertThat(response.getStatusCode()).as("status code").isEqualTo(404); + } + + + /* Private Methods */ + + private Vfi arrangeVfi() throws Exception { + Report.log(Status.INFO, "Create service"); + SdcService service = SdcInternalApiClient.createService(); + Report.log(Status.INFO, "Create vf"); + SdcResource vf = SdcInternalApiClient.createVf(); + Report.log(Status.INFO, "Checkin vf"); + vf = SdcInternalApiClient.checkinVf(vf); + Report.log(Status.INFO, "Create vfi from (service [%s] + vf [%s])", service.getUuid(), vf.getUuid()); + return SdcInternalApiClient.createVfi(service, vf); + } + + + private void arrangeAttachmentToNewVfi(Vfcmt vfcmt) throws Exception { + Vfi vfi = arrangeVfi(); + Report.log(Status.INFO, "Attaching vfcmt [%s] to vfi [%s]", vfcmt.getUuid(), vfi.getName()); + RestResponse response = DcaeRestClient.attachVfiRef(vfcmt.getUuid(), vfi.getContainer().getUuid(), vfi.getName()); + Report.logDebug("Response:", response); + if (response.getStatusCode() != 200) { + throw new Exception("Failed to attach vfcmt to vfi\nResponse: " + response.toString()); + } + } + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java b/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java new file mode 100644 index 0000000..8e72204 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstanceNagative.java @@ -0,0 +1,25 @@ +package org.onap.dcae.ci.api.tests.services.instance; + + +import com.aventstack.extentreports.Status; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; + +import org.onap.dcae.ci.report.Report; +import org.testng.annotations.Test; + +import java.io.IOException; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GetServiceInstanceNagative extends DcaeRestBaseTest { + + @Test + public void test_invalidServiceID() throws IOException{ + Report.log(Status.INFO, "Send invalid service Instance"); + RestResponse response = DcaeRestClient.getServicesInstance("123456789"); + Report.log(Status.INFO, "Verifying response status is 404"); + assertThat(response.getStatusCode()).as("response status").isEqualTo(404); + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java b/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java new file mode 100644 index 0000000..b22e2f7 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/instance/GetServiceInstancePositive.java @@ -0,0 +1,121 @@ +package org.onap.dcae.ci.api.tests.services.instance; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.onap.sdc.dcae.composition.restmodels.sdc.ServiceDetailed; +import org.onap.sdc.dcae.composition.services.Resource; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import org.onap.sdc.dcae.composition.restmodels.DcaeMinimizedService; +import org.springframework.util.CollectionUtils; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.aventstack.extentreports.Status; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; + +public class GetServiceInstancePositive extends DcaeRestBaseTest { + + private RestResponse response; + + @BeforeClass + public void executeApiCall() throws Exception { + // arrange + DcaeMinimizedService service = arrangeService(); + try { + // act + Report.log(Status.INFO, "Get all VFIs for service [" + service.getUuid() + "]"); + response = DcaeRestClient.getServicesInstance(service.getUuid()); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + } catch (Exception err) { + Report.log(Status.FAIL, "Unable to execute api call: " + err.toString()); + err.printStackTrace(); + } + } + + private DcaeMinimizedService arrangeService() throws Exception { + DcaeMinimizedService service = null; + try { + Predicate hasVfi = p -> !CollectionUtils.isEmpty(getService(p.getUuid()).getResources()); + Vfcmt vfcmt = client.createCheckedoutVfcmt(); + Report.log(Status.INFO, "Created vfcmt [" + vfcmt.getUuid() + "]"); + Report.log(Status.INFO, "Get all services for vfcmt [" + vfcmt.getUuid() + "]"); + RestResponse responseServices = DcaeRestClient.getServices(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId()); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(responseServices)); + DcaeMinimizedService[] servicesList = gson.fromJson(responseServices.getResponse(), DcaeMinimizedService[].class); + // TODO: create a service instead of picking a random one + // find a service with a vfi + service = Arrays.stream(servicesList).filter(hasVfi).findAny().orElse(null); + } catch (Exception err) { + Report.log(Status.ERROR, "Could not arrange test: " + err.toString()); + } + return service; + } + + private ServiceDetailed getService(String serviceId) { + ServiceDetailed service = null; + try { + service = gson.fromJson(DcaeRestClient.getServicesInstance(serviceId).getResponse(), ServiceDetailed.class); + } catch (Exception e) { + Report.log(Status.ERROR, "Could not arrange test: " + e.toString()); + } + return service; + } + + @Test + public void test_responseStatusOk() throws IOException{ + // assert + Report.log(Status.INFO, "Verifing response status is 200"); + assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + } + + @Test + public void test_atLeastOneOrMoreResources() throws IOException{ + // assert + Report.log(Status.INFO, "Parsing response to a one service instance"); + List resourceList = getResourceListFromJsonResponse(); + Report.log(Status.INFO, "validating parsed response structure"); + assertThat(resourceList).size().isGreaterThanOrEqualTo(1); // TODO: create a VFI for the service instead of picking a random one + } + + @Test + public void test_responseIsValidStructure() throws IOException{ + // assert + Report.log(Status.INFO, "Parsing response to a one service instance"); + + List resourceList = getResourceListFromJsonResponse(); + + Report.log(Status.INFO, "validating parsed response structure"); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(resourceList.get(0).getResourceInstanceName()).isNotEmpty(); + softly.assertThat(resourceList.get(0).getResourceInvariantUUID()).isNotEmpty(); + }); + } + + + /*** private method ***/ + private List getResourceListFromJsonResponse() { + JsonParser jsonParser = new JsonParser(); + JsonObject responseJson = (JsonObject)jsonParser.parse(response.getResponse()); + JsonArray resources = responseJson.getAsJsonArray("resources"); + Type listType = new TypeToken>(){}.getType(); + List resourceList = gson.fromJson(resources, listType); + return resourceList; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesNagative.java b/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesNagative.java new file mode 100644 index 0000000..be7d651 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesNagative.java @@ -0,0 +1,47 @@ +package org.onap.dcae.ci.api.tests.services.list; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.testng.Assert.fail; + +import java.io.IOException; + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.testng.annotations.Test; + +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +import com.aventstack.extentreports.Status; + +public class GetAllServicesNagative extends DcaeRestBaseTest { + + @Test + public void userNotLastUpdater_statusCode403() throws Exception{ + // arrange + String user1 = DcaeRestClient.getDefaultUserId(); + String user2 = DcaeRestClient.getDesigner2UserId(); + Vfcmt vfcmt = null; + try { + vfcmt = client.createCheckedoutVfcmt(user1); + } catch (Exception err) { + fail("Unable to arrange test", err); + } + // act + Report.log(Status.INFO, "GetServices for user that is not the vfcmt last-updater"); + RestResponse response = getServices(vfcmt.getUuid(), user2); + // assert + assertThat(response.getStatusCode()).as("response status").isEqualTo(403); + } + + + /* Private Methods */ + + private RestResponse getServices(String uuid, String user2) throws IOException { + RestResponse response = DcaeRestClient.getServices(uuid, user2); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + return response; + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesPositive.java b/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesPositive.java new file mode 100644 index 0000000..b8b947f --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/services/list/GetAllServicesPositive.java @@ -0,0 +1,72 @@ +package org.onap.dcae.ci.api.tests.services.list; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.List; + +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; + +import org.onap.sdc.dcae.composition.restmodels.sdc.Service; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import com.aventstack.extentreports.Status; +import com.google.gson.reflect.TypeToken; + +public class GetAllServicesPositive extends DcaeRestBaseTest { + + private RestResponse response; + + @BeforeClass + public void executeApiCall() throws Exception { + Report.log(Status.INFO, "@BeforeClass --> executeApiCall"); + Vfcmt component = client.createCheckedoutVfcmt(); + String uuid = component.getUuid(); + String userIdLastUpdaterUserId = component.getLastUpdaterUserId(); + try { + // act + Report.log(Status.INFO, "Get all services"); + response = DcaeRestClient.getServices(uuid, userIdLastUpdaterUserId); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + } catch (Exception err) { + Report.log(Status.ERROR, err); + err.printStackTrace(); + } + } + + @Test + public void test_responseStatusOk() throws IOException{ + // assert + Report.log(Status.INFO, "Verifing response status is 200"); + assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + } + + @Test + public void test_responseIsValidStructure() throws IOException{ + // assert + Report.log(Status.INFO, "Parsing response to a List of Services"); + Type listType = new TypeToken>(){}.getType(); + List servicesList = gson.fromJson(response.getResponse(), listType); + Service service = servicesList.get(0); + + Report.log(Status.INFO, "validating parsed response structure"); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(service.getInvariantUUID()).isNotEmpty(); + softly.assertThat(service.getLastUpdaterUserId()).isNotEmpty(); + softly.assertThat(service.getName()).isNotEmpty(); + softly.assertThat(service.getUuid()).isNotEmpty(); + softly.assertThat(service.getLifecycleState()).isNotEmpty(); + softly.assertThat(service.getVersion()).isNotEmpty(); + }); + } + + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java new file mode 100644 index 0000000..1dc27d6 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateMonitoringComponent.java @@ -0,0 +1,253 @@ +package org.onap.dcae.ci.api.tests.vfcmt; + + +import com.aventstack.extentreports.Status; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; +import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; +import org.onap.sdc.dcae.composition.restmodels.ImportVFCMTRequest; +import org.onap.sdc.dcae.composition.restmodels.MessageResponse; +import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; +import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed; +import org.onap.sdc.dcae.composition.services.Service; +import org.onap.sdc.dcae.composition.util.DcaeBeConstants; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CreateMonitoringComponent extends DcaeRestBaseTest { + + private RestResponse response; + private Resource res = null; + + + @BeforeClass + public void executeApiCall() { + // arrange + try { + // act + Report.log(Status.INFO, "Creating vfcmt"); + RestResponse clientResponse = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); + Resource[] resources = gson.fromJson(clientResponse.getResponse(),Resource[].class); + if (resources.length > 0){ + res = resources[0]; + } + } catch (Exception err) { + Report.log(Status.ERROR, err); + } + } + + @Test + public void testCreateMonitoringComponentSuccess() throws IOException { + + Service service; + + try { + service = createServiceWithVFiAsSdcDesigner(); + } catch (Exception e) { + Report.log(Status.ERROR, e); + return; + } + + CreateVFCMTRequest request = new CreateVFCMTRequest(); + // If you crashed here (below) it is because your environment has no Base Monitoring Templates + request.setTemplateUuid(res.getUuid()); + request.setVfiName(service.getResources().get(0).getResourceInstanceName()); + request.setServiceUuid(service.getUuid()); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); + + response = DcaeRestClient.createMc(gson.toJson(request)); + + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + + CreateMcResponse mcResponse = gson.fromJson(response.getResponse(),CreateMcResponse.class); + + String vfUuid = mcResponse.getVfcmt().getUuid(); + String vfCdump = gson.toJson(mcResponse.getCdump()); + assertThat(vfCdump.contains(vfUuid)).isTrue(); + + RestResponse r = DcaeRestClient.getAttachedService(vfUuid); + assertThat(r.getResponse().contains(service.getUuid())).isTrue(); + + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + } + + @Test + public void testCreateMonitoringComponentBadUser() throws IOException { + + String fakeUserId = "anonymous"; + CreateVFCMTRequest request = new CreateVFCMTRequest(); + // If you crashed here (below) it is because your environment has no Base Monitoring Templates + request.setTemplateUuid(res.getUuid()); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); + + response = DcaeRestClient.createMc(gson.toJson(request),fakeUserId); + + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + // assert + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(403); + } + + @Test + public void testImportMonitoringComponentBothFlagsFalseSuccess() throws Exception { + + Service service; + + try { + service = createServiceWithVFiAsSdcDesigner(); + } catch (Exception e) { + Report.log(Status.ERROR, e); + return; + } + + String vfiName = service.getResources().get(0).getResourceInstanceName(); + Vfcmt vfcmt = prepareMockVfcmtForImport(); + ImportVFCMTRequest request = new ImportVFCMTRequest(); + request.setTemplateUuid(vfcmt.getUuid()); + request.setVfiName(vfiName); + request.setServiceUuid(service.getUuid()); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); + + response = DcaeRestClient.importMc(gson.toJson(request)); + + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + + // the service vfi should now have an external reference record to the vfcmt + response = DcaeRestClient.getServiceExternalReferences(service.getUuid(), service.getVersion()); + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + Map> refs = gson.fromJson(response.getResponse(), Map.class); + assertThat(vfcmt.getUuid().equals(refs.get("monitoringComponents").get(0).get("uuid"))).isTrue(); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + } + + @Test + public void testImportMonitoringComponentCloneFalseUpdateFlowTypeTrueSuccess() throws Exception { + + Service service; + + try { + service = createServiceWithVFiAsSdcDesigner(); + } catch (Exception e) { + Report.log(Status.ERROR, e); + return; + } + + String vfiName = service.getResources().get(0).getResourceInstanceName(); + Vfcmt vfcmt = prepareMockVfcmtForImport(); + ImportVFCMTRequest request = new ImportVFCMTRequest(); + request.setUpdateFlowType(true); + request.setTemplateUuid(vfcmt.getUuid()); + request.setVfiName(vfiName); + request.setServiceUuid(service.getUuid()); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); + + response = DcaeRestClient.importMc(gson.toJson(request)); + + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + + // TODO update to one GET call after editMC is implemented + // assert that the vfcmt was updated as expected (version, owner, lifecycle) + response = DcaeRestClient.getResourceDetails(vfcmt.getUuid()); + ResourceDetailed updatedMC = gson.fromJson(response.getResponse(), ResourceDetailed.class); + assertThat(updatedMC.getVersion()).isEqualTo("0.2"); + assertThat(updatedMC.getLastUpdaterUserId()).isEqualTo(DcaeRestClient.getDefaultUserId()); + assertThat(updatedMC.getLifecycleState()).isEqualTo(DcaeBeConstants.LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name()); + // assert that the updated cdump includes 'flowType' + + response = DcaeRestClient.getComposition(vfcmt.getUuid()); + String cdump = gson.fromJson(response.getResponse(), MessageResponse.class).getSuccessResponse(); + assertThat(cdump).isEqualTo("{\"flowType\":\"flowType_xxx\",\"cid\":\"1234567\"}"); + Report.log(Status.DEBUG, "Response updated mock cdump: " + cdump); + } + + @Test + public void testImportMonitoringComponentBothFlagsTrueSuccess() throws Exception { + + Service service; + + try { + service = createServiceWithVFiAsSdcDesigner(); + } catch (Exception e) { + Report.log(Status.ERROR, e); + return; + } + + String vfiName = service.getResources().get(0).getResourceInstanceName(); + Vfcmt vfcmt = prepareMockVfcmtForImport(); + ImportVFCMTRequest request = new ImportVFCMTRequest(); + request.setUpdateFlowType(true); + request.setCloneVFCMT(true); + request.setTemplateUuid(vfcmt.getUuid()); + request.setVfiName(vfiName); + request.setServiceUuid(service.getUuid()); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); + + response = DcaeRestClient.importMc(gson.toJson(request)); + + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(200); + + // assert that the vfcmt was cloned, the flowType updated and the reference artifact created + CreateMcResponse mcResponse = gson.fromJson(response.getResponse(),CreateMcResponse.class); + + assertThat(mcResponse.getVfcmt().getFlowType()).isEqualTo("flowType_xxx"); + // check the reference artifact + response = DcaeRestClient.getAttachedService(mcResponse.getVfcmt().getUuid()); + String ref = gson.fromJson(response.getResponse(), MessageResponse.class).getSuccessResponse(); + assertThat(ref).isEqualTo(service.getUuid()+"/resources/"+vfiName); + + Report.log(Status.DEBUG, "Response cloned Monitoring component: " + mcResponse); + } + + @Test + public void testImportMonitoringComponentServiceNotFoundFailure() throws Exception { + + Vfcmt vfcmt = prepareMockVfcmtForImport(); + ImportVFCMTRequest request = new ImportVFCMTRequest(); + request.setTemplateUuid(vfcmt.getUuid()); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); + response = DcaeRestClient.importMc(gson.toJson(request)); + + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(404); + + Report.log(Status.DEBUG, "Error response: " + response.getResponse()); + // assert vfcmt version was not increased + response = DcaeRestClient.getResourceDetails(vfcmt.getUuid()); + vfcmt = gson.fromJson(response.getResponse(), Vfcmt.class); + assertThat(vfcmt.getVersion()).isEqualTo("0.1"); + } + + + private Vfcmt prepareMockVfcmtForImport() throws IOException { + RestResponse createResponse = DcaeRestClient.createVfcmt(StringUtils.randomString("CI-", 20), "description", DcaeRestClient.getDesigner2UserId()); + Vfcmt vfcmt = gson.fromJson(createResponse.getResponse(), Vfcmt.class); + // create a composition artifact + DcaeRestClient.saveComposition(vfcmt.getUuid(), vfcmt.getLastUpdaterUserId(), "{\"cid\":\"1234567\"}"); + return vfcmt; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateVfcmt.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateVfcmt.java new file mode 100644 index 0000000..6ca6053 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/CreateVfcmt.java @@ -0,0 +1,126 @@ +package org.onap.dcae.ci.api.tests.vfcmt; + +import static org.assertj.core.api.Assertions.*; + +import java.io.IOException; + +import org.assertj.core.api.SoftAssertions; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.utilities.DcaeTestConstants; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.testng.annotations.*; + +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; +import com.aventstack.extentreports.Status; + +public class CreateVfcmt extends DcaeRestBaseTest { + + private Vfcmt input; + private RestResponse response; + + @BeforeClass + public void executeApiCall() { + // arrange + input = new Vfcmt(); + input.setName(StringUtils.randomString("CI-", 20)); + input.setDescription(StringUtils.randomString("", 10)); + try { + // act + Report.log(Status.INFO, "Creating vfcmt"); + response = DcaeRestClient.createVfcmt(input.getName(), input.getDescription()); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + } catch (Exception err) { + Report.log(Status.ERROR, err); + } + } + + /* Positive tests */ + + @Test + public void test_responseStatusOk() throws IOException { + // assert + Report.log(Status.INFO, "Verifing response status is 200"); + assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + } + + @Test + public void test_responseIsValidStructure() throws IOException { + // assert + Report.log(Status.INFO, "Parsing response to a VFCMT"); + Vfcmt createdVfcmt = gson.fromJson(response.getResponse(), Vfcmt.class); + Report.log(Status.INFO, "validating parsed response structure"); + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(createdVfcmt.getCategory()).isEqualTo("Template"); + softly.assertThat(createdVfcmt.getInvariantUUID()).isNotEmpty(); + softly.assertThat(createdVfcmt.getUuid()).isNotEmpty(); + softly.assertThat(createdVfcmt.getLastUpdaterUserId()).isEqualTo(DcaeRestClient.getDefaultUserId()); + softly.assertThat(createdVfcmt.getLifecycleState()).isEqualTo(DcaeTestConstants.Sdc.State.NOT_CERTIFIED_CHECKOUT); + softly.assertThat(createdVfcmt.getName()).isEqualTo(input.getName()); + softly.assertThat(createdVfcmt.getDescription()).isEqualTo(input.getDescription()); + softly.assertThat(createdVfcmt.getResourceType()).isEqualTo("VFCMT"); + softly.assertThat(createdVfcmt.getSubCategory()).isEqualTo("Monitoring Template"); + softly.assertThat(createdVfcmt.getVersion()).isEqualTo("0.1"); + }); + } + + /* Negative tests */ + + + + @Test + public void testWithNonExistingUser_status403() throws IOException { + // arrange + String fakeUserId = "anonymous"; + String name = StringUtils.randomString("CI-", 20); + String description = StringUtils.randomString("", 10); + // act + Report.log(Status.INFO, "Creating vfcmt with fake user"); + RestResponse res = DcaeRestClient.createVfcmt(name, description, fakeUserId); + Report.log(Status.DEBUG, "response: " + StringUtils.truncate(res)); + // assert + assertThat(res.getStatusCode()) + .as("status code") + .isEqualTo(403); + } + + @Test + public void testCreateTwoVfcmtsWithSameName_status409() throws IOException { + // arrange + String name = StringUtils.randomString("CI-", 20); + Report.log(Status.INFO, "Creating first vfcmt with name '" + name + "'"); + RestResponse response1 = DcaeRestClient.createVfcmt(name, StringUtils.randomString("", 10)); + Report.log(Status.DEBUG, "First Response: " + StringUtils.truncate(response1)); + if (response1.getStatusCode() != 200) { + fail("unable to arrange test - could not create the first vfcmt"); + } + // act + Report.log(Status.INFO, "Creating second vfcmt with same name '" + name + "'"); + RestResponse response2 = DcaeRestClient.createVfcmt(name, StringUtils.randomString("", 10)); + Report.log(Status.DEBUG, "Second response: " + StringUtils.truncate(response2)); + // assert + assertThat(response2.getStatusCode()) + .as("second status code") + .isEqualTo(409); + } + + @Test + public void testWithNonDesignerRole_status403() throws IOException { + // arrange + String testerId = DcaeRestClient.getDefaultTesterId(); + String name = StringUtils.randomString("CI-", 20); + String description = StringUtils.randomString("", 10); + // act + Report.log(Status.INFO, "Creating vfcmt with role tester"); + RestResponse response = DcaeRestClient.createVfcmt(name, description, testerId); + Report.log(Status.DEBUG, "response: " + StringUtils.truncate(response)); + // assert + assertThat(response.getStatusCode()) + .as("status code") + .isEqualTo(403); + } + + +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java new file mode 100644 index 0000000..4a9a952 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllMonitoringTemplateVfcmts.java @@ -0,0 +1,61 @@ +package org.onap.dcae.ci.api.tests.vfcmt; + +import com.aventstack.extentreports.Status; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GetAllMonitoringTemplateVfcmts extends DcaeRestBaseTest { + + private RestResponse response; + private static final String BASE_MONITORING_TEMPLATE = "Base Monitoring Template"; + + @BeforeClass + public void executeApiCall() { + try { + // act + Report.log(Status.INFO, "Fetching all monitoring templates vfcmt resources"); + response = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + } catch (Exception err) { + Report.log(Status.ERROR, err); + } + } + + @Test + public void testResponseStatusOk() { + // assert + Report.log(Status.INFO, "Verifying response status is 200"); + assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + } + + @Test + public void testResponseBodyIsListOfVfcmtsOnly() { + // assert + Report.log(Status.INFO, "Parsing response to a list of monitoring template VFCMTs"); + Vfcmt[] vfcmtList = gson.fromJson(response.getResponse(), Vfcmt[].class); + + Report.log(Status.INFO, "Verifying we got items"); + assertThat(vfcmtList).isNotEmpty(); + + Report.log(Status.INFO, "Verifying all items of the parsed response are VFCMTs"); + assertThat(vfcmtList) + .as("response data") + .extracting("resourceType") + .containsOnly("VFCMT"); + + Report.log(Status.INFO, "Verifying that all items of the parsed response are monitoring template VFCMTs"); + assertThat(vfcmtList) + .as("response data") + .extracting("subCategory") + .containsOnly(BASE_MONITORING_TEMPLATE); + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java new file mode 100644 index 0000000..65e3f91 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetAllVfcmts.java @@ -0,0 +1,55 @@ +package org.onap.dcae.ci.api.tests.vfcmt; + +import static org.assertj.core.api.Assertions.*; + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.testng.annotations.*; + + +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +import com.aventstack.extentreports.Status; + +public class GetAllVfcmts extends DcaeRestBaseTest { + + private RestResponse response; + + @BeforeClass + public void executeApiCall() { + try { + // act + Report.log(Status.INFO, "Fetching all vfcmt resources"); + response = DcaeRestClient.getAllVfcmts(); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + } catch (Exception err) { + Report.log(Status.ERROR, err); + } + } + + /* Positive tests */ + + @Test + public void testResponseStatusOk() { + // assert + Report.log(Status.INFO, "Verifying response status is 200"); + assertThat(response.getStatusCode()).as("response status").isEqualTo(200); + } + + @Test + public void testResponseBodyIsListOfVfcmtsOnly() { + // assert + Report.log(Status.INFO, "Parsing response to a list of VFCMTs"); + Vfcmt[] vfcmtList = gson.fromJson(response.getResponse(), Vfcmt[].class); + Report.log(Status.INFO, "Verifying all items of the parsed response are VFCMTs"); + assertThat(vfcmtList) + .as("response data") + .extracting("resourceType") + .containsOnly("VFCMT"); + } + + /* Negative tests */ +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java new file mode 100644 index 0000000..c12a14c --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/GetVfcmtsForMigration.java @@ -0,0 +1,96 @@ +package org.onap.dcae.ci.api.tests.vfcmt; + + +import com.aventstack.extentreports.Status; +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.entities.RestResponse; +import org.onap.dcae.ci.utilities.DcaeRestClient; +import org.onap.dcae.ci.report.Report; +import org.onap.dcae.ci.utilities.StringUtils; +import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; +import org.onap.sdc.dcae.composition.restmodels.CreateVFCMTRequest; +import org.onap.sdc.dcae.composition.restmodels.sdc.Resource; +import org.onap.sdc.dcae.composition.services.Service; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GetVfcmtsForMigration extends DcaeRestBaseTest { + + private static final String STATUS_CODE = "status code"; + private RestResponse response; + private Resource res = null; + + @BeforeClass + public void executeApiCall() { + try { + // act + Report.log(Status.INFO, "Selecting vfcmt resources for migration"); + response = DcaeRestClient.getVfcmtsForMigration("services","1111111","1.3"); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + + Report.log(Status.INFO, "getAllMonitoringTemplatesVfcmts"); + RestResponse clientResponse = DcaeRestClient.getAllMonitoringTemplatesVfcmts(); + Resource[] resources = gson.fromJson(clientResponse.getResponse(),Resource[].class); + if (resources.length > 0){ + res = resources[0]; + } + } catch (Exception err) { + Report.log(Status.ERROR, err); + } + } + + // If tests are taking too long: consider removing this very tedious and long test + @Test + public void testCreateMonitoringComponentSuccess() throws IOException { + CreateVFCMTRequest request = new CreateVFCMTRequest(); + + request.setDescription("Test description"); + + Service service; + + try { + service = createServiceWithVFiAsSdcDesigner(); + } catch (Exception e) { + Report.log(Status.ERROR, e); + return; + } + + // If you crashed here (below) it is because your environment has no Base Monitoring Templates + request.setTemplateUuid(res.getUuid()); + if (service != null) { + request.setServiceUuid(service.getUuid()); + } + request.setVfiName(service.getResources().get(0).getResourceInstanceName()); + + List listOfVfcmtsConnectedToService = new ArrayList<>(); + for (int i = 0 ; i < 4 ; i++){ + request.setName(StringUtils.randomString("CI-", 20)); + DcaeRestClient.fillCreateMcRequestMandatoryFields(request); + response = DcaeRestClient.createMc(gson.toJson(request)); + assertThat(response.getStatusCode()).as(STATUS_CODE).isEqualTo(200); + CreateMcResponse mcResponse = gson.fromJson(response.getResponse(),CreateMcResponse.class); + String key = mcResponse.getVfcmt().getUuid(); + String value = gson.toJson(mcResponse.getCdump()); + assertThat(value.contains(key)).isTrue(); + Report.log(Status.DEBUG, "Response: " + StringUtils.truncate(response)); + listOfVfcmtsConnectedToService.add(key); + } + + response = DcaeRestClient.getVfcmtsForMigration("service",service.getUuid(),service.getVersion()); + assertThat(response.getStatusCode()).as(STATUS_CODE).isEqualTo(200); + + listOfVfcmtsConnectedToService.forEach( s -> assertThat(response.getResponse().contains(s)).isFalse()); + + response = DcaeRestClient.getAllVfcmts(); + assertThat(response.getStatusCode()).as(STATUS_CODE).isEqualTo(200); + + listOfVfcmtsConnectedToService.forEach( s -> assertThat(response.getResponse().contains(s)).isTrue()); + + } +} diff --git a/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java new file mode 100644 index 0000000..f5ed264 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/api/tests/vfcmt/VfcmtCreationFlow.java @@ -0,0 +1,37 @@ +package org.onap.dcae.ci.api.tests.vfcmt; + +import org.onap.dcae.ci.api.tests.DcaeRestBaseTest; +import org.onap.dcae.ci.report.Report; +import org.testng.annotations.*; +import static org.assertj.core.api.Assertions.*; + +import com.aventstack.extentreports.Status; +import org.onap.sdc.dcae.composition.vfcmt.Vfcmt; + +public class VfcmtCreationFlow extends DcaeRestBaseTest { + + private Vfcmt[] vfcmtsBeforeAdd; + private Vfcmt newVfcmt; + private Vfcmt[] vfcmtsAfterAdd; + + @BeforeClass + public void executeFlow() throws Exception { + Report.log(Status.INFO, "@BeforeClass --> executeFlow (getAllVfcmts)"); + try { + // act + vfcmtsBeforeAdd = client.getAllVfcmts(); + newVfcmt = client.createVfcmt(); + vfcmtsAfterAdd = client.getAllVfcmts(); + } catch (Exception err) { + Report.log(Status.ERROR, err); + err.printStackTrace(); + } + } + + @Test + public void test_numberOfVfcmtsIncresed() { + Report.log(Status.INFO, String.format("asserting (after[%d] > before[%d])", vfcmtsAfterAdd.length, vfcmtsBeforeAdd.length)); + // assert + assertThat(vfcmtsAfterAdd.length).isGreaterThan(vfcmtsBeforeAdd.length); + } +} diff --git a/src/main/java/org/onap/dcae/ci/config/Configuration.java b/src/main/java/org/onap/dcae/ci/config/Configuration.java new file mode 100644 index 0000000..0631800 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/config/Configuration.java @@ -0,0 +1,299 @@ +package org.onap.dcae.ci.config; + +import org.yaml.snakeyaml.Yaml; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Paths; + +public class Configuration { + private String apiPath; + private String dcaeBeHost; + private String beHost; + private String feHost; + private int bePort; + private int fePort; + private String dcaeBePort; + private String url; + private String remoteTestingMachineIP; + private int remoteTestingMachinePort; + private boolean remoteTesting; + private String browser; + private String systemUnderDebug; + private String reportDBhost; + private int reportDBport; + private boolean captureTraffic; + private boolean useBrowserMobProxy; + private String stopOnClassFailure; + private String reportFileName; + private String reportFolder; + private int numOfAttemptsToRefresh; + private boolean rerun; + private String windowsDownloadDirectory; + private String screenshotFolder; + private String harFilesFolder; + private String ruleEditorUrl; + + public Configuration() { + this.basicInit((String) null); + } + + public Configuration(String url) { + this.basicInit(url); + } + + public static synchronized Configuration loadConfigFile(File configFile) { + return loadConfigFile(configFile, Configuration.class); + } + + private void basicInit(String url) { + this.remoteTesting = false; + this.captureTraffic = false; + this.useBrowserMobProxy = false; + this.reportFolder = "." + File.separator + "ExtentReport" + File.separator; + this.reportFileName = "UI_Extent_Report.html"; + this.screenshotFolder = this.reportFolder + "screenshots" + File.separator; + this.harFilesFolder = this.reportFolder + "har_files" + File.separator; + this.browser = "firefox"; + this.url = url; + this.numOfAttemptsToRefresh = 2; + } + + public String getBeHost() { + return this.beHost; + } + + public void setBeHost(String beHost) { + this.beHost = beHost; + } + + public String getFeHost() { + return this.feHost; + } + + public void setFeHost(String feHost) { + this.feHost = feHost; + } + + public int getBePort() { + return this.bePort; + } + + public void setBePort(int bePort) { + this.bePort = bePort; + } + + public int getFePort() { + return this.fePort; + } + + public void setFePort(int fePort) { + this.fePort = fePort; + } + + public String getUrl() { + return this.url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getRemoteTestingMachineIP() { + return this.remoteTestingMachineIP; + } + + public void setRemoteTestingMachineIP(String remoteTestingMachineIP) { + this.remoteTestingMachineIP = remoteTestingMachineIP; + } + + public int getRemoteTestingMachinePort() { + return this.remoteTestingMachinePort; + } + + public void setRemoteTestingMachinePort(int remoteTestingMachinePort) { + this.remoteTestingMachinePort = remoteTestingMachinePort; + } + + public boolean isRemoteTesting() { + return this.remoteTesting; + } + + public void setRemoteTesting(boolean remoteTesting) { + this.remoteTesting = remoteTesting; + } + + public String getBrowser() { + return this.browser; + } + + public void setBrowser(String browser) { + this.browser = browser; + } + + public String getSystemUnderDebug() { + return this.systemUnderDebug; + } + + public void setSystemUnderDebug(String systemUnderDebug) { + this.systemUnderDebug = systemUnderDebug; + } + + public String getReportDBhost() { + return this.reportDBhost; + } + + public void setReportDBhost(String reportDBhost) { + this.reportDBhost = reportDBhost; + } + + public int getReportDBport() { + return this.reportDBport; + } + + public void setReportDBport(int reportDBport) { + this.reportDBport = reportDBport; + } + + public boolean isCaptureTraffic() { + return this.captureTraffic; + } + + public void setCaptureTraffic(boolean captureTraffic) { + this.captureTraffic = captureTraffic; + } + + public boolean isUseBrowserMobProxy() { + return this.useBrowserMobProxy; + } + + public void setUseBrowserMobProxy(boolean useBrowserMobProxy) { + this.useBrowserMobProxy = useBrowserMobProxy; + } + + public String getStopOnClassFailure() { + return this.stopOnClassFailure; + } + + public void setStopOnClassFailure(String stopOnClassFailure) { + this.stopOnClassFailure = stopOnClassFailure; + } + + public String getReportFileName() { + return this.reportFileName; + } + + public void setReportFileName(String reportFileName) { + this.reportFileName = reportFileName; + } + + public String getReportFolder() { + return this.reportFolder; + } + + public void setReportFolder(String reportFolder) { + this.reportFolder = reportFolder; + } + + public int getNumOfAttemptsToRefresh() { + return this.numOfAttemptsToRefresh; + } + + public void setNumOfAttemptsToRefresh(int numOfAttemptsToRefresh) { + this.numOfAttemptsToRefresh = numOfAttemptsToRefresh; + } + + public boolean isRerun() { + return this.rerun; + } + + public void setRerun(boolean rerun) { + this.rerun = rerun; + } + + public String getWindowsDownloadDirectory() { + return this.windowsDownloadDirectory; + } + + public void setWindowsDownloadDirectory(String windowsDownloadDirectory) { + this.windowsDownloadDirectory = windowsDownloadDirectory; + } + + public String getScreenshotFolder() { + return this.screenshotFolder; + } + + public void setScreenshotFolder(String screenshotFolder) { + this.screenshotFolder = screenshotFolder; + } + + public String getHarFilesFolder() { + return this.harFilesFolder; + } + + public void setHarFilesFolder(String harFilesFolder) { + this.harFilesFolder = harFilesFolder; + } + + public String getDcaeBeHost() { + return dcaeBeHost; + } + + public void setDcaeBeHost(String dcaeBeHost) { + this.dcaeBeHost = dcaeBeHost; + } + + public String getDcaeBePort() { + return dcaeBePort; + } + + public void setDcaeBePort(String dcaeBePort) { + this.dcaeBePort = dcaeBePort; + } + + public String getApiPath() { + return apiPath; + } + + public void setApiPath(String apiPath) { + this.apiPath = apiPath; + } + + public String getRuleEditorUrl() { + return ruleEditorUrl; + } + + public void setRuleEditorUrl(String ruleEditorUrl) { + this.ruleEditorUrl = ruleEditorUrl; + } + + + public static synchronized T loadConfigFile(File configFile, Class clazz) { + InputStream in = null; + T config = null; + + try { + String absolutePath = configFile.getAbsolutePath(); + in = Files.newInputStream(Paths.get(absolutePath, new String[0]), new OpenOption[0]); + Yaml yaml = new Yaml(); + config = yaml.loadAs(in, clazz); + } catch (IOException var14) { + var14.printStackTrace(); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException var13) { + var13.printStackTrace(); + } + } + + } + + return config; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/RestResponse.java b/src/main/java/org/onap/dcae/ci/entities/RestResponse.java new file mode 100644 index 0000000..4e5b60f --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/RestResponse.java @@ -0,0 +1,57 @@ +package org.onap.dcae.ci.entities; + +import java.util.List; +import java.util.Map; + +public class RestResponse { + Integer statusCode; + String response; + Map> headerFields; + String responseMessage; + + public RestResponse() { + } + + public RestResponse(Integer errorCode, String response, Map> headerFields, String responseMessage) { + this.statusCode = errorCode; + this.response = response; + this.headerFields = headerFields; + this.responseMessage = responseMessage; + } + + public Integer getStatusCode() { + return this.statusCode; + } + + public void setStatusCode(Integer errorCode) { + this.statusCode = errorCode; + } + + public String getResponse() { + return this.response; + } + + public void setResponse(String response) { + this.response = response; + } + + public Map> getHeaderFields() { + return this.headerFields; + } + + public void setHeaderFields(Map> headerFields) { + this.headerFields = headerFields; + } + + public String getResponseMessage() { + return this.responseMessage; + } + + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + public String toString() { + return "RestResponse [errorCode=" + this.statusCode + ", response=" + this.response + ", headerFields=" + this.headerFields + ", responseMessage=" + this.responseMessage + "]"; + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/items/Artifact.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Artifact.java new file mode 100644 index 0000000..eae61ea --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Artifact.java @@ -0,0 +1,109 @@ + +package org.onap.dcae.ci.entities.composition.items; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Artifact { + + @SerializedName("artifactChecksum") + @Expose + private String artifactChecksum; + @SerializedName("artifactType") + @Expose + private String artifactType; + @SerializedName("artifactUUID") + @Expose + private String artifactUUID; + @SerializedName("artifactVersion") + @Expose + private String artifactVersion; + @SerializedName("artifactName") + @Expose + private String artifactName; + @SerializedName("artifactGroupType") + @Expose + private String artifactGroupType; + @SerializedName("artifactURL") + @Expose + private String artifactURL; + @SerializedName("artifactDescription") + @Expose + private String artifactDescription; + @SerializedName("artifactLabel") + @Expose + private String artifactLabel; + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public String getArtifactType() { + return artifactType; + } + + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public String getArtifactUUID() { + return artifactUUID; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } + + public String getArtifactVersion() { + return artifactVersion; + } + + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public String getArtifactGroupType() { + return artifactGroupType; + } + + public void setArtifactGroupType(String artifactGroupType) { + this.artifactGroupType = artifactGroupType; + } + + public String getArtifactURL() { + return artifactURL; + } + + public void setArtifactURL(String artifactURL) { + this.artifactURL = artifactURL; + } + + public String getArtifactDescription() { + return artifactDescription; + } + + public void setArtifactDescription(String artifactDescription) { + this.artifactDescription = artifactDescription; + } + + public String getArtifactLabel() { + return artifactLabel; + } + + public void setArtifactLabel(String artifactLabel) { + this.artifactLabel = artifactLabel; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/items/Data.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Data.java new file mode 100644 index 0000000..f7f44d3 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Data.java @@ -0,0 +1,21 @@ + +package org.onap.dcae.ci.entities.composition.items; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Data { + + @SerializedName("element") + @Expose + private Element element; + + public Element getElement() { + return element; + } + + public void setElement(Element element) { + this.element = element; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/items/DcaeComponents.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/DcaeComponents.java new file mode 100644 index 0000000..c434a0d --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/DcaeComponents.java @@ -0,0 +1,56 @@ + +package org.onap.dcae.ci.entities.composition.items; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.lang.*; + +public class DcaeComponents { + + @SerializedName("id") + @Expose + private Object id; + @SerializedName("timestamp") + @Expose + private Integer timestamp; + @SerializedName("data") + @Expose + private Data data; + @SerializedName("error") + @Expose + private java.lang.Error error; + + public Object getId() { + return id; + } + + public void setId(Object id) { + this.id = id; + } + + public Integer getTimestamp() { + return timestamp; + } + + public void setTimestamp(Integer timestamp) { + this.timestamp = timestamp; + } + + public Data getData() { + return data; + } + + public void setData(Data data) { + this.data = data; + } + + public java.lang.Error getError() { + return error; + } + + public void setError(java.lang.Error error) { + this.error = error; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/items/Element.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Element.java new file mode 100644 index 0000000..64c6601 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Element.java @@ -0,0 +1,55 @@ + +package org.onap.dcae.ci.entities.composition.items; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Element { + + @SerializedName("itemId") + @Expose + private String itemId; + @SerializedName("name") + @Expose + private String name; + @SerializedName("id") + @Expose + private String id; + @SerializedName("items") + @Expose + private List items = null; + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/items/Error.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Error.java new file mode 100644 index 0000000..bad41a1 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Error.java @@ -0,0 +1,8 @@ + +package org.onap.dcae.ci.entities.composition.items; + + +public class Error { + + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/items/Item.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Item.java new file mode 100644 index 0000000..a184886 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Item.java @@ -0,0 +1,220 @@ + +package org.onap.dcae.ci.entities.composition.items; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Item { + + @SerializedName("lifecycleState") + @Expose + private String lifecycleState; + @SerializedName("models") + @Expose + private List models = null; + @SerializedName("subCategory") + @Expose + private String subCategory; + @SerializedName("catalog") + @Expose + private String catalog; + @SerializedName("lastUpdaterUserId") + @Expose + private String lastUpdaterUserId; + @SerializedName("description") + @Expose + private String description; + @SerializedName("uuid") + @Expose + private String uuid; + @SerializedName("version") + @Expose + private String version; + @SerializedName("itemId") + @Expose + private String itemId; + @SerializedName("catalogId") + @Expose + private Integer catalogId; + @SerializedName("toscaModelURL") + @Expose + private String toscaModelURL; + @SerializedName("name") + @Expose + private String name; + @SerializedName("invariantUUID") + @Expose + private String invariantUUID; + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("category") + @Expose + private String category; + @SerializedName("lastUpdaterFullName") + @Expose + private String lastUpdaterFullName; + @SerializedName("toscaResourceName") + @Expose + private String toscaResourceName; + @SerializedName("resourceType") + @Expose + private String resourceType; + @SerializedName("artifacts") + @Expose + private List artifacts = null; + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public List getModels() { + return models; + } + + public void setModels(List models) { + this.models = models; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getCatalog() { + return catalog; + } + + public void setCatalog(String catalog) { + this.catalog = catalog; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public Integer getCatalogId() { + return catalogId; + } + + public void setCatalogId(Integer catalogId) { + this.catalogId = catalogId; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public String getToscaResourceName() { + return toscaResourceName; + } + + public void setToscaResourceName(String toscaResourceName) { + this.toscaResourceName = toscaResourceName; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/items/Model.java b/src/main/java/org/onap/dcae/ci/entities/composition/items/Model.java new file mode 100644 index 0000000..2b3a85b --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/items/Model.java @@ -0,0 +1,65 @@ + +package org.onap.dcae.ci.entities.composition.items; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Model { + + @SerializedName("itemId") + @Expose + private String itemId; + @SerializedName("name") + @Expose + private String name; + @SerializedName("description") + @Expose + private String description; + @SerializedName("id") + @Expose + private String id; + @SerializedName("version") + @Expose + private String version; + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Artifact.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Artifact.java new file mode 100644 index 0000000..4d095ab --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Artifact.java @@ -0,0 +1,109 @@ + +package org.onap.dcae.ci.entities.composition.rightMenu.element; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Artifact { + + @SerializedName("artifactChecksum") + @Expose + private String artifactChecksum; + @SerializedName("artifactType") + @Expose + private String artifactType; + @SerializedName("artifactUUID") + @Expose + private String artifactUUID; + @SerializedName("artifactVersion") + @Expose + private String artifactVersion; + @SerializedName("artifactName") + @Expose + private String artifactName; + @SerializedName("artifactGroupType") + @Expose + private String artifactGroupType; + @SerializedName("artifactURL") + @Expose + private String artifactURL; + @SerializedName("artifactDescription") + @Expose + private String artifactDescription; + @SerializedName("artifactLabel") + @Expose + private String artifactLabel; + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public String getArtifactType() { + return artifactType; + } + + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public String getArtifactUUID() { + return artifactUUID; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } + + public String getArtifactVersion() { + return artifactVersion; + } + + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public String getArtifactGroupType() { + return artifactGroupType; + } + + public void setArtifactGroupType(String artifactGroupType) { + this.artifactGroupType = artifactGroupType; + } + + public String getArtifactURL() { + return artifactURL; + } + + public void setArtifactURL(String artifactURL) { + this.artifactURL = artifactURL; + } + + public String getArtifactDescription() { + return artifactDescription; + } + + public void setArtifactDescription(String artifactDescription) { + this.artifactDescription = artifactDescription; + } + + public String getArtifactLabel() { + return artifactLabel; + } + + public void setArtifactLabel(String artifactLabel) { + this.artifactLabel = artifactLabel; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Item.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Item.java new file mode 100644 index 0000000..aa96b43 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Item.java @@ -0,0 +1,220 @@ + +package org.onap.dcae.ci.entities.composition.rightMenu.element; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Item { + + @SerializedName("lifecycleState") + @Expose + private String lifecycleState; + @SerializedName("models") + @Expose + private List models = null; + @SerializedName("subCategory") + @Expose + private String subCategory; + @SerializedName("catalog") + @Expose + private String catalog; + @SerializedName("lastUpdaterUserId") + @Expose + private String lastUpdaterUserId; + @SerializedName("description") + @Expose + private String description; + @SerializedName("uuid") + @Expose + private String uuid; + @SerializedName("version") + @Expose + private String version; + @SerializedName("itemId") + @Expose + private String itemId; + @SerializedName("catalogId") + @Expose + private Integer catalogId; + @SerializedName("toscaModelURL") + @Expose + private String toscaModelURL; + @SerializedName("name") + @Expose + private String name; + @SerializedName("invariantUUID") + @Expose + private String invariantUUID; + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("category") + @Expose + private String category; + @SerializedName("lastUpdaterFullName") + @Expose + private String lastUpdaterFullName; + @SerializedName("toscaResourceName") + @Expose + private String toscaResourceName; + @SerializedName("resourceType") + @Expose + private String resourceType; + @SerializedName("artifacts") + @Expose + private List artifacts = null; + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public List getModels() { + return models; + } + + public void setModels(List models) { + this.models = models; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getCatalog() { + return catalog; + } + + public void setCatalog(String catalog) { + this.catalog = catalog; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public Integer getCatalogId() { + return catalogId; + } + + public void setCatalogId(Integer catalogId) { + this.catalogId = catalogId; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public String getToscaResourceName() { + return toscaResourceName; + } + + public void setToscaResourceName(String toscaResourceName) { + this.toscaResourceName = toscaResourceName; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java new file mode 100644 index 0000000..d7ed2cb --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/ItemsElement.java @@ -0,0 +1,55 @@ + +package org.onap.dcae.ci.entities.composition.rightMenu.element; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class ItemsElement { + + @SerializedName("itemId") + @Expose + private String itemId; + @SerializedName("name") + @Expose + private String name; + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("items") + @Expose + private List items = null; + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Model.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Model.java new file mode 100644 index 0000000..4541aaf --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Model.java @@ -0,0 +1,65 @@ + +package org.onap.dcae.ci.entities.composition.rightMenu.element; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Model { + + @SerializedName("itemId") + @Expose + private String itemId; + @SerializedName("name") + @Expose + private String name; + @SerializedName("description") + @Expose + private String description; + @SerializedName("id") + @Expose + private String id; + @SerializedName("version") + @Expose + private String version; + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Service.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Service.java new file mode 100644 index 0000000..3c33535 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/element/Service.java @@ -0,0 +1,21 @@ + +package org.onap.dcae.ci.entities.composition.rightMenu.element; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Service { + + @SerializedName("element") + @Expose + private ItemsElement element; + + public ItemsElement getElement() { + return element; + } + + public void setElement(ItemsElement element) { + this.element = element; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Element.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Element.java new file mode 100644 index 0000000..350a350 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Element.java @@ -0,0 +1,76 @@ +package org.onap.dcae.ci.entities.composition.rightMenu.elements; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Element { + +@SerializedName("itemId") +@Expose +private String itemId; +@SerializedName("catalogId") +@Expose +private Integer catalogId; +@SerializedName("catalog") +@Expose +private String catalog; +@SerializedName("name") +@Expose +private String name; +@SerializedName("id") +@Expose +private Integer id; +@SerializedName("labels") +@Expose +private List labels = null; + +public String getItemId() { +return itemId; +} + +public void setItemId(String itemId) { +this.itemId = itemId; +} + +public Integer getCatalogId() { +return catalogId; +} + +public void setCatalogId(Integer catalogId) { +this.catalogId = catalogId; +} + +public String getCatalog() { +return catalog; +} + +public void setCatalog(String catalog) { +this.catalog = catalog; +} + +public String getName() { +return name; +} + +public void setName(String name) { +this.name = name; +} + +public Integer getId() { +return id; +} + +public void setId(Integer id) { +this.id = id; +} + +public List getLabels() { +return labels; +} + +public void setLabels(List labels) { +this.labels = labels; +} + +} \ No newline at end of file diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Elements.java b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Elements.java new file mode 100644 index 0000000..b5dad46 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/rightMenu/elements/Elements.java @@ -0,0 +1,18 @@ +package org.onap.dcae.ci.entities.composition.rightMenu.elements; +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Elements { + @SerializedName("elements") + @Expose + private List elements = null; + + public List getElements() { + return elements; + } + + public void setElements(List elements) { + this.elements = elements; + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/services/CiService.java b/src/main/java/org/onap/dcae/ci/entities/composition/services/CiService.java new file mode 100644 index 0000000..5a272b6 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/services/CiService.java @@ -0,0 +1,11 @@ +package org.onap.dcae.ci.entities.composition.services; + +import org.onap.dcae.ci.entities.sdc.SdcService; +import org.onap.sdc.dcae.composition.services.Service; + +public class CiService extends Service { + // partial construction - converts from internal SDC object to dcae-ci object (external SDC) + public CiService(SdcService service) { + super(service.getName(), service.getUuid(), service.getVersion()); + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/composition/services/Vfi.java b/src/main/java/org/onap/dcae/ci/entities/composition/services/Vfi.java new file mode 100644 index 0000000..4b084d6 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/composition/services/Vfi.java @@ -0,0 +1,21 @@ +package org.onap.dcae.ci.entities.composition.services; + +import org.onap.dcae.ci.entities.sdc.SdcService; + +public class Vfi { + private String name; + private SdcService container; + + public Vfi(String name, SdcService container) { + this.name = name; + this.container = container; + } + + public String getName() { + return name; + } + + public SdcService getContainer() { + return container; + } +} \ No newline at end of file diff --git a/src/main/java/org/onap/dcae/ci/entities/rule_editor/SaveRuleError.java b/src/main/java/org/onap/dcae/ci/entities/rule_editor/SaveRuleError.java new file mode 100644 index 0000000..407cc37 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/rule_editor/SaveRuleError.java @@ -0,0 +1,27 @@ +package org.onap.dcae.ci.entities.rule_editor; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class SaveRuleError { + private Map requestError; + private String notes; + + @JsonCreator + public SaveRuleError( + @JsonProperty("requestError") Map requestError, @JsonProperty("notes") String notes) { + this.requestError = requestError; + this.notes = notes; + } + + + + public List getFormattedErrors() { + List> errors = (List>)requestError.get("serviceExceptions"); + return errors.stream().map(e -> e.get("formattedErrorMessage")).collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcCategory.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcCategory.java new file mode 100644 index 0000000..8d14aa2 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcCategory.java @@ -0,0 +1,28 @@ +package org.onap.dcae.ci.entities.sdc; + +import java.util.Arrays; +import java.util.List; + +public class SdcCategory { + + private String name; + private List subcategories; + + + public String getName() { + return name; + } + + public List getSubcategories() { + return subcategories; + } + + public SdcCategory(String categoryName) { + this.name = categoryName; + } + + public SdcCategory(String categoryName, String subCategoryName){ + this(categoryName); + this.subcategories = Arrays.asList(new SdcCategory(subCategoryName)); + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponent.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponent.java new file mode 100644 index 0000000..1dc7206 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponent.java @@ -0,0 +1,113 @@ +package org.onap.dcae.ci.entities.sdc; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class SdcComponent { + + private String name; + private String description; + private List tags; + private String contactId; + private String icon; + private String uuid; + + private String lastUpdaterUserId; + private String uniqueId; + private String version; + private String resourceType; + private List categories; + private Map allVersions; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public String getContactId() { + return contactId; + } + + public void setContactId(String contactId) { + this.contactId = contactId; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public Map getAllVersions() { + return allVersions; + } + + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentFactory.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentFactory.java new file mode 100644 index 0000000..1cb9cbc --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentFactory.java @@ -0,0 +1,41 @@ +package org.onap.dcae.ci.entities.sdc; + +import org.apache.commons.lang3.RandomStringUtils; + +import org.onap.dcae.ci.utilities.DcaeRestClient; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class SdcComponentFactory { + + private SdcComponentFactory(){} + + public static SdcService getDefaultService() { + SdcService service = new SdcService(); + service.setCategories(Arrays.asList(new SdcCategory("Mobility"))); + setDefaultComponentFields(service, "CiService"); + return service; + } + + public static SdcResource getDefaultResource() { + SdcResource resource = new SdcResource(); + resource.setVendorName("vendorName"); + resource.setVendorRelease("1.1"); + resource.setResourceType("VF"); + resource.setCategories(Arrays.asList(new SdcCategory("Generic", "Infrastructure"))); + setDefaultComponentFields(resource, "CiResource"); + return resource; + } + + private static void setDefaultComponentFields(SdcComponent component, String name) { + component.setName(name.concat(RandomStringUtils.randomAlphanumeric(4))); + List tags = new ArrayList<>(); + tags.add(component.getName()); + component.setTags(tags); + component.setDescription("Ci component description"); + component.setIcon("defaultIcon"); + component.setContactId(DcaeRestClient.getDefaultUserId()); + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentInstance.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentInstance.java new file mode 100644 index 0000000..d300908 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentInstance.java @@ -0,0 +1,20 @@ +package org.onap.dcae.ci.entities.sdc; + + +public class SdcComponentInstance { + + String componentUid; + String description; + String posX; + String posY; + String name; + String uniqueId; + + public SdcComponentInstance(SdcResource vf) { + this.componentUid = vf.getUniqueId(); + this.posX = "20"; + this.posY = "20"; + this.name = vf.getName(); + this.description = vf.getDescription(); + } +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentMetadata.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentMetadata.java new file mode 100644 index 0000000..c284e5d --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcComponentMetadata.java @@ -0,0 +1,12 @@ +package org.onap.dcae.ci.entities.sdc; + + +public class SdcComponentMetadata { + + private SdcComponent metadata; + + public SdcComponent getMetadata() { + return metadata; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcResource.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcResource.java new file mode 100644 index 0000000..8cd5605 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcResource.java @@ -0,0 +1,26 @@ +package org.onap.dcae.ci.entities.sdc; + + +public class SdcResource extends SdcComponent { + + private String vendorName; + private String vendorRelease; + + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorRelease() { + return vendorRelease; + } + + public void setVendorRelease(String vendorRelease) { + this.vendorRelease = vendorRelease; + } + +} diff --git a/src/main/java/org/onap/dcae/ci/entities/sdc/SdcService.java b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcService.java new file mode 100644 index 0000000..4ee3ac0 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/entities/sdc/SdcService.java @@ -0,0 +1,37 @@ +package org.onap.dcae.ci.entities.sdc; + +import org.onap.dcae.ci.entities.sdc.SdcComponent; + + +public class SdcService extends SdcComponent { + + private String projectCode = "12345"; + private String serviceRole = "";// empty string is valid + private String serviceType = "";// empty string is valid + private String instantiationType = "Macro"; + + + public void setServiceRole(String serviceRole){ + this.serviceRole = serviceRole; + } + + public String getServiceRole(){ + return serviceRole; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceType(){ + return serviceType; + } + + public void setInstantiationType(String instantiationType) { + this.instantiationType = instantiationType; + } + + public String getInstantiationType(){ + return instantiationType; + } +} diff --git a/src/main/java/org/onap/dcae/ci/enums/HttpHeaderEnum.java b/src/main/java/org/onap/dcae/ci/enums/HttpHeaderEnum.java new file mode 100644 index 0000000..aed1c53 --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/enums/HttpHeaderEnum.java @@ -0,0 +1,25 @@ +package org.onap.dcae.ci.enums; + +public enum HttpHeaderEnum { + Content_MD5("Content-MD5"), + USER_ID("USER_ID"), + CONTENT_TYPE("Content-Type"), + ACCEPT("Accept"), + X_ECOMP_REQUEST_ID_HEADER("X-ECOMP-RequestID"), + CACHE_CONTROL("Cache-Control"), + X_ECOMP_INSTANCE_ID("X-ECOMP-InstanceID"), + AUTHORIZATION("Authorization"), + CONTENT_LENGTH("Content-Length"), + X_ECOMP_SERVICE_ID_HEADER("X-ECOMP-ServiceID"); + + + String value; + + private HttpHeaderEnum(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } +} diff --git a/src/main/java/org/onap/dcae/ci/report/ExtentManager.java b/src/main/java/org/onap/dcae/ci/report/ExtentManager.java new file mode 100644 index 0000000..cbf28cb --- /dev/null +++ b/src/main/java/org/onap/dcae/ci/report/ExtentManager.java @@ -0,0 +1,192 @@ +package org.onap.dcae.ci.report; + +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.apache.commons.io.FileUtils; +import org.onap.dcae.ci.config.Configuration; +import org.onap.dcae.ci.utilities.SetupReport; +import org.testng.ITestContext; + +import java.io.*; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Properties; + +public class ExtentManager { + + private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; + private static ExtentReports extent; + private static ExtentHtmlReporter htmlReporter; + private static ExtentXReporter extentxReporter; + private static final String icon = "$(document).ready(function() {" + "\n" + + "$('.brand-logo').html('').prepend(\"