summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mod/bpgenerator/TestCases/imports/imports.yaml2
-rw-r--r--mod/bpgenerator/TestCases/imports/importsWithBlanks.yaml3
-rw-r--r--mod/bpgenerator/pom.xml72
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java39
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java148
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java15
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java122
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java40
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java46
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java4
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java132
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java121
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java13
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java16
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java15
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java5
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java211
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java11
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java5
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java10
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java10
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java181
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java248
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java151
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java102
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java118
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java229
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java226
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java244
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java52
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java2
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java245
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java224
-rw-r--r--mod/bpgenerator/version.properties4
-rw-r--r--mod/runtimeapi/pom.xml2
-rw-r--r--mod/runtimeapi/runtime-core/pom.xml6
-rw-r--r--mod/runtimeapi/runtime-web/pom.xml6
-rw-r--r--mod2/auth-service/Dockerfile14
-rw-r--r--mod2/auth-service/pom.xml222
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/AuthServiceApplication.java40
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/DataLoader.java97
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/AuthController.java171
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/RoleController.java58
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/UserController.java96
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/AppExceptionHandler.java52
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/IllegalUserOperationException.java34
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/RoleNotExistsException.java34
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/UserAlreadyExistsException.java34
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/UserNotFoundException.java34
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/GenericResponse.java40
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/JwtResponse.java50
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/LoginRequest.java43
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/ModUser.java75
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/Role.java50
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/SignupRequest.java53
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/UpdateUserRequest.java47
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/repositories/RoleRepository.java37
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/repositories/UserRepository.java40
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/WebSecurityConfigurer.java92
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/AuthEntryPointJwt.java51
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/AuthTokenFilter.java81
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/JwtUtils.java90
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/services/UserDetailsImpl.java127
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/services/UserDetailsServiceImpl.java100
-rw-r--r--mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/services/MODUserDetailService.java56
-rw-r--r--mod2/auth-service/src/main/resources/application.properties32
-rw-r--r--mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/AuthObjectMother.java85
-rw-r--r--mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/RoleObjectMother.java56
-rw-r--r--mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/UserObjectMother.java100
-rw-r--r--mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/util/TestUtil.java60
-rw-r--r--mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/AuthControllerTest.java149
-rw-r--r--mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/RoleControllerTest.java109
-rw-r--r--mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/UserControllerTest.java168
-rw-r--r--mod2/auth-service/src/test/resources/application.properties1
-rw-r--r--mod2/auth-service/src/test/resources/http/requests/AuthLoginRequest.json4
-rw-r--r--mod2/auth-service/src/test/resources/http/requests/AuthSignupRequest.json6
-rw-r--r--mod2/auth-service/src/test/resources/specification/componentSpec_hello_world-with-dmaap.json149
-rw-r--r--mod2/auth-service/src/test/resources/specification/policy_json_sample_3.json28
-rw-r--r--mod2/catalog-service/Dockerfile14
-rw-r--r--mod2/catalog-service/lombok.config1
-rw-r--r--mod2/catalog-service/pom.xml201
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/ModCatalogApplication.java68
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockDeploymentArtifactGenerator.java45
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockSpecificationValidationStratergy.java42
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMicroservice.java65
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsLocation.java29
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsStatus.java28
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsType.java32
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/common/AuditFields.java51
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifact.java51
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactFilter.java40
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactSearch.java38
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactStatus.java30
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/MsInstanceInfo.java33
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ErrorMessages.java33
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/MissingRequestBodyException.java24
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/OperationNotAllowedException.java27
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ReleaseNotSupportedException.java24
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ResourceConflictException.java27
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceNotFoundException.java27
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceTagAlreadyExists.java24
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceTagInvalid.java24
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMsServiceNameAlreadyExists.java24
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMsServiceNameInvalid.java24
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/common/UserNotPassedException.java27
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/BlueprintFileNameCreateException.java27
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/DeploymentArtifactNotFound.java27
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/StatusChangeNotValidException.java28
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/msinstance/MsInstanceAlreadyExistsException.java24
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/msinstance/MsInstanceNotFoundException.java27
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/specification/SpecificationInvalid.java38
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/specification/SpecificationNotFoundException.java24
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/DeploymentArtifactsRef.java36
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/MsInstance.java56
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/MsInstanceStatus.java28
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/DeploymentArtifactPatchRequest.java40
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/ErrorResponse.java35
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/GenericErrorResponse.java54
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MicroserviceCreateRequest.java59
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MicroserviceUpdateRequest.java52
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MsInstanceRequest.java52
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MsInstanceUpdateRequest.java42
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/SpecificationRequest.java45
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/SuccessResponse.java34
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/DeploymentType.java28
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/Specification.java52
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/SpecificationStatus.java28
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/basemicroservice/BaseMicroserviceMongoGateway.java71
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/basemicroservice/BaseMicroserviceMongoRepo.java40
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/deploymentartifact/DeploymentArtifactMongoGateway.java86
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/deploymentartifact/DeploymentArtifactMongoRepo.java37
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/microserviceinstance/MsInstanceMongoGateway.java61
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/microserviceinstance/MsInstanceMongoRepo.java38
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/specification/SpecificationMongoGateway.java48
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/specification/SpecificationMongoRepo.java38
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/AppExceptionHandler.java149
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/BaseMicroserviceController.java70
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/DeploymentArtifactController.java115
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/MicroserviceInstanceController.java75
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/SpecificationController.java62
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/BaseMicroserviceGateway.java45
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/MsService.java47
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/MsServiceImpl.java257
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/ArtifactFileNameCreator.java59
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactGateway.java45
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactGeneratorStrategy.java32
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactService.java51
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImpl.java205
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactStatusChangeHandler.java77
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceGateway.java40
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceService.java51
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceServiceImpl.java213
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceStatusChangeHandler.java75
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationGateway.java37
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationService.java40
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationServiceImpl.java138
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationValidationStratergy.java30
-rw-r--r--mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationValidatorService.java61
-rw-r--r--mod2/catalog-service/src/main/resources/application.properties24
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/BaseMsObjectMother.java131
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/DeploymentArtifactObjectMother.java222
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/MsInstanceObjectMother.java112
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/SpecificationObjectMother.java41
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/persistence/DeploymentArtifactGatewayTest.java147
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/util/TestUtil.java53
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/BaseMicroserviceControllerTest.java165
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/DeploymentArtifactControllerTest.java170
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/MicroserviceInstanceControllerTest.java145
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/MsRequestValidationTest.java87
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/SpecificationControllerTest.java79
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsInstanceServiceImplTest.java209
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsInstanceStatusChangeHandlerTest.java92
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsServiceImplTest.java217
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/SpecificationServiceTest.java103
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/ArtifactFileNameCreatorTest.java89
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java250
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactStatusChangeHandlerTest.java106
-rw-r--r--mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/SearchDeploymentArtifactsTest.java90
-rw-r--r--mod2/catalog-service/src/test/resources/application.properties1
-rw-r--r--mod2/catalog-service/src/test/resources/http/requests/CreateSpecificationRequest.json180
-rw-r--r--mod2/catalog-service/src/test/resources/http/requests/CreateSpecificationResponse.json188
-rw-r--r--mod2/catalog-service/src/test/resources/specification/componentSpec_hello_world-with-dmaap.json149
-rw-r--r--mod2/catalog-service/src/test/resources/specification/policy_json_sample_3.json28
-rw-r--r--releases/1.1.0-distributorapi-container.yaml9
-rw-r--r--releases/1.1.0-runtimeapi-container.yaml9
-rw-r--r--releases/1.5.0-blueprint-generator.yaml4
-rw-r--r--releases/1.5.1-blueprint-generator.yaml4
-rw-r--r--releases/2.12.3-onboardingapi-container.yaml9
204 files changed, 12083 insertions, 1379 deletions
diff --git a/mod/bpgenerator/TestCases/imports/imports.yaml b/mod/bpgenerator/TestCases/imports/imports.yaml
new file mode 100644
index 0000000..4b52b8a
--- /dev/null
+++ b/mod/bpgenerator/TestCases/imports/imports.yaml
@@ -0,0 +1,2 @@
+imports: ['https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml', 'plugin:k8splugin?version=3.4.1',
+ 'plugin:pgaas?version=1.3.0', 'plugin:clamppolicyplugin?version=1.1.0', 'plugin:dmaap?version=1.5.0']
diff --git a/mod/bpgenerator/TestCases/imports/importsWithBlanks.yaml b/mod/bpgenerator/TestCases/imports/importsWithBlanks.yaml
new file mode 100644
index 0000000..242c2a9
--- /dev/null
+++ b/mod/bpgenerator/TestCases/imports/importsWithBlanks.yaml
@@ -0,0 +1,3 @@
+imports: ['https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml', 'plugin:k8splugin?version=3.4.1',
+ '', ' ', ' ', 'plugin:pgaas?version=1.3.0', 'plugin:clamppolicyplugin?version=1.1.0',
+ 'plugin:dmaap?version=1.5.0']
diff --git a/mod/bpgenerator/pom.xml b/mod/bpgenerator/pom.xml
index 96ceb41..86009f3 100644
--- a/mod/bpgenerator/pom.xml
+++ b/mod/bpgenerator/pom.xml
@@ -29,17 +29,12 @@
</parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.5.2-SNAPSHOT</version>
<properties>
- <maven.compiler.source>1.6</maven.compiler.source>
- <maven.compiler.target>1.6</maven.compiler.target>
-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <sonar.core.codeCoveragePlugin>cobertura</sonar.core.codeCoveragePlugin>
- <sonar.java.coveragePlugin>cobertura</sonar.java.coveragePlugin>
<sonar.junit.reportsPath>${project.basedir}/target/surefire-reports</sonar.junit.reportsPath>
<sonar.surefire.reportsPath>${project.basedir}/target/surefire-reports</sonar.surefire.reportsPath>
- <sonar.cobertura.reportPaths>${project.basedir}/target/site/cobertura/coverage.xml</sonar.cobertura.reportPaths>
+ <sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<shade.main>org.onap.blueprintgenerator.core.App</shade.main>
<shade.transformer>org.apache.maven.plugins.shade.resource.ManifestResourceTransformer</shade.transformer>
</properties>
@@ -70,47 +65,6 @@
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <instrumentation>
- <includes>
- <include>**/*.class</include>
- </includes>
- </instrumentation>
- <encoding>UTF-8</encoding>
- </configuration>
-
- <executions>
-
- <execution>
- <id>clean</id>
- <!-- > <phase>pre-site</phase> -->
- <phase>pre-site</phase>
- <goals>
- <goal>cobertura</goal>
- </goals>
- </execution>
-
-
- <execution>
- <id>instrument</id>
- <phase>site</phase>
- <goals>
- <goal>instrument</goal>
- <goal>cobertura</goal>
- </goals>
- <configuration>
- <encoding>UTF-8</encoding>
- </configuration>
- </execution>
-
- </executions>
-
- </plugin>
-
- <plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.2</version>
@@ -141,31 +95,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>8</source>
- <target>8</target>
+ <source>11</source>
+ <target>11</target>
</configuration>
</plugin>
</plugins>
-
</build>
- <reporting>
- <plugins>
- <plugin>
- <!-- use mvn cobertura:cobertura to generate cobertura reports -->
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <formats>
- <format>xml</format>
- </formats>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
-
<dependencies>
<dependency>
<groupId>junit</groupId>
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java
index 16eca51..c3b1453 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java
@@ -27,6 +27,10 @@ import java.util.LinkedHashMap;
@UtilityClass
public class BlueprintHelper {
+ public static final String INTEGER_TYPE = "integer";
+ public static final String BOOLEAN_TYPE = "boolean";
+ public static final String STRING_TYPE = "string";
+
public static LinkedHashMap<String, Object> createInputValue(String type, String description, Object defaultValue) {
LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
inputMap.put("type", type);
@@ -34,4 +38,39 @@ public class BlueprintHelper {
inputMap.put("default", defaultValue);
return inputMap;
}
+
+ public static LinkedHashMap<String, Object> createInputValue(String type, Object defaultValue) {
+ LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
+ inputMap.put("type", type);
+ inputMap.put("default", defaultValue);
+ return inputMap;
+ }
+
+ public static LinkedHashMap<String, Object> createIntegerInput(String description, Object defaultValue){
+ return createInputValue(INTEGER_TYPE, description, defaultValue);
+ }
+
+ public static LinkedHashMap<String, Object> createBooleanInput(String description, Object defaultValue){
+ return createInputValue(BOOLEAN_TYPE, description, defaultValue);
+ }
+
+ public static LinkedHashMap<String, Object> createStringInput(String description, Object defaultValue){
+ return createInputValue(STRING_TYPE, description, defaultValue);
+ }
+
+ public static LinkedHashMap<String, Object> createStringInput(Object defaultValue){
+ return createInputValue(STRING_TYPE, defaultValue);
+ }
+
+ public static String joinUnderscore(String firstValue, String secondValue){
+ return firstValue + "_" + secondValue;
+ }
+
+ public static boolean isDataRouterType(String type) {
+ return type.equals("data_router") || type.equals("data router");
+ }
+
+ public static boolean isMessageRouterType(String type) {
+ return type.equals("message_router") || type.equals("message router");
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
index 5d4131b..f9fa2cb 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
@@ -18,18 +18,32 @@
*/
-
package org.onap.blueprintgenerator.core;
-
-
-
+import java.util.ArrayList;
+import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;
+import org.onap.blueprintgenerator.models.componentspec.Artifacts;
+import org.onap.blueprintgenerator.models.componentspec.Auxilary;
+import org.onap.blueprintgenerator.models.componentspec.CallsObj;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+import org.onap.blueprintgenerator.models.componentspec.Container;
+import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
+import org.onap.blueprintgenerator.models.componentspec.Host;
+import org.onap.blueprintgenerator.models.componentspec.Parameters;
+import org.onap.blueprintgenerator.models.componentspec.Policy;
+import org.onap.blueprintgenerator.models.componentspec.ProvidesObj;
+import org.onap.blueprintgenerator.models.componentspec.Publishes;
+import org.onap.blueprintgenerator.models.componentspec.Self;
+import org.onap.blueprintgenerator.models.componentspec.Services;
+import org.onap.blueprintgenerator.models.componentspec.Streams;
+import org.onap.blueprintgenerator.models.componentspec.Subscribes;
+import org.onap.blueprintgenerator.models.componentspec.Volumes;
@Getter @Setter
public class TestComponentSpec {
- private String cs = "{\r\n" +
+ private String componentSpecAsString = "{\r\n" +
" \"self\": {\r\n" +
" \"component_type\": \"docker\",\r\n" +
" \"description\": \"Test component spec\",\r\n" +
@@ -129,4 +143,128 @@ public class TestComponentSpec {
" }] \r\n" +
"\r\n" +
"}";
+ private ComponentSpec componentSpec;
+
+ public TestComponentSpec() {
+ this.componentSpec = createComponentSpec();
+ }
+
+ private ComponentSpec createComponentSpec(){
+ //Manually fill a component spec object with the values from the file itself
+ ComponentSpec manualSpec = new ComponentSpec();
+
+ Self self = new Self();
+ self.setComponent_type("docker");
+ self.setDescription("Test component spec");
+ self.setName("test.component.spec");
+ self.setVersion("1.0.1");
+ manualSpec.setSelf(self);
+
+ Services services = new Services();
+ CallsObj[] calls = new CallsObj[0];
+ ProvidesObj[] provides = new ProvidesObj[0];
+ services.setCalls(calls);
+ services.setProvides(provides);
+ manualSpec.setServices(null);
+
+ Streams streams = new Streams();
+ Publishes[] publishes = new Publishes[2];
+ Publishes pub1 = new Publishes();
+ pub1.setConfig_key("TEST-PUB-DR");
+ pub1.setFormat("dataformat_Hello_World_PM");
+ pub1.setType("data_router");
+ pub1.setVersion("1.0.0");
+
+ Publishes pub2 = new Publishes();
+ pub2.setConfig_key("TEST-PUB-MR");
+ pub2.setFormat("dataformat_Hello_World_PM");
+ pub2.setType("message_router");
+ pub2.setVersion("1.0.0");
+ publishes[0] = pub1;
+ publishes[1] = pub2;
+ streams.setPublishes(publishes);
+
+ Subscribes[] subscribes = new Subscribes[2];
+ Subscribes sub1 = new Subscribes();
+ sub1.setConfig_key("TEST-SUB-MR");
+ sub1.setFormat("dataformat_Hello_World_PM");
+ sub1.setRoute("/TEST_HELLO_WORLD_SUB_MR");
+ sub1.setType("message_router");
+ sub1.setVersion("1.0.0");
+
+ Subscribes sub2 = new Subscribes();
+ sub2.setConfig_key("TEST-SUB-DR");
+ sub2.setFormat("dataformat_Hello_World_PM");
+ sub2.setRoute("/TEST-HELLO-WORLD-SUB-DR");
+ sub2.setType("data_router");
+ sub2.setVersion("1.0.0");
+ subscribes[0] = sub1;
+ subscribes[1] = sub2;
+ streams.setSubscribes(subscribes);
+
+ manualSpec.setStreams(streams);
+
+ Parameters[] parameters = new Parameters[1];
+ Parameters par1 = new Parameters();
+ par1.setName("testParam1");
+ par1.setValue("test-param-1");
+ par1.setDescription("test parameter 1");
+ par1.setSourced_at_deployment(true);
+ par1.setDesigner_editable(true);
+ par1.setPolicy_editable(true);
+ par1.setPolicy_group("Test_Parameters");
+ par1.setRequired(true);
+ par1.setType("string");
+ parameters[0] = par1;
+
+ manualSpec.setParameters(parameters);
+
+ Auxilary auxilary = new Auxilary();
+ HealthCheck healthcheck = new HealthCheck();
+ healthcheck.setInterval("300s");
+ healthcheck.setTimeout("120s");
+ healthcheck.setScript("/etc/init.d/nagios status");
+ healthcheck.setType("docker");
+ auxilary.setHealthcheck(healthcheck);
+
+ Volumes[] volumes = new Volumes[1];
+ Volumes vol1 = new Volumes();
+ Container con1 = new Container();
+ con1.setBind("/opt/app/manager/config/hostname");
+ Host host1 = new Host();
+ host1.setPath("/etc/hostname");
+ host1.setMode("ro");
+ vol1.setContainer(con1);
+ vol1.setHost(host1);
+
+ volumes[0] = vol1;
+
+ auxilary.setVolumes(volumes);
+
+ ArrayList<Object> ports = new ArrayList();
+ ports.add("80:80");
+
+ TreeMap<String, String> dataBases = new TreeMap<>();
+ dataBases.put("TestDB1", "PGaaS");
+ dataBases.put("TestDB2", "PGaaS");
+ auxilary.setDatabases(dataBases);
+
+ Policy pol = new Policy();
+ pol.setTrigger_type("docker");
+ pol.setScript_path("/opt/app/manager/bin/reconfigure.sh");
+ auxilary.setPolicy(pol);
+
+ auxilary.setPorts(ports);
+
+ manualSpec.setAuxilary(auxilary);
+
+ Artifacts[] artifacts = new Artifacts[1];
+ Artifacts art = new Artifacts();
+ art.setType("docker image");
+ art.setUri("test.tester");
+
+ artifacts[0] = art;
+ manualSpec.setArtifacts(artifacts);
+ return manualSpec;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
index b39a8ec..75864be 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
@@ -52,8 +52,7 @@ public class Appconfig {
public TreeMap<String, LinkedHashMap<String, Object>> createAppconfig(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override,
boolean isDmaap) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
//set service calls
CallsObj[] call = new CallsObj[0];
@@ -83,7 +82,7 @@ public class Appconfig {
}
//set the stream publishes
- TreeMap<String, DmaapObj> streamSubscribes = new TreeMap<String, DmaapObj>();
+ TreeMap<String, DmaapObj> streamSubscribes = new TreeMap<>();
if(cs.getStreams().getSubscribes().length != 0) {
for(Subscribes s: cs.getStreams().getSubscribes()) {
@@ -110,7 +109,7 @@ public class Appconfig {
this.setStreams_subscribes(streamSubscribes);
//set the parameters into the appconfig
- TreeMap<String, Object> parameters = new TreeMap<String, Object>();
+ TreeMap<String, Object> parameters = new TreeMap<>();
for(Parameters p: cs.getParameters()) {
String pName = p.getName();
if(p.isSourced_at_deployment()) {
@@ -119,17 +118,17 @@ public class Appconfig {
parameters.put(pName, paramInput);
if(!p.getValue().equals("")) {
- LinkedHashMap<String, Object> inputs = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> inputs = new LinkedHashMap<>();
inputs.put("type", "string");
inputs.put("default", p.getValue());
retInputs.put(pName, inputs);
} else {
- LinkedHashMap<String, Object> inputs = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> inputs = new LinkedHashMap<>();
inputs.put("type", "string");
retInputs.put(pName, inputs);
}
} else {
- if(p.getType() == "string") {
+ if("string".equals(p.getType())) {
String val =(String) p.getValue();
val = '"' + val + '"';
parameters.put(pName, val);
@@ -143,7 +142,7 @@ public class Appconfig {
GetInput ov = new GetInput();
ov.setBpInputName("service_component_name_override");
parameters.put("service_component_name_override", ov);
- LinkedHashMap<String, Object> over = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> over = new LinkedHashMap<>();
over.put("type", "string");
over.put("default", override);
retInputs.put("service_component_name_override", over);
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
index c043a9e..f2ef7aa 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
@@ -20,35 +20,27 @@
package org.onap.blueprintgenerator.models.blueprint;
-import java.io.*;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.TreeMap;
import java.util.regex.Pattern;
-
+import lombok.Getter;
+import lombok.Setter;
import org.onap.blueprintgenerator.core.Fixes;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.Parameters;
-import org.onap.blueprintgenerator.models.componentspec.Publishes;
-import org.onap.blueprintgenerator.models.componentspec.Subscribes;
import org.onap.blueprintgenerator.models.dmaapbp.DmaapBlueprint;
import org.onap.blueprintgenerator.models.onapbp.OnapBlueprint;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonProcessingException;
-//import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import org.yaml.snakeyaml.Yaml;
-
-
@Getter @Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -100,93 +92,43 @@ public class Blueprint {
public void blueprintToYaml(String outputPath, String bluePrintName, ComponentSpec cs) {
File outputFile;
-
- if(bluePrintName.equals("")) {
- String name = cs.getSelf().getName();
- if(name.contains(".")) {
- name = name.replaceAll(Pattern.quote("."), "_");
- }
- if(name.contains(" ")) {
- name = name.replaceAll(" ", "");
- }
- String file = name + ".yaml";
-
-
- outputFile = new File(outputPath, file);
- outputFile.getParentFile().mkdirs();
- try {
- outputFile.createNewFile();
- } catch (IOException e) {
-
- throw new RuntimeException(e);
- }
- } else {
- if(bluePrintName.contains(" ") || bluePrintName.contains(".")) {
- bluePrintName = bluePrintName.replaceAll(Pattern.quote("."), "_");
- bluePrintName = bluePrintName.replaceAll(" ", "");
- }
- String file = bluePrintName + ".yaml";
- outputFile = new File(outputPath, file);
- outputFile.getParentFile().mkdirs();
- try {
- outputFile.createNewFile();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ String name = bluePrintName.equals("") ? cs.getSelf().getName() : bluePrintName;
+ if(name.contains(".")) {
+ name = name.replaceAll(Pattern.quote("."), "_");
+ }
+ if(name.contains(" ")) {
+ name = name.replaceAll(" ", "");
+ }
+ String file = name + ".yaml";
+ outputFile = new File(outputPath, file);
+ outputFile.getParentFile().mkdirs();
+ try {
+ outputFile.createNewFile();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
String version = "#blueprint_version: " + cs.getSelf().getVersion() + '\n';
String description = "#description: " + cs.getSelf().getDescription() + '\n';
- BufferedWriter writer = null;
- try {
- writer = new BufferedWriter(new FileWriter(outputFile, false));
+ try(BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile, false))) {
+ writer.write(description);
+ writer.write(version);
} catch (IOException e1) {
throw new RuntimeException(e1);
}
- if(writer != null) {
- try {
- writer.write(description);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- try {
- writer.write(version);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- try {
- writer.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
//read the translated blueprint into the file
ObjectMapper blueprintMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
- PrintWriter out = null;
- try {
- out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)));
+ try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)))) {
+ blueprintMapper.writeValue(out, this);
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
- if(out != null) {
- blueprintMapper.writeValue(out, this);
- out.close();
- }
- } catch (IOException e) {
-
- throw new RuntimeException(e);
- }
-
-
- Fixes fix = new Fixes();
- try {
- fix.fixSingleQuotes(outputFile);
+ Fixes.fixSingleQuotes(outputFile);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java
new file mode 100644
index 0000000..ac14b47
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java
@@ -0,0 +1,40 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ */
+
+package org.onap.blueprintgenerator.models.blueprint;
+
+public final class BpConstants {
+
+ private BpConstants() {}
+
+ public static final String CLOUDIFY_DSL_1_3 = "cloudify_dsl_1_3";
+
+ public static final String CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP = "dcae.nodes.ContainerizedServiceComponentUsingDmaap";
+ public static final String CONTENERIZED_SERVICE_COMPONENT = "dcae.nodes.ContainerizedServiceComponent";
+ public static final String FEED = "dcaegen2.nodes.Feed";
+ public static final String TOPIC = "dcaegen2.nodes.Topic";
+ public static final String PUBLISH_EVENTS = "dcaegen2.relationships.publish_events";
+ public static final String PUBLISH_FILES = "dcaegen2.relationships.publish_files";
+ public static final String SUBSCRIBE_TO_EVENTS = "dcaegen2.relationships.subscribe_to_events";
+ public static final String SUBSCRIBE_TO_FILES = "dcaegen2.relationships.subscribe_to_files";
+
+ public static final String TOSCA_DATATYPES_ROOT = "tosca.datatypes.Root";
+ public static final String TOSCA_NODES_ROOT = "tosca.nodes.Root";
+ public static final String TOSCA_SIMPLE_YAML = "tosca_simple_yaml_1_0_0";
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
index b17b045..7b55e17 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
@@ -20,24 +20,16 @@
package org.onap.blueprintgenerator.models.blueprint;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
-
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-import lombok.AllArgsConstructor;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
-
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import lombok.Getter;
+import lombok.Setter;
@Getter @Setter
@JsonInclude(value=Include.NON_NULL)
@@ -46,32 +38,30 @@ public class Imports {
private ArrayList<String> imports;
public static ArrayList<String> createOnapImports() {
- ArrayList<String> imps = new ArrayList<String>();
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml");
+ ArrayList<String> imps = new ArrayList<>();
+ imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
+ imps.add("plugin:k8splugin?version=3.4.2");
+ imps.add("plugin:dcaepolicyplugin?version=2.4.0");
return imps;
}
+
public static ArrayList<String> createDmaapImports(){
- ArrayList<String> imps = new ArrayList<String>();
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R5/k8splugin/1.6.0/k8splugin_types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml");
+ ArrayList<String> imps = new ArrayList<>();
+ imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
+ imps.add("plugin:k8splugin?version=3.4.2");
+ imps.add("plugin:dmaap?version=1.5.0");
return imps;
}
+
public static ArrayList<String> createImportsFromFile(String path) {
- Imports imports = new Imports();
ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
File importPath = new File(path);
try {
- imports = importMapper.readValue(importPath, Imports.class);
+ Imports imports = importMapper.readValue(importPath, Imports.class);
+ imports.getImports().removeIf(String::isBlank);
+ return imports.getImports();
} catch (IOException e) {
throw new RuntimeException(e);
}
- ArrayList<String> imps = new ArrayList<String>();
- for(String s: imports.getImports()) {
- imps.add(s);
- }
- return imps;
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
index a3404f6..435059e 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
@@ -31,11 +31,9 @@ import lombok.Getter; import lombok.Setter;
public class Interfaces {
private Start start;
public TreeMap<String, LinkedHashMap<String, Object>> createInterface(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
//create the start object
Start start = new Start();
- retInputs = start.createOnapStart(retInputs, cs);
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = start.createOnapStart(inps, cs);
this.setStart(start);
return retInputs;
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
index d32d6f4..9aa5354 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
@@ -20,6 +20,11 @@
package org.onap.blueprintgenerator.models.blueprint;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createBooleanInput;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createIntegerInput;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -31,7 +36,6 @@ import java.util.Map;
import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;
-import org.onap.blueprintgenerator.common.blueprint.BlueprintHelper;
import org.onap.blueprintgenerator.models.blueprint.tls.ExternalCertificateParametersFactory;
import org.onap.blueprintgenerator.models.blueprint.tls.ExternalTlsInfoFactory;
import org.onap.blueprintgenerator.models.blueprint.tls.TlsInfo;
@@ -42,11 +46,16 @@ import org.onap.blueprintgenerator.models.componentspec.Publishes;
import org.onap.blueprintgenerator.models.componentspec.Subscribes;
import org.onap.blueprintgenerator.models.dmaapbp.DmaapStreams;
+
@Getter
@Setter
@JsonInclude(value = Include.NON_NULL)
public class Properties {
+ private static final String EMPTY_VALUE = "";
+
+ ArrayList<DmaapStreams> streams_publishes;
+ ArrayList<DmaapStreams> streams_subscribes;
private Appconfig application_config;
private Auxilary docker_config;
private Object image;
@@ -58,13 +67,11 @@ public class Properties {
private String name;
private GetInput topic_name;
private GetInput feed_name;
- ArrayList<DmaapStreams> streams_publishes;
- ArrayList<DmaapStreams> streams_subscribes;
private TlsInfo tls_info;
private ExternalTlsInfo external_cert;
private ResourceConfig resource_config;
private GetInput always_pull_image;
- //private boolean useExisting;
+ private Boolean useExisting;
@JsonIgnore
private ExternalTlsInfoFactory externalCertFactory;
@@ -74,35 +81,29 @@ public class Properties {
}
public TreeMap<String, LinkedHashMap<String, Object>> createOnapProperties(
- TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec componentSpec, String override) {
TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
//set the image
GetInput image = new GetInput();
image.setBpInputName("image");
this.setImage(image);
- LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
- img.put("type", "string");
- img.put("default", cs.getArtifacts()[0].getUri());
- retInputs.put("image", img);
+ retInputs.put("image", createStringInput(componentSpec.getImageUri()));
//set the location id
GetInput location = new GetInput();
location.setBpInputName("location_id");
this.setLocation_id(location);
- LinkedHashMap<String, Object> locMap = new LinkedHashMap();
- locMap.put("type", "string");
- locMap.put("default", "");
- retInputs.put("location_id", locMap);
+ retInputs.put("location_id", createStringInput(EMPTY_VALUE));
//set the log info
- this.setLog_info(cs.getAuxilary().getLog_info());
+ this.setLog_info(componentSpec.getAuxilary().getLog_info());
//set the replicas
GetInput replica = new GetInput();
replica.setBpInputName("replicas");
this.setReplicas(replica);
- LinkedHashMap<String, Object> rep = BlueprintHelper.createInputValue("integer", "number of instances", 1);
+ LinkedHashMap<String, Object> rep = createIntegerInput("number of instances", 1);
retInputs.put("replicas", rep);
//set the dns name
@@ -112,7 +113,7 @@ public class Properties {
//this.setName(cs.getSelf().getName());
//set the docker config
- Auxilary aux = cs.getAuxilary();
+ Auxilary aux = componentSpec.getAuxilary();
// if(aux.getPorts() != null) {
// retInputs = aux.createPorts(retInputs);
// }
@@ -120,76 +121,67 @@ public class Properties {
//set the app config
Appconfig app = new Appconfig();
- retInputs = app.createAppconfig(retInputs, cs, override, false);
+ retInputs = app.createAppconfig(retInputs, componentSpec, override, false);
this.setApplication_config(app);
// set always_pull_image
this.always_pull_image = new GetInput();
this.always_pull_image.setBpInputName("always_pull_image");
- LinkedHashMap<String, Object> inputAlwaysPullImage = BlueprintHelper.createInputValue("boolean",
+ LinkedHashMap<String, Object> inputAlwaysPullImage = createBooleanInput(
"Set to true if the image should always be pulled",
true);
retInputs.put("always_pull_image", inputAlwaysPullImage);
//set service component type
- String sType = cs.getSelf().getName();
- sType = sType.replace('.', '-');
- this.setService_component_type(sType);
+ String serviceComponentType = componentSpec.getSelfName().replace('.', '-');
+ this.setService_component_type(serviceComponentType);
//set the tls info for internal and external communication
- TreeMap<String, Object> tls_info = cs.getAuxilary().getTls_info();
+ TreeMap<String, Object> tls_info = componentSpec.getAuxilary().getTls_info();
if (tls_info != null) {
- addTlsInfo(cs, retInputs);
+ addTlsInfo(componentSpec, retInputs);
if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) {
- retInputs.putAll(addExternalTlsInfo(cs));
+ retInputs.putAll(addExternalTlsInfo(componentSpec));
}
}
//set the reource config
ResourceConfig resource = new ResourceConfig();
- retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
+ retInputs = resource.createResourceConfig(retInputs, componentSpec.getSelf().getName());
this.setResource_config(resource);
return retInputs;
}
public TreeMap<String, LinkedHashMap<String, Object>> createDmaapProperties(
- TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec componentSpec, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
//set the image
GetInput image = new GetInput();
image.setBpInputName("tag_version");
this.setImage(image);
- LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
- img.put("type", "string");
- img.put("default", cs.getArtifacts()[0].getUri());
- retInputs.put("tag_version", img);
+ retInputs.put("tag_version", createStringInput(componentSpec.getImageUri()));
//set the location id
GetInput location = new GetInput();
location.setBpInputName("location_id");
this.setLocation_id(location);
- LinkedHashMap<String, Object> locMap = new LinkedHashMap();
- locMap.put("type", "string");
- locMap.put("default", "");
- retInputs.put("location_id", locMap);
+ retInputs.put("location_id", createStringInput(EMPTY_VALUE));
//set the log info
- this.setLog_info(cs.getAuxilary().getLog_info());
+ this.setLog_info(componentSpec.getAuxilary().getLog_info());
//set service component type
- String sType = cs.getSelf().getName();
- sType = sType.replace('.', '-');
- this.setService_component_type(sType);
+ String serviceComponentType = componentSpec.getSelfName().replace('.', '-');
+ this.setService_component_type(serviceComponentType);
//set the tls info for internal and external communication
- TreeMap<String, Object> tls_info = cs.getAuxilary().getTls_info();
+ TreeMap<String, Object> tls_info = componentSpec.getAuxilary().getTls_info();
if (tls_info != null) {
- addTlsInfo(cs, retInputs);
+ addTlsInfo(componentSpec, retInputs);
if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) {
- retInputs.putAll(addExternalTlsInfo(cs));
+ retInputs.putAll(addExternalTlsInfo(componentSpec));
}
}
@@ -197,7 +189,7 @@ public class Properties {
GetInput replica = new GetInput();
replica.setBpInputName("replicas");
this.setReplicas(replica);
- LinkedHashMap<String, Object> rep = BlueprintHelper.createInputValue("integer", "number of instances", 1);
+ LinkedHashMap<String, Object> rep = createIntegerInput("number of instances", 1);
retInputs.put("replicas", rep);
// //set the dns name
@@ -207,7 +199,7 @@ public class Properties {
// this.setName(cs.getSelf().getName());
//set the docker config
- Auxilary aux = cs.getAuxilary();
+ Auxilary aux = componentSpec.getAuxilary();
// if(aux.getPorts() != null) {
// retInputs = aux.createPorts(retInputs);
// }
@@ -215,59 +207,63 @@ public class Properties {
//set the appconfig
Appconfig app = new Appconfig();
- retInputs = app.createAppconfig(retInputs, cs, override, true);
+ retInputs = app.createAppconfig(retInputs, componentSpec, override, true);
this.setApplication_config(app);
//set the stream publishes
- ArrayList<DmaapStreams> pubStreams = new ArrayList();
- if (cs.getStreams().getPublishes() != null) {
- for (Publishes p : cs.getStreams().getPublishes()) {
- if (p.getType().equals("message_router") || p.getType().equals("message router")) {
- String topic = p.getConfig_key() + "_topic";
+ ArrayList<DmaapStreams> pubStreams = new ArrayList<>();
+ if (componentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publishes : componentSpec.getStreams().getPublishes()) {
+ if (isMessageRouterType(publishes.getType())) {
+ String topic = publishes.getConfig_key() + "_topic";
DmaapStreams mrStreams = new DmaapStreams();
retInputs = mrStreams
- .createStreams(inps, cs, topic, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
+ .createStreams(inps, componentSpec, topic, publishes.getType(), publishes.getConfig_key(),
+ publishes.getRoute(), 'p');
pubStreams.add(mrStreams);
- } else if (p.getType().equals("data_router") || p.getType().equals("data router")) {
- String feed = p.getConfig_key() + "_feed";
+ } else if (isDataRouterType(publishes.getType())) {
+ String feed = publishes.getConfig_key() + "_feed";
DmaapStreams drStreams = new DmaapStreams();
retInputs = drStreams
- .createStreams(inps, cs, feed, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
+ .createStreams(inps, componentSpec, feed, publishes.getType(), publishes.getConfig_key(),
+ publishes.getRoute(), 'p');
pubStreams.add(drStreams);
}
}
}
//set the stream subscribes
- ArrayList<DmaapStreams> subStreams = new ArrayList();
- if (cs.getStreams().getSubscribes() != null) {
- for (Subscribes s : cs.getStreams().getSubscribes()) {
- if (s.getType().equals("message_router") || s.getType().equals("message router")) {
- String topic = s.getConfig_key() + "_topic";
+ ArrayList<DmaapStreams> subStreams = new ArrayList<>();
+ if (componentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) {
+ if (isMessageRouterType(subscribes.getType())) {
+ String topic = subscribes.getConfig_key() + "_topic";
DmaapStreams mrStreams = new DmaapStreams();
retInputs = mrStreams
- .createStreams(inps, cs, topic, s.getType(), s.getConfig_key(), s.getRoute(), 's');
+ .createStreams(inps, componentSpec, topic, subscribes.getType(), subscribes.getConfig_key(),
+ subscribes.getRoute(), 's');
subStreams.add(mrStreams);
- } else if (s.getType().equals("data_router") || s.getType().equals("data router")) {
- String feed = s.getConfig_key() + "_feed";
+ } else if (isDataRouterType(subscribes.getType())) {
+ String feed = subscribes.getConfig_key() + "_feed";
DmaapStreams drStreams = new DmaapStreams();
retInputs = drStreams
- .createStreams(inps, cs, feed, s.getType(), s.getConfig_key(), s.getRoute(), 's');
+ .createStreams(inps, componentSpec, feed, subscribes.getType(), subscribes.getConfig_key(),
+ subscribes.getRoute(), 's');
subStreams.add(drStreams);
}
}
}
- if (pubStreams.size() != 0) {
+ if (!pubStreams.isEmpty()) {
this.setStreams_publishes(pubStreams);
}
- if (subStreams.size() != 0) {
+ if (!subStreams.isEmpty()) {
this.setStreams_subscribes(subStreams);
}
//set the reource config
ResourceConfig resource = new ResourceConfig();
- retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
+ retInputs = resource.createResourceConfig(retInputs, componentSpec.getSelf().getName());
this.setResource_config(resource);
return retInputs;
@@ -280,7 +276,7 @@ public class Properties {
useTLSFlag.setBpInputName("use_tls");
tlsInfo.setUseTls(useTLSFlag);
this.setTls_info(tlsInfo);
- LinkedHashMap<String, Object> useTlsFlagInput = BlueprintHelper.createInputValue("boolean",
+ LinkedHashMap<String, Object> useTlsFlagInput = createBooleanInput(
"flag to indicate tls enable/disable",
cs.getAuxilary().getTls_info().get("use_tls"));
retInputs.put("use_tls", useTlsFlagInput);
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
index 13aa0d0..030374f 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
@@ -21,6 +21,8 @@
package org.onap.blueprintgenerator.models.blueprint;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput;
+
import java.util.LinkedHashMap;
import java.util.TreeMap;
@@ -32,93 +34,94 @@ import lombok.Setter;
//TODO: Auto-generated Javadoc
/* (non-Javadoc)
-* @see java.lang.Object#toString()
-*/
-@Getter @Setter
+ * @see java.lang.Object#toString()
+ */
+@Getter
+@Setter
/* (non-Javadoc)
-* @see java.lang.Object#toString()
-*/
+ * @see java.lang.Object#toString()
+ */
@Builder
/**
-* Instantiates a new resource config obj.
-*/
+ * Instantiates a new resource config obj.
+ */
@NoArgsConstructor
/**
-* Instantiates a new resource config obj.
-*
-* @param limits the limits
-* @param requests the requests
-*/
+ * Instantiates a new resource config obj.
+ *
+ * @param limits the limits
+ * @param requests the requests
+ */
@AllArgsConstructor
public class ResourceConfig {
- /** The limits. */
- private TreeMap<String, GetInput> limits;
-
- /** The requests. */
- private TreeMap<String, GetInput> requests;
+ /**
+ * The limits.
+ */
+ private TreeMap<String, GetInput> limits;
+ /**
+ * The requests.
+ */
+ private TreeMap<String, GetInput> requests;
- /**
- * Creates the resource config.
- *
- * @param inps the inps
- * @param name the name
- * @return the tree map
- */
- public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- LinkedHashMap<String, Object> mi = new LinkedHashMap<String, Object>();
- mi.put("type", "string");
- mi.put("default", "128Mi");
+ /**
+ * Creates the resource config.
+ *
+ * @param inps the inps
+ * @param name the name
+ * @return the tree map
+ */
+ public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String name) {
- LinkedHashMap<String, Object> m = new LinkedHashMap<String, Object>();
- m.put("type", "string");
- m.put("default", "250m");
+ LinkedHashMap<String, Object> memoryLimit = createStringInput("128Mi");
+ LinkedHashMap<String, Object> cpuLimit = createStringInput("250m");
+ String namePrefix = getNamePrefix(name);
- if(!name.equals("")) {
- name = name + "_";
- }
+ //set the limits
+ TreeMap<String, GetInput> limits = new TreeMap<>();
- //set the limits
- TreeMap<String, GetInput> lim = new TreeMap<String, GetInput>();
+ GetInput cpu = new GetInput();
+ cpu.setBpInputName(namePrefix + "cpu_limit");
+ limits.put("cpu", cpu);
- GetInput cpu = new GetInput();
- cpu.setBpInputName(name + "cpu_limit");
- lim.put("cpu", cpu);
+ GetInput memL = new GetInput();
+ memL.setBpInputName(namePrefix + "memory_limit");
+ limits.put("memory", memL);
- GetInput memL = new GetInput();
- memL.setBpInputName(name + "memory_limit");
- lim.put("memory", memL);
+ inps.put(namePrefix + "cpu_limit", cpuLimit);
+ inps.put(namePrefix + "memory_limit", memoryLimit);
- retInputs.put(name + "cpu_limit", m);
- retInputs.put(name + "memory_limit", mi);
+ this.setLimits(limits);
- this.setLimits(lim);
+ //set the requests
+ TreeMap<String, GetInput> requests = new TreeMap<>();
- //set the requests
- TreeMap<String, GetInput> req = new TreeMap<String, GetInput>();
+ GetInput cpuR = new GetInput();
+ cpuR.setBpInputName(namePrefix + "cpu_request");
+ requests.put("cpu", cpuR);
- GetInput cpuR = new GetInput();
- cpuR.setBpInputName(name + "cpu_request");
- req.put("cpu", cpuR);
+ GetInput memR = new GetInput();
+ memR.setBpInputName(namePrefix + "memory_request");
+ requests.put("memory", memR);
- GetInput memR = new GetInput();
- memR.setBpInputName(name + "memory_request");
- req.put("memory", memR);
+ inps.put(namePrefix + "cpu_request", cpuLimit);
+ inps.put(namePrefix + "memory_request", memoryLimit);
- retInputs.put(name + "cpu_request", m);
- retInputs.put(name + "memory_request", mi);
+ this.setRequests(requests);
- this.setRequests(req);
+ return inps;
+ }
- return retInputs;
- }
+ private String getNamePrefix(String name) {
+ return name.isEmpty() ? "" : name + "_";
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java
index d9c885d..0b03777 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java
@@ -36,14 +36,12 @@ public class Start {
private LinkedHashMap<String, Object> envs;
public TreeMap<String, LinkedHashMap<String, Object>> createOnapStart(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- retInputs = inps;
-
+
//create the start inputs
StartInputs inputs = new StartInputs();
- inputs.createOnapStartInputs(retInputs, cs);
+ inputs.createOnapStartInputs(inps, cs);
this.setInputs(inputs);
- return retInputs;
+ return inps;
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
index 1055fbd..a0cfe20 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
@@ -41,10 +41,9 @@ public class StartInputs {
private Object envs;
public TreeMap<String, LinkedHashMap<String, Object>> createOnapStartInputs(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
int count = 0;
- ArrayList<String> portList = new ArrayList();
+ ArrayList<String> portList = new ArrayList<>();
Auxilary aux = cs.getAuxilary();
if (aux.getPorts() != null) {
@@ -56,10 +55,10 @@ public class StartInputs {
, ports[0], count);
portList.add(internal);
- LinkedHashMap<String, Object> portType = new LinkedHashMap();
+ LinkedHashMap<String, Object> portType = new LinkedHashMap<>();
portType.put("type", "string");
portType.put("default", ports[1]);
- retInputs.put("external_port_" + count, portType);
+ inps.put("external_port_" + count, portType);
count++;
}
@@ -98,7 +97,7 @@ public class StartInputs {
// }
//set the envs
- LinkedHashMap<String, Object> eMap = new LinkedHashMap();
+ LinkedHashMap<String, Object> eMap = new LinkedHashMap<>();
if(cs.getAuxilary().getDatabases() != null){
//set db env variables
LinkedHashMap<String, Object> envVars = PgaasNodeBuilder.getEnvVariables(cs.getAuxilary().getDatabases());
@@ -111,9 +110,9 @@ public class StartInputs {
this.setEnvs(env);
eMap.put("default", "{}");
}
- retInputs.put("envs", eMap);
+ inps.put("envs", eMap);
- return retInputs;
+ return inps;
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java
index 464fc4a..0cec284 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java
@@ -46,9 +46,7 @@ public class DmaapInfo {
public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRInfo(
TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
stringType.put("type", "string");
config = config.replaceAll("-", "_");
@@ -62,9 +60,9 @@ public class DmaapInfo {
topic.setBpInputName(config);
this.setTopic_url(topic);
- retInputs.put(config, stringType);
+ inps.put(config, stringType);
- return retInputs;
+ return inps;
}
public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRInfo(
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java
index 6af69e5..30f59e2 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java
@@ -40,10 +40,8 @@ public class DmaapObj {
public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRObj(TreeMap<String, LinkedHashMap<String, Object>> inps,
String config, char type, String n, String num, boolean isDmaap) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- LinkedHashMap<String, Object> stringType = new LinkedHashMap();
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
stringType.put("type", "string");
- retInputs = inps;
//set the dmaapinfo
DmaapInfo info = new DmaapInfo();
@@ -58,20 +56,18 @@ public class DmaapObj {
GetInput u = new GetInput();
u.setBpInputName(config + "_" + num +"_aaf_username");
this.setUser(u);
- retInputs.put(config + "_" + num +"_aaf_username", stringType);
+ inps.put(config + "_" + num +"_aaf_username", stringType);
//set password
GetInput p = new GetInput();
p.setBpInputName(config + "_" + num +"_aaf_password");
this.setPass(p);
- retInputs.put(config + "_" + num +"_aaf_password", stringType);
+ inps.put(config + "_" + num +"_aaf_password", stringType);
}
- return retInputs;
+ return inps;
}
public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num, boolean isDmaap) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
-
+
//set the dmaapinfo
DmaapInfo info = new DmaapInfo();
if(!isDmaap){
@@ -82,6 +78,6 @@ public class DmaapObj {
String infoType = "<<" + n + ">>";
this.setDmaap_info(infoType);
}
- return retInputs;
+ return inps;
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
index f7f5a03..198dc19 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
@@ -21,13 +21,11 @@
package org.onap.blueprintgenerator.models.componentspec;
-
import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -53,6 +51,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
+@EqualsAndHashCode
//Called in Component Spec Object
public class Artifacts {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
index a36deb5..58e1e0c 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
@@ -22,19 +22,15 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import java.util.ArrayList;
+import java.util.TreeMap;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -64,6 +60,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in component Spec Object
public class Auxilary {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
index 0b7dcee..d130632 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
@@ -24,11 +24,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java
index 3876b53..0cd2b72 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java
@@ -1,21 +1,22 @@
-/**============LICENSE_START=======================================================
- org.onap.dcae
- ================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
-
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+
*/
package org.onap.blueprintgenerator.models.componentspec;
@@ -30,11 +31,13 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
+import lombok.Setter;
import lombok.NoArgsConstructor;
import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo;
// TODO: Auto-generated Javadoc
+
/**
* The Class ComponentSpec.
*/
@@ -43,13 +46,13 @@ import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo;
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
-@Getter @Setter
+@Getter
+@Setter
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
-
/**
* Instantiates a new component spec.
*/
@@ -66,82 +69,98 @@ import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo;
* @param artifacts the artifacts
*/
-@JsonInclude(value=Include.NON_NULL)
+@JsonInclude(value = Include.NON_NULL)
//main object that the component spec file is written in
public class ComponentSpec {
-
- /** The self. */
- private Self self;
-
- /** The services. */
- private Services services;
-
- /** The streams. */
- private Streams streams;
-
- /** The parameters. */
- private Parameters[] parameters;
-
- /** The auxilary. */
- private Auxilary auxilary;
-
- @JsonProperty("policy_info")
- private PolicyInfo policyInfo;
-
- /** The artifacts. */
- private Artifacts[] artifacts;
-
- /**
- * Creates the component spec from file.
- *
- * @param path the path
- */
- public void createComponentSpecFromFile(String path) {
- ObjectMapper componentMapper = new ObjectMapper();
- File specPathFile = new File(path);
- ComponentSpec cs = new ComponentSpec();
-
- try {
- cs = componentMapper.readValue(specPathFile, ComponentSpec.class);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
-
-
- //set all the pieces of the component spec
- this.setSelf(cs.getSelf());
- this.setArtifacts(cs.getArtifacts());
- this.setAuxilary(cs.getAuxilary());
- this.setParameters(cs.getParameters());
- this.setServices(cs.getServices());
- this.setStreams(cs.getStreams());
- this.setPolicyInfo(cs.getPolicyInfo());
- }
-
-
- /**
- * Creates the component spec from string.
- *
- * @param specString the spec string
- */
- public void createComponentSpecFromString(String specString) {
- ObjectMapper componentMapper = new ObjectMapper();
- ComponentSpec cs = new ComponentSpec();
- try {
- cs = componentMapper.readValue(specString, ComponentSpec.class);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- //set all the pieces of the component spec
- this.setSelf(cs.getSelf());
- this.setArtifacts(cs.getArtifacts());
- this.setAuxilary(cs.getAuxilary());
- this.setParameters(cs.getParameters());
- this.setServices(cs.getServices());
- this.setStreams(cs.getStreams());
- }
-
+ /**
+ * The self.
+ */
+ private Self self;
+
+ /**
+ * The services.
+ */
+ private Services services;
+
+ /**
+ * The streams.
+ */
+ private Streams streams;
+
+ /**
+ * The parameters.
+ */
+ private Parameters[] parameters;
+
+ /**
+ * The auxilary.
+ */
+ private Auxilary auxilary;
+
+ @JsonProperty("policy_info")
+ private PolicyInfo policyInfo;
+
+ /**
+ * The artifacts.
+ */
+ private Artifacts[] artifacts;
+
+ /**
+ * Creates the component spec from file.
+ *
+ * @param path the path
+ */
+ public void createComponentSpecFromFile(String path) {
+ ObjectMapper componentMapper = new ObjectMapper();
+ File specPathFile = new File(path);
+ ComponentSpec cs = new ComponentSpec();
+
+ try {
+ cs = componentMapper.readValue(specPathFile, ComponentSpec.class);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ //set all the pieces of the component spec
+ this.setSelf(cs.getSelf());
+ this.setArtifacts(cs.getArtifacts());
+ this.setAuxilary(cs.getAuxilary());
+ this.setParameters(cs.getParameters());
+ this.setServices(cs.getServices());
+ this.setStreams(cs.getStreams());
+ this.setPolicyInfo(cs.getPolicyInfo());
+ }
+
+
+ /**
+ * Creates the component spec from string.
+ *
+ * @param specString the spec string
+ */
+ public void createComponentSpecFromString(String specString) {
+ ObjectMapper componentMapper = new ObjectMapper();
+ ComponentSpec cs = new ComponentSpec();
+ try {
+ cs = componentMapper.readValue(specString, ComponentSpec.class);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ //set all the pieces of the component spec
+ this.setSelf(cs.getSelf());
+ this.setArtifacts(cs.getArtifacts());
+ this.setAuxilary(cs.getAuxilary());
+ this.setParameters(cs.getParameters());
+ this.setServices(cs.getServices());
+ this.setStreams(cs.getStreams());
+ }
+
+ public String getImageUri() {
+ return artifacts[0].getUri();
+ }
+
+ public String getSelfName() {
+ return this.self.getName();
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
index 3615605..785df35 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
@@ -20,18 +20,10 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.HashMap;
-
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
* The Class ConstraintsObj.
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
index d94e2bb..cbe02dc 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
@@ -22,11 +22,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,6 +49,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
public class Container {
/** The bind. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
index 45f9091..ef33aaf 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
index acc9379..76e1036 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -53,6 +52,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in Auxillary Object
public class HealthCheck {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
index 91734ad..f178c94 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
@@ -22,11 +22,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -46,6 +45,7 @@ import lombok.NoArgsConstructor;
* @param mode the mode
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
public class Host{
/** The path. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
index 515ecc7..eb95202 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
@@ -20,17 +20,13 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.ArrayList;
-
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
@@ -68,6 +64,7 @@ import lombok.NoArgsConstructor;
* @param constraints the constraints
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in component Spec Object
public class Parameters {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
index 3cc14fe..d295ca4 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -51,6 +50,7 @@ import lombok.NoArgsConstructor;
* @param script_path the script path
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//called in auxilary
public class Policy {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
index 7af16d6..aa38271 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
index ad9c87d..9ad24c3 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
@@ -21,11 +21,9 @@
package org.onap.blueprintgenerator.models.componentspec;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
index 3ee47b9..4f46313 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -54,6 +53,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Streams Object
public class Publishes {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
index 6c389d6..6d78805 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,7 +49,7 @@ import lombok.NoArgsConstructor;
* @param policy the policy
*/
@JsonInclude(value=Include.NON_NULL)
-
+@EqualsAndHashCode
public class ReconfigsObj {
/** The dti. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
index 2aaf60b..7ca1830 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
@@ -25,11 +25,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
index a566661..8b5f35e 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
@@ -20,16 +20,13 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.Map;
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -55,6 +52,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//called in Component Spec object
public class Self {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
index afe0904..772d859 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
index 1b7dcd3..500f32d 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
@@ -24,11 +24,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -52,6 +51,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Component Spec Object
public class Streams {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
index 14485a0..ec4aa41 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -57,6 +56,7 @@ import lombok.NoArgsConstructor;
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Streams Object
public class Subscribes {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
index 1034242..777bdeb 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,6 +49,7 @@ import lombok.NoArgsConstructor;
* @param host the host
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in Auxillary Object
public class Volumes {
@@ -58,4 +58,4 @@ public class Volumes {
/** The host. */
private Host host;
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
index c4cc663..0c8f8a9 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
@@ -1,4 +1,4 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
@@ -8,16 +8,16 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============LICENSE_END=========================================================
-
+
*/
package org.onap.blueprintgenerator.models.dmaapbp;
@@ -28,92 +28,99 @@ import java.util.TreeMap;
import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
import org.onap.blueprintgenerator.models.blueprint.Blueprint;
-import org.onap.blueprintgenerator.models.blueprint.Imports;
import org.onap.blueprintgenerator.models.blueprint.Node;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import org.onap.blueprintgenerator.models.componentspec.Publishes;
import org.onap.blueprintgenerator.models.componentspec.Subscribes;
-public class DmaapBlueprint extends Blueprint{
- public Blueprint createDmaapBlueprint(ComponentSpec cs, String importPath, String override) {
- Blueprint bp = new Blueprint();
-
- //set tosca definition
- bp.setTosca_definitions_version("cloudify_dsl_1_3");
-
- //set the description
- bp.setDescription(cs.getSelf().getDescription());
-
- //create the inpus object that will be added to over the creation of the blueprint
- TreeMap<String, LinkedHashMap<String, Object>> inps = new TreeMap<String, LinkedHashMap<String, Object>>();
-
- //set the imports
- Imports imps = new Imports();
- if(importPath.equals("")) {
- bp.setImports(imps.createDmaapImports());
- }
- else {
- bp.setImports(imps.createImportsFromFile(importPath));
- }
-
- //bp.setImports(imps.getImports());
-
- //set and create the node templates
- TreeMap<String, Node> nodeTemplate = new TreeMap();
-
- //create and add the main dmaap node
- DmaapNode dmaap = new DmaapNode();
- inps = dmaap.createDmaapNode(cs, inps, override);
- nodeTemplate.put(cs.getSelf().getName(), dmaap);
-
- //create and add the topic/feed nodes
-
- //go through the streams publishes
- if(cs.getStreams().getPublishes() != null) {
- for(Publishes p: cs.getStreams().getPublishes()) {
- if(p.getType().equals("message_router") || p.getType().equals("message router")) {
- String topic = p.getConfig_key() + "_topic";
- DmaapNode topicNode = new DmaapNode();
- inps = topicNode.createTopicNode(cs, inps, topic);
- nodeTemplate.put(topic, topicNode);
- } else if(p.getType().equals("data_router") || p.getType().equals("data router")) {
- String feed = p.getConfig_key() + "_feed";
- DmaapNode feedNode = new DmaapNode();
- inps = feedNode.createFeedNode(cs, inps, feed);
- nodeTemplate.put(feed, feedNode);
- }
- }
- }
- //go through the stream subscribes
- if(cs.getStreams().getSubscribes() != null) {
- for(Subscribes s: cs.getStreams().getSubscribes()) {
- if(s.getType().equals("message_router") || s.getType().equals("message router")) {
- String topic = s.getConfig_key() + "_topic";
- DmaapNode topicNode = new DmaapNode();
- inps = topicNode.createTopicNode(cs, inps, topic);
- nodeTemplate.put(topic, topicNode);
- } else if(s.getType().equals("data_router") || s.getType().equals("data router")) {
- String feed = s.getConfig_key() + "_feed";
- DmaapNode feedNode = new DmaapNode();
- inps = feedNode.createFeedNode(cs, inps, feed);
- nodeTemplate.put(feed, feedNode);
- }
- }
- }
-
- //if present in component spec, populate policyNodes information in the blueprint
- if(cs.getPolicyInfo() != null){
- PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inps);
- }
-
- //if present in component spec, populate pgaasNodes information in the blueprint
- if(cs.getAuxilary().getDatabases() != null){
- PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inps);
- }
-
- bp.setNode_templates(nodeTemplate);
-
- bp.setInputs(inps);
- return bp;
- }
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.joinUnderscore;
+import static org.onap.blueprintgenerator.models.blueprint.Imports.createDmaapImports;
+import static org.onap.blueprintgenerator.models.blueprint.Imports.createImportsFromFile;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3;
+
+public class DmaapBlueprint extends Blueprint {
+
+ private static final String TOPIC = "topic";
+ private static final String FEED = "feed";
+
+ public Blueprint createDmaapBlueprint(ComponentSpec componentSpec, String importPath, String override) {
+ Blueprint blueprint = new Blueprint();
+
+ //set tosca definition
+ blueprint.setTosca_definitions_version(CLOUDIFY_DSL_1_3);
+
+ //set the description
+ blueprint.setDescription(componentSpec.getSelf().getDescription());
+
+ //create the inpus object that will be added to over the creation of the blueprint
+ TreeMap<String, LinkedHashMap<String, Object>> inps = new TreeMap<>();
+
+ //set the imports
+ if (importPath.equals("")) {
+ blueprint.setImports(createDmaapImports());
+ } else {
+ blueprint.setImports(createImportsFromFile(importPath));
+ }
+
+ //set and create the node templates
+ TreeMap<String, Node> nodeTemplate = new TreeMap();
+
+ //create and add the main dmaap node
+ DmaapNode dmaap = new DmaapNode();
+ inps = dmaap.createDmaapNode(componentSpec, inps, override);
+ nodeTemplate.put(componentSpec.getSelf().getName(), dmaap);
+
+ //create and add the topic/feed nodes
+
+ //go through the streams publishes
+ if (componentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publisher : componentSpec.getStreams().getPublishes()) {
+ if (isMessageRouterType(publisher.getType())) {
+ String topic = joinUnderscore(publisher.getConfig_key(), TOPIC);
+ DmaapNode topicNode = new DmaapNode();
+ inps = topicNode.createTopicNode(componentSpec, inps, topic);
+ nodeTemplate.put(topic, topicNode);
+ } else if (isDataRouterType(publisher.getType())) {
+ String feed = joinUnderscore(publisher.getConfig_key(), FEED);
+ DmaapNode feedNode = new DmaapNode();
+ inps = feedNode.createFeedNode(componentSpec, inps, feed);
+ nodeTemplate.put(feed, feedNode);
+ }
+ }
+ }
+ //go through the stream subscribes
+ if (componentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes subscriber : componentSpec.getStreams().getSubscribes()) {
+ if (isMessageRouterType(subscriber.getType())) {
+ String topic = joinUnderscore(subscriber.getConfig_key(), TOPIC);
+ DmaapNode topicNode = new DmaapNode();
+ inps = topicNode.createTopicNode(componentSpec, inps, topic);
+ nodeTemplate.put(topic, topicNode);
+ } else if (isDataRouterType(subscriber.getType())) {
+ String feed = joinUnderscore(subscriber.getConfig_key(), FEED);
+ DmaapNode feedNode = new DmaapNode();
+ inps = feedNode.createFeedNode(componentSpec, inps, feed);
+ nodeTemplate.put(feed, feedNode);
+ }
+ }
+ }
+
+ //if present in component spec, populate policyNodes information in the blueprint
+ if (componentSpec.getPolicyInfo() != null) {
+ PolicyNodeBuilder.addPolicyNodesAndInputs(componentSpec, nodeTemplate, inps);
+ }
+
+ //if present in component spec, populate pgaasNodes information in the blueprint
+ if (componentSpec.getAuxilary().getDatabases() != null) {
+ PgaasNodeBuilder.addPgaasNodesAndInputs(componentSpec, nodeTemplate, inps);
+ }
+
+ blueprint.setNode_templates(nodeTemplate);
+
+ blueprint.setInputs(inps);
+ return blueprint;
+ }
+
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
index 37d7d2d..515099a 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
@@ -43,117 +43,143 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType;
+
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.FEED;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOPIC;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.PUBLISH_EVENTS;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.PUBLISH_FILES;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_EVENTS;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_FILES;
+
@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter @Setter
-@EqualsAndHashCode(callSuper=false)
+@Getter
+@Setter
+@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
-@JsonInclude(value=Include.NON_NULL)
-
-public class DmaapNode extends Node{
-
- public TreeMap<String, LinkedHashMap<String, Object>> createDmaapNode(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> inps, String override) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
-
- //set the type
- this.setType("dcae.nodes.ContainerizedServiceComponentUsingDmaap");
-
- //create the interface
- Interfaces inter = new Interfaces();
- retInputs = inter.createInterface(retInputs, cs);
- TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
- interfaces.put("cloudify.interfaces.lifecycle", inter);
- this.setInterfaces(interfaces);
-
- //create and set the relationships
- ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
-
- //go through the streams publishes
- if(cs.getStreams().getPublishes() != null) {
- for(Publishes p: cs.getStreams().getPublishes()) {
- LinkedHashMap<String, String> pubRelations = new LinkedHashMap();
- if(p.getType().equals("message_router") || p.getType().equals("message router")) {
- pubRelations.put("type", "ccsdk.relationships.publish_events");
- pubRelations.put("target", p.getConfig_key() + "_topic");
- } else if(p.getType().equals("data_router") || p.getType().equals("data router")) {
- pubRelations.put("type", "ccsdk.relationships.publish_files");
- pubRelations.put("target", p.getConfig_key() + "_feed");
- }
- rets.add(pubRelations);
- }
- }
- //go through the stream subscribes
- if(cs.getStreams().getSubscribes() != null) {
- for(Subscribes s: cs.getStreams().getSubscribes()) {
- LinkedHashMap<String, String> subRelations = new LinkedHashMap();
- if(s.getType().equals("message_router") || s.getType().equals("message router")) {
- subRelations.put("type", "ccsdk.relationships.subscribe_to_events");
- subRelations.put("target", s.getConfig_key() + "_topic");
- } else if(s.getType().equals("data_router") || s.getType().equals("data router")) {
- subRelations.put("type", "ccsdk.relationships.subscribe_to_files");
- subRelations.put("target", s.getConfig_key() + "_feed");
- }
- rets.add(subRelations);
- }
- }
-
- //add relationship for policy if exist
- if(cs.getPolicyInfo() != null){
- ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.getPolicyRelationships(cs);
- rets.addAll(policyRelationshipsList);
- }
-
- //add relationships and env_variables for pgaas dbs if exist
- if(cs.getAuxilary().getDatabases() != null){
- ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder.getPgaasNodeRelationships(cs);
- rets.addAll(pgaasRelationshipsList);
- }
-
- this.setRelationships(rets);
-
- //create and set the properties
- Properties props = new Properties();
- retInputs = props.createDmaapProperties(retInputs, cs, override);
- this.setProperties(props);
-
- return retInputs;
- }
- public TreeMap<String, LinkedHashMap<String, Object>> createFeedNode(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap();
- stringType.put("type", "string");
-
- //set the type
- this.setType("ccsdk.nodes.Feed");
-
- //create and set the properties
- Properties props = new Properties();
- GetInput topicInput = new GetInput();
- topicInput.setBpInputName(name + "_name");
- props.setFeed_name(topicInput);
- //props.setUseExisting(true);
- retInputs.put(name + "_name", stringType);
- this.setProperties(props);
-
- return retInputs;
- }
-
- public TreeMap<String, LinkedHashMap<String, Object>> createTopicNode(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap();
- stringType.put("type", "string");
-
- //set the type
- this.setType("ccsdk.nodes.Topic");
-
- //create and set the properties
- Properties props = new Properties();
- GetInput topicInput = new GetInput();
- topicInput.setBpInputName(name + "_name");
- props.setTopic_name(topicInput);
- //props.setUseExisting(true);
- retInputs.put(name + "_name", stringType);
- this.setProperties(props);
-
- return retInputs;
- }
+@JsonInclude(value = Include.NON_NULL)
+
+public class DmaapNode extends Node {
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createDmaapNode(ComponentSpec componentSpec,
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+
+ //set the type
+ this.setType(CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP);
+
+ //create the interface
+ Interfaces inter = new Interfaces();
+ retInputs = inter.createInterface(retInputs, componentSpec);
+ TreeMap<String, Interfaces> interfaces = new TreeMap<>();
+ interfaces.put("cloudify.interfaces.lifecycle", inter);
+ this.setInterfaces(interfaces);
+
+ //create and set the relationships
+ ArrayList<LinkedHashMap<String, String>> relationships = new ArrayList<>();
+
+ //go through the streams publishes
+ if (componentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publishes : componentSpec.getStreams().getPublishes()) {
+ relationships.add(createTypeAndTargetPubRelations(publishes));
+ }
+ }
+ //go through the stream subscribes
+ if (componentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) {
+ relationships.add(createTypeAndTargetSubRelations(subscribes));
+ }
+ }
+
+ //add relationship for policy if exist
+ if (componentSpec.getPolicyInfo() != null) {
+ ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder
+ .getPolicyRelationships(componentSpec);
+ relationships.addAll(policyRelationshipsList);
+ }
+
+ //add relationships and env_variables for pgaas dbs if exist
+ if (componentSpec.getAuxilary().getDatabases() != null) {
+ ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder
+ .getPgaasNodeRelationships(componentSpec);
+ relationships.addAll(pgaasRelationshipsList);
+ }
+
+ this.setRelationships(relationships);
+
+ //create and set the properties
+ Properties props = new Properties();
+ retInputs = props.createDmaapProperties(retInputs, componentSpec, override);
+ this.setProperties(props);
+
+ return retInputs;
+ }
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createFeedNode(ComponentSpec cs,
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String name) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
+ stringType.put("type", "string");
+
+ //set the type
+ this.setType(FEED);
+
+ //create and set the properties
+ Properties props = new Properties();
+ GetInput topicInput = new GetInput();
+ topicInput.setBpInputName(name + "_name");
+ props.setFeed_name(topicInput);
+ props.setUseExisting(true);
+ retInputs.put(name + "_name", stringType);
+ this.setProperties(props);
+
+ return retInputs;
+ }
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createTopicNode(ComponentSpec cs,
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String name) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
+ stringType.put("type", "string");
+
+ //set the type
+ this.setType(TOPIC);
+
+ //create and set the properties
+ Properties props = new Properties();
+ GetInput topicInput = new GetInput();
+ topicInput.setBpInputName(name + "_name");
+ props.setTopic_name(topicInput);
+ //props.setUseExisting(true);
+ retInputs.put(name + "_name", stringType);
+ this.setProperties(props);
+
+ return retInputs;
+ }
+
+ private LinkedHashMap<String, String> createTypeAndTargetPubRelations(Publishes publishes) {
+ LinkedHashMap<String, String> pubRelations = new LinkedHashMap<>();
+ if (isMessageRouterType(publishes.getType())) {
+ pubRelations.put("type", PUBLISH_EVENTS);
+ pubRelations.put("target", publishes.getConfig_key() + "_topic");
+ } else if (isDataRouterType(publishes.getType())) {
+ pubRelations.put("type", PUBLISH_FILES);
+ pubRelations.put("target", publishes.getConfig_key() + "_feed");
+ }
+ return pubRelations;
+ }
+
+ private LinkedHashMap<String, String> createTypeAndTargetSubRelations(Subscribes subscribes) {
+ LinkedHashMap<String, String> subRelations = new LinkedHashMap<>();
+ if (isMessageRouterType(subscribes.getType())) {
+ subRelations.put("type", SUBSCRIBE_TO_EVENTS);
+ subRelations.put("target", subscribes.getConfig_key() + "_topic");
+ } else if (isDataRouterType(subscribes.getType())) {
+ subRelations.put("type", SUBSCRIBE_TO_FILES);
+ subRelations.put("target", subscribes.getConfig_key() + "_feed");
+ }
+ return subRelations;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
index e2847d7..162337e 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
@@ -33,72 +33,77 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import lombok.Getter;
import lombok.Setter;
-@Getter @Setter
-@JsonInclude(value=Include.NON_NULL)
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
+
+@Getter
+@Setter
+@JsonInclude(value = Include.NON_NULL)
public class DmaapStreams {
- private String name;
- private GetInput location;
- private GetInput client_role;
- private String type;
-
- private GetInput username;
- private GetInput password;
- //private GetInput delivery_url;
-
- private GetInput privileged;
- private GetInput decompress;
-
- private String route;
- private String scheme;
-
- public TreeMap<String, LinkedHashMap<String, Object>> createStreams(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String name, String type, String key, String route, char o){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap();
- stringType.put("type", "string");
-
- //set the name
- this.setName(name);
-
- //set the type
- this.setType(type);
-
- //set the location
- GetInput location = new GetInput();
- location.setBpInputName(key + "_" + name + "_location");
- retInputs.put(key + "_" + name + "_location", stringType);
- this.setLocation(location);
-
- //if its data router we need to add some more
- if(type.equals("data_router") || type.equals("data router")) {
- if(o == 's') {
- //set the username
- GetInput username = new GetInput();
- username.setBpInputName(key + "_" + name + "_username");
- this.setUsername(username);
- retInputs.put(key + "_" + name + "_username", stringType);
-
- //set the password
- GetInput password = new GetInput();
- password.setBpInputName(key + "_" + name + "_password");
- this.setPassword(password);
- retInputs.put(key + "_" + name + "_password", stringType);
-
- //set privileged
- GetInput priviliged = new GetInput();
- priviliged.setBpInputName(key + "_" + name + "_priviliged");
- this.setPrivileged(priviliged);
- retInputs.put(key + "_" + name + "_priviliged", stringType);
-
- //set decompress
- GetInput decompress = new GetInput();
- decompress.setBpInputName(key + "_" + name + "_decompress");
- this.setDecompress(decompress);
- retInputs.put(key + "_" + name + "_decompress", stringType);
-
- this.setRoute(route);
- this.setScheme("https");
- }
+ private String name;
+ private GetInput location;
+ private GetInput client_role;
+ private String type;
+
+ private GetInput username;
+ private GetInput password;
+ //private GetInput delivery_url;
+
+ private GetInput privileged;
+ private GetInput decompress;
+
+ private String route;
+ private String scheme;
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createStreams(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String name, String type, String key,
+ String route, char o) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap();
+ stringType.put("type", "string");
+
+ //set the name
+ this.setName(name);
+
+ //set the type
+ this.setType(type);
+
+ //set the location
+ GetInput location = new GetInput();
+ location.setBpInputName(key + "_" + name + "_location");
+ retInputs.put(key + "_" + name + "_location", stringType);
+ this.setLocation(location);
+
+ //if its data router we need to add some more
+ if (isDataRouterType(type)) {
+ if ('s' == o) {
+ //set the username
+ GetInput username = new GetInput();
+ username.setBpInputName(key + "_" + name + "_username");
+ this.setUsername(username);
+ retInputs.put(key + "_" + name + "_username", stringType);
+
+ //set the password
+ GetInput password = new GetInput();
+ password.setBpInputName(key + "_" + name + "_password");
+ this.setPassword(password);
+ retInputs.put(key + "_" + name + "_password", stringType);
+
+ //set privileged
+ GetInput priviliged = new GetInput();
+ priviliged.setBpInputName(key + "_" + name + "_priviliged");
+ this.setPrivileged(priviliged);
+ retInputs.put(key + "_" + name + "_priviliged", stringType);
+
+ //set decompress
+ GetInput decompress = new GetInput();
+ decompress.setBpInputName(key + "_" + name + "_decompress");
+ this.setDecompress(decompress);
+ retInputs.put(key + "_" + name + "_decompress", stringType);
+
+ this.setRoute(route);
+ this.setScheme("https");
+ }
// //set the delivery url
// GetInput delivery = new GetInput();
@@ -106,13 +111,13 @@ public class DmaapStreams {
// this.setDelivery_url(delivery);
// retInputs.put(name + "delivery_url", stringType);
- } else {
- //set the client role
- GetInput client = new GetInput();
- client.setBpInputName(key + "_" + name + "_client_role");
- this.setClient_role(client);
- retInputs.put(key + "_" + name + "_client_role", stringType);
- }
- return retInputs;
- }
+ } else {
+ //set the client role
+ GetInput client = new GetInput();
+ client.setBpInputName(key + "_" + name + "_client_role");
+ this.setClient_role(client);
+ retInputs.put(key + "_" + name + "_client_role", stringType);
+ }
+ return retInputs;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
index 9f6f560..d9f3c16 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
@@ -1,4 +1,4 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
@@ -22,10 +22,14 @@
package org.onap.blueprintgenerator.models.onapbp;
-import java.util.ArrayList;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.LinkedHashMap;
import java.util.TreeMap;
-
+import lombok.Getter;
+import lombok.Setter;
import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
import org.onap.blueprintgenerator.models.blueprint.Blueprint;
@@ -33,67 +37,59 @@ import org.onap.blueprintgenerator.models.blueprint.Imports;
import org.onap.blueprintgenerator.models.blueprint.Node;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.Getter; import lombok.Setter;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
-@Getter @Setter
-@JsonInclude(value=Include.NON_NULL)
+@Getter
+@Setter
+@JsonInclude(value = Include.NON_NULL)
-public class OnapBlueprint extends Blueprint{
- public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) {
+public class OnapBlueprint extends Blueprint {
- //create the inputs that will be used
- TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- //set the tosca definition which is the same for everything
- this.setTosca_definitions_version("cloudify_dsl_1_3");
+ public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) {
- //set the imports
- if(!"".equals(importPath)) {
- Imports imps = new Imports();
- this.setImports(imps.createImportsFromFile(importPath));
- }
- else {
- Imports imps = new Imports();
- this.setImports(imps.createOnapImports());
- }
+ //create the inputs that will be used
+ TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ //set the tosca definition which is the same for everything
+ this.setTosca_definitions_version(CLOUDIFY_DSL_1_3);
- //create the node template
- TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
- String nodeName = cs.getSelf().getName();
+ //set the imports
+ if (!"".equals(importPath)) {
+ Imports imps = new Imports();
+ this.setImports(imps.createImportsFromFile(importPath));
+ } else {
+ Imports imps = new Imports();
+ this.setImports(imps.createOnapImports());
+ }
- //create the onap node that will be used
- OnapNode node = new OnapNode();
- inputs = node.createOnapNode(inputs, cs, override);
- nodeTemplate.put(nodeName, node);
- this.setNode_templates(nodeTemplate);
+ //create the node template
+ TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
+ String nodeName = cs.getSelf().getName();
- //if present in component spec, populate policyNode information in the blueprint
- if(cs.getPolicyInfo() != null){
- PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs);
- }
+ //create the onap node that will be used
+ OnapNode node = new OnapNode();
+ inputs = node.createOnapNode(inputs, cs, override);
+ nodeTemplate.put(nodeName, node);
+ this.setNode_templates(nodeTemplate);
- //if present in component spec, populate pgaasNodes information in the blueprint
- if(cs.getAuxilary().getDatabases() != null){
- PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs);
- }
+ //if present in component spec, populate policyNode information in the blueprint
+ if (cs.getPolicyInfo() != null) {
+ PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs);
+ }
- //set the inputs
- this.setInputs(inputs);
+ //if present in component spec, populate pgaasNodes information in the blueprint
+ if (cs.getAuxilary().getDatabases() != null) {
+ PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs);
+ }
+ //set the inputs
+ this.setInputs(inputs);
- Blueprint bp = new Blueprint();
- bp.setImports(this.getImports());
- bp.setInputs(this.getInputs());
- bp.setNode_templates(this.getNode_templates());
- bp.setTosca_definitions_version(this.getTosca_definitions_version());
+ Blueprint bp = new Blueprint();
+ bp.setImports(this.getImports());
+ bp.setInputs(this.getInputs());
+ bp.setNode_templates(this.getNode_templates());
+ bp.setTosca_definitions_version(this.getTosca_definitions_version());
- return bp;
+ return bp;
- }
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
index b0d1302..9daea56 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
@@ -1,8 +1,10 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@@ -20,10 +22,18 @@
package org.onap.blueprintgenerator.models.onapbp;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.TreeMap;
-
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
import org.onap.blueprintgenerator.models.blueprint.Interfaces;
@@ -31,60 +41,54 @@ import org.onap.blueprintgenerator.models.blueprint.Node;
import org.onap.blueprintgenerator.models.blueprint.Properties;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter @Setter
-@EqualsAndHashCode(callSuper=false)
+@Getter
+@Setter
+@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
-@JsonInclude(value=Include.NON_NULL)
-
-public class OnapNode extends Node{
-
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
-
- //create and set the interfaces
- Interfaces inter = new Interfaces();
- retInputs = inter.createInterface(retInputs, cs);
- TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
- interfaces.put("cloudify.interfaces.lifecycle", inter);
- this.setInterfaces(interfaces);
-
- //set the type
- this.setType("dcae.nodes.ContainerizedServiceComponent");
-
- //create and set the relationships
- ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
-
- //add relationship for policy if exist
- if(cs.getPolicyInfo() != null){
- ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.getPolicyRelationships(cs);
- rets.addAll(policyRelationshipsList);
- }
-
- //add relationships and env_variables for pgaas dbs if exist
- if(cs.getAuxilary().getDatabases() != null){
- ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder.getPgaasNodeRelationships(cs);
- rets.addAll(pgaasRelationshipsList);
- }
-
- this.setRelationships(rets);
-
- //set the properties
- Properties props = new Properties();
- retInputs = props.createOnapProperties(retInputs, cs, override);
- this.setProperties(props);
-
- return retInputs;
- }
+@JsonInclude(value = Include.NON_NULL)
+
+public class OnapNode extends Node {
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ retInputs = inps;
+
+ //create and set the interfaces
+ Interfaces inter = new Interfaces();
+ retInputs = inter.createInterface(retInputs, cs);
+ TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
+ interfaces.put("cloudify.interfaces.lifecycle", inter);
+ this.setInterfaces(interfaces);
+
+ //set the type
+ this.setType(CONTENERIZED_SERVICE_COMPONENT);
+
+ //create and set the relationships
+ ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
+
+ //add relationship for policy if exist
+ if (cs.getPolicyInfo() != null) {
+ ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder
+ .getPolicyRelationships(cs);
+ rets.addAll(policyRelationshipsList);
+ }
+
+ //add relationships and env_variables for pgaas dbs if exist
+ if (cs.getAuxilary().getDatabases() != null) {
+ ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder
+ .getPgaasNodeRelationships(cs);
+ rets.addAll(pgaasRelationshipsList);
+ }
+
+ this.setRelationships(rets);
+
+ //set the properties
+ Properties props = new Properties();
+ retInputs = props.createOnapProperties(retInputs, cs, override);
+ this.setProperties(props);
+
+ return retInputs;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java
index 9c9bd51..81bc440 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java
@@ -1,37 +1,28 @@
-/**============LICENSE_START=======================================================
- org.onap.dcae
- ================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
*/
package org.onap.blueprintgenerator.models.policymodel;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
-
-import org.onap.blueprintgenerator.models.blueprint.Node;
-import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.Parameters;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_SIMPLE_YAML;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerationException;
@@ -39,101 +30,107 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+import org.onap.blueprintgenerator.models.componentspec.Parameters;
-@Getter @Setter
+@Getter
+@Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PolicyModel {
-
- private String tosca_definition_version;
- private TreeMap<String, PolicyModelNode> node_types;
- private TreeMap<String, PolicyModelNode> data_types;
-
- public ArrayList<PolicyModel> createPolicyModels(ComponentSpec cs, String filePath) {
- ArrayList<PolicyModel> models = new ArrayList();
- Parameters[] params = cs.getParameters();
-
- ArrayList<String> groups = new ArrayList<String>();
- groups = getModelGroups(params);
-
- for(String s: groups) {
- PolicyModel model = new PolicyModel();
- model = model.createPolicyModel(s, params);
- //models.add(model);
- policyModelToYaml(filePath, model, s);
- }
-
+
+ private String tosca_definition_version;
+ private TreeMap<String, PolicyModelNode> node_types;
+ private TreeMap<String, PolicyModelNode> data_types;
+
+ public ArrayList<PolicyModel> createPolicyModels(ComponentSpec cs, String filePath) {
+ ArrayList<PolicyModel> models = new ArrayList();
+ Parameters[] params = cs.getParameters();
+
+ ArrayList<String> groups = new ArrayList<String>();
+ groups = getModelGroups(params);
+
+ for (String s : groups) {
+ PolicyModel model = new PolicyModel();
+ model = model.createPolicyModel(s, params);
+ //models.add(model);
+ policyModelToYaml(filePath, model, s);
+ }
+
// for(PolicyModel p: models) {
// policyModelToYaml(filePath, p);
// }
- return models;
- }
-
- public ArrayList<String> getModelGroups(Parameters[] params) {
- ArrayList<String> groups = new ArrayList();
-
- for(Parameters p: params) {
- if(p.isPolicy_editable()) {
- if(groups.isEmpty()) {
- groups.add(p.getPolicy_group());
- } else {
- if(!groups.contains(p.getPolicy_group())) {
- groups.add(p.getPolicy_group());
- }
- }
- }
- }
-
- return groups;
- }
-
- public PolicyModel createPolicyModel(String s, Parameters[] params) {
- PolicyModel model = new PolicyModel();
- model.setTosca_definition_version("tosca_simple_yaml_1_0_0");
-
- PolicyModelNode node = new PolicyModelNode();
- String hasEntryScheme = node.createNodeType(s, params);
- String nodeTypeName = "onap.policy." + s;
- TreeMap<String, PolicyModelNode> nodeType = new TreeMap();
- nodeType.put(nodeTypeName, node);
- model.setNode_types(nodeType);
-
- if(!hasEntryScheme.equals("")) {
- PolicyModelNode data = new PolicyModelNode();
- TreeMap<String, PolicyModelNode> dataType = data.createDataTypes(hasEntryScheme, params);
- model.setData_types(dataType);
- }
-
- return model;
- }
-
- public void policyModelToYaml(String path, PolicyModel p, String name) {
- File outputFile;
- String filePath = path + "/" + name + ".yml";
- File policyFile = new File(filePath);
- ObjectMapper policyMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
- outputFile = new File(path, name + ".yml");
- outputFile.getParentFile().mkdirs();
-
- try {
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)));
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- try {
- policyMapper.writeValue(outputFile, p);
- } catch (JsonGenerationException e) {
- e.printStackTrace();
- } catch (JsonMappingException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- System.out.println("model " + name + " created");
- }
+ return models;
+ }
+
+ public ArrayList<String> getModelGroups(Parameters[] params) {
+ ArrayList<String> groups = new ArrayList();
+
+ for (Parameters p : params) {
+ if (p.isPolicy_editable()) {
+ if (groups.isEmpty()) {
+ groups.add(p.getPolicy_group());
+ } else {
+ if (!groups.contains(p.getPolicy_group())) {
+ groups.add(p.getPolicy_group());
+ }
+ }
+ }
+ }
+
+ return groups;
+ }
+
+ public PolicyModel createPolicyModel(String s, Parameters[] params) {
+ PolicyModel model = new PolicyModel();
+ model.setTosca_definition_version(TOSCA_SIMPLE_YAML);
+
+ PolicyModelNode node = new PolicyModelNode();
+ String hasEntryScheme = node.createNodeType(s, params);
+ String nodeTypeName = "onap.policy." + s;
+ TreeMap<String, PolicyModelNode> nodeType = new TreeMap();
+ nodeType.put(nodeTypeName, node);
+ model.setNode_types(nodeType);
+
+ if (!hasEntryScheme.equals("")) {
+ PolicyModelNode data = new PolicyModelNode();
+ TreeMap<String, PolicyModelNode> dataType = data.createDataTypes(hasEntryScheme, params);
+ model.setData_types(dataType);
+ }
+
+ return model;
+ }
+
+ public void policyModelToYaml(String path, PolicyModel p, String name) {
+ File outputFile;
+ String filePath = path + "/" + name + ".yml";
+ File policyFile = new File(filePath);
+ ObjectMapper policyMapper = new ObjectMapper(
+ new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
+ outputFile = new File(path, name + ".yml");
+ outputFile.getParentFile().mkdirs();
+
+ try {
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ policyMapper.writeValue(outputFile, p);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ System.out.println("model " + name + " created");
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java
index 56d1d13..89321de 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java
@@ -1,8 +1,10 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@@ -20,128 +22,126 @@
package org.onap.blueprintgenerator.models.policymodel;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_DATATYPES_ROOT;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_NODES_ROOT;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.TreeMap;
-
-import org.onap.blueprintgenerator.models.blueprint.Node;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.blueprintgenerator.models.componentspec.EntrySchemaObj;
import org.onap.blueprintgenerator.models.componentspec.Parameters;
import org.onap.blueprintgenerator.models.componentspec.PolicySchemaObj;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.Getter;
-import lombok.Setter;
-
-@Getter @Setter
+@Getter
+@Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PolicyModelNode {
-
- private String derived_from;
- private TreeMap<String, PolicyProperties> properties;
-
- public String createNodeType(String policyName, Parameters[] params) {
- String hasEntrySchema = "";
-
- TreeMap<String, PolicyProperties> props = new TreeMap();
- for(Parameters p: params) {
- if(p.getPolicy_group() != null) {
- if(p.getPolicy_group().equals(policyName)) {
- String name = p.getName();
- String type = p.getType();
- PolicyProperties polProps = new PolicyProperties();
- if(p.getPolicy_schema() != null) {
- polProps.setType("map");
- HashMap<String, String> entrySchema = new HashMap();
- entrySchema.put("type", "onap.datatypes." + name);
- //ArrayList<String> entrySchema = new ArrayList<String>();
- //entrySchema.add("type: onap.data." + name);
- polProps.setEntry_schema(entrySchema);
- hasEntrySchema = name;
- props.put(name, polProps);
- }
- else {
- polProps.setType(type);
- props.put(name, polProps);
- }
- }
- }
- }
-
- this.setDerived_from("tosca.datatypes.Root");
- this.setProperties(props);
- return hasEntrySchema;
- }
-
- public TreeMap<String, PolicyModelNode> createDataTypes(String param, Parameters[] parameters) {
- TreeMap<String, PolicyModelNode> dataType = new TreeMap<String, PolicyModelNode>();
-
- PolicyModelNode node = new PolicyModelNode();
- node.setDerived_from("tosca.datatypes.Root");
-
- TreeMap<String, PolicyProperties> properties = new TreeMap();
-
- Parameters par = new Parameters();
- for(Parameters p: parameters) {
- if(p.getName().equals(param)) {
- par = p;
- break;
- }
- }
-
- for(PolicySchemaObj pol: par.getPolicy_schema()) {
- if(pol.getEntry_schema() != null) {
- PolicyProperties prop = new PolicyProperties();
- prop.setType("map");
- HashMap<String, String> schema = new HashMap();
- schema.put("type", "onap.datatypes." + pol.getName());
+
+ private String derived_from;
+ private TreeMap<String, PolicyProperties> properties;
+
+ public String createNodeType(String policyName, Parameters[] params) {
+ String hasEntrySchema = "";
+
+ TreeMap<String, PolicyProperties> props = new TreeMap();
+ for (Parameters p : params) {
+ if (p.getPolicy_group() != null) {
+ if (p.getPolicy_group().equals(policyName)) {
+ String name = p.getName();
+ String type = p.getType();
+ PolicyProperties polProps = new PolicyProperties();
+ if (p.getPolicy_schema() != null) {
+ polProps.setType("map");
+ HashMap<String, String> entrySchema = new HashMap();
+ entrySchema.put("type", "onap.datatypes." + name);
+ //ArrayList<String> entrySchema = new ArrayList<String>();
+ //entrySchema.add("type: onap.data." + name);
+ polProps.setEntry_schema(entrySchema);
+ hasEntrySchema = name;
+ props.put(name, polProps);
+ } else {
+ polProps.setType(type);
+ props.put(name, polProps);
+ }
+ }
+ }
+ }
+
+ this.setDerived_from(TOSCA_DATATYPES_ROOT);
+ this.setProperties(props);
+ return hasEntrySchema;
+ }
+
+ public TreeMap<String, PolicyModelNode> createDataTypes(String param, Parameters[] parameters) {
+ TreeMap<String, PolicyModelNode> dataType = new TreeMap<String, PolicyModelNode>();
+
+ PolicyModelNode node = new PolicyModelNode();
+ node.setDerived_from(TOSCA_DATATYPES_ROOT);
+
+ TreeMap<String, PolicyProperties> properties = new TreeMap();
+
+ Parameters par = new Parameters();
+ for (Parameters p : parameters) {
+ if (p.getName().equals(param)) {
+ par = p;
+ break;
+ }
+ }
+
+ for (PolicySchemaObj pol : par.getPolicy_schema()) {
+ if (pol.getEntry_schema() != null) {
+ PolicyProperties prop = new PolicyProperties();
+ prop.setType("map");
+ HashMap<String, String> schema = new HashMap();
+ schema.put("type", "onap.datatypes." + pol.getName());
// prop.setType("list");
// ArrayList<String> schema = new ArrayList();
// schema.add("type: onap.data." + pol.getName());
- prop.setEntry_schema(schema);
- properties.put(pol.getName(), prop);
- dataType = translateEntrySchema(dataType, pol.getEntry_schema(), pol.getName());
- }
- else {
- PolicyProperties prop = new PolicyProperties();
- prop.setType(pol.getType());
- properties.put(pol.getName(), prop);
- }
- }
-
- node.setProperties(properties);
- dataType.put("onap.datatypes." + param, node);
- return dataType;
- }
-
- private TreeMap<String, PolicyModelNode> translateEntrySchema(TreeMap<String, PolicyModelNode> dataType, EntrySchemaObj[] entry, String name){
- TreeMap<String, PolicyModelNode> data = dataType;
- PolicyModelNode node = new PolicyModelNode();
- node.setDerived_from("tosca.nodes.Root");
- TreeMap<String, PolicyProperties> properties = new TreeMap<String, PolicyProperties>();
-
- for(EntrySchemaObj e: entry) {
- if(e.getEntry_schema() != null) {
- PolicyProperties prop = new PolicyProperties();
- prop.setType("list");
- ArrayList<String> schema = new ArrayList<String>();
- schema.add("type: onap.datatypes." + e.getName());
- prop.setEntry_schema(schema);
- properties.put(e.getName(), prop);
- data = translateEntrySchema(data, e.getEntry_schema(), e.getName());
- node.setProperties(properties);
- } else {
- PolicyProperties prop = new PolicyProperties();
- prop.setType(e.getType());
- properties.put(e.getName(), prop);
- node.setProperties(properties);
- }
- }
-
- dataType.put("onap.datatypes." + name, node);
- return data;
- }
+ prop.setEntry_schema(schema);
+ properties.put(pol.getName(), prop);
+ dataType = translateEntrySchema(dataType, pol.getEntry_schema(), pol.getName());
+ } else {
+ PolicyProperties prop = new PolicyProperties();
+ prop.setType(pol.getType());
+ properties.put(pol.getName(), prop);
+ }
+ }
+
+ node.setProperties(properties);
+ dataType.put("onap.datatypes." + param, node);
+ return dataType;
+ }
+
+ private TreeMap<String, PolicyModelNode> translateEntrySchema(TreeMap<String, PolicyModelNode> dataType,
+ EntrySchemaObj[] entry, String name) {
+ TreeMap<String, PolicyModelNode> data = dataType;
+ PolicyModelNode node = new PolicyModelNode();
+ node.setDerived_from(TOSCA_NODES_ROOT);
+ TreeMap<String, PolicyProperties> properties = new TreeMap<String, PolicyProperties>();
+
+ for (EntrySchemaObj e : entry) {
+ if (e.getEntry_schema() != null) {
+ PolicyProperties prop = new PolicyProperties();
+ prop.setType("list");
+ ArrayList<String> schema = new ArrayList<String>();
+ schema.add("type: onap.datatypes." + e.getName());
+ prop.setEntry_schema(schema);
+ properties.put(e.getName(), prop);
+ data = translateEntrySchema(data, e.getEntry_schema(), e.getName());
+ node.setProperties(properties);
+ } else {
+ PolicyProperties prop = new PolicyProperties();
+ prop.setType(e.getType());
+ properties.put(e.getName(), prop);
+ node.setProperties(properties);
+ }
+ }
+
+ dataType.put("onap.datatypes." + name, node);
+ return data;
+ }
}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
index 1c7e592..b978701 100644
--- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
@@ -21,15 +21,14 @@
package org.onap.blueprintgenerator.core;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -39,22 +38,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.onap.blueprintgenerator.models.blueprint.Blueprint;
import org.onap.blueprintgenerator.models.blueprint.GetInput;
-import org.onap.blueprintgenerator.models.componentspec.Artifacts;
-import org.onap.blueprintgenerator.models.componentspec.Auxilary;
-import org.onap.blueprintgenerator.models.componentspec.CallsObj;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.Container;
-import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
-import org.onap.blueprintgenerator.models.componentspec.Host;
-import org.onap.blueprintgenerator.models.componentspec.Parameters;
-import org.onap.blueprintgenerator.models.componentspec.Policy;
-import org.onap.blueprintgenerator.models.componentspec.ProvidesObj;
-import org.onap.blueprintgenerator.models.componentspec.Publishes;
-import org.onap.blueprintgenerator.models.componentspec.Self;
-import org.onap.blueprintgenerator.models.componentspec.Services;
-import org.onap.blueprintgenerator.models.componentspec.Streams;
-import org.onap.blueprintgenerator.models.componentspec.Subscribes;
-import org.onap.blueprintgenerator.models.componentspec.Volumes;
import org.onap.blueprintgenerator.models.dmaapbp.DmaapNode;
import org.onap.blueprintgenerator.models.onapbp.OnapNode;
import org.onap.blueprintgenerator.models.policymodel.PolicyModel;
@@ -70,146 +54,20 @@ public class BlueprintGeneratorTest {
/**
* Component spec test.
*
- * @throws JsonParseException the json parse exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
-
@Test
- public void componentSpecTest() throws JsonParseException, JsonMappingException, IOException {
-
+ public void componentSpecTest() {
ComponentSpec spec = new ComponentSpec();
TestComponentSpec test = new TestComponentSpec();
- spec.createComponentSpecFromString(test.getCs());
-
- //Manually fill a component spec object with the values from the file itself
- ComponentSpec manualSpec = new ComponentSpec();
-
- Self self = new Self();
- self.setComponent_type("docker");
- self.setDescription("Test component spec");
- self.setName("test.component.spec");
- self.setVersion("1.0.1");
- manualSpec.setSelf(self);
-
- //assertEquals(manualSpec.getSelf(), spec.getSelf());
-
- Services services = new Services();
- CallsObj[] calls = new CallsObj[0];
- ProvidesObj[] provides = new ProvidesObj[0];
- services.setCalls(calls);
- services.setProvides(provides);
- manualSpec.setServices(null);
-
- //assertEquals(manualSpec.getServices(), spec.getServices());
-
- Streams streams = new Streams();
- Publishes[] publishes = new Publishes[2];
- Publishes pub1 = new Publishes();
- pub1.setConfig_key("TEST-PUB-DR");
- pub1.setFormat("dataformat_Hello_World_PM");
- pub1.setType("data_router");
- pub1.setVersion("1.0.0");
-
- Publishes pub2 = new Publishes();
- pub2.setConfig_key("TEST-PUB-MR");
- pub2.setFormat("dataformat_Hello_World_PM");
- pub2.setType("message_router");
- pub2.setVersion("1.0.0");
- publishes[0] = pub1;
- publishes[1] = pub2;
- streams.setPublishes(publishes);
-
- Subscribes[] subscribes = new Subscribes[2];
- Subscribes sub1 = new Subscribes();
- sub1.setConfig_key("TEST-SUB-MR");
- sub1.setFormat("dataformat_Hello_World_PM");
- sub1.setRoute("/TEST_HELLO_WORLD_SUB_MR");
- sub1.setType("message_router");
- sub1.setVersion("1.0.0");
-
- Subscribes sub2 = new Subscribes();
- sub2.setConfig_key("TEST-SUB-DR");
- sub2.setFormat("dataformat_Hello_World_PM");
- sub2.setRoute("/TEST-HELLO-WORLD-SUB-DR");
- sub2.setType("data_router");
- sub2.setVersion("1.0.0");
- subscribes[0] = sub1;
- subscribes[1] = sub2;
- streams.setSubscribes(subscribes);
-
- manualSpec.setStreams(streams);
-
- //assertEquals(manualSpec.getStreams(), spec.getStreams());
-
- Parameters[] parameters = new Parameters[1];
- Parameters par1 = new Parameters();
- par1.setName("testParam1");
- par1.setValue("test-param-1");
- par1.setDescription("test parameter 1");
- par1.setSourced_at_deployment(true);
- par1.setDesigner_editable(true);
- par1.setPolicy_editable(true);
- par1.setPolicy_group("Test_Parameters");
- par1.setRequired(true);
- par1.setType("string");
- parameters[0] = par1;
-
- manualSpec.setParameters(parameters);
-
- //assertEquals(manualSpec.getParameters(), spec.getParameters());
-
- Auxilary auxilary = new Auxilary();
- HealthCheck healthcheck = new HealthCheck();
- healthcheck.setInterval("300s");
- healthcheck.setTimeout("120s");
- healthcheck.setScript("/etc/init.d/nagios status");
- healthcheck.setType("docker");
- auxilary.setHealthcheck(healthcheck);
-
- Volumes[] volumes = new Volumes[1];
- Volumes vol1 = new Volumes();
- Container con1 = new Container();
- con1.setBind("/opt/app/manager/config/hostname");
- Host host1 = new Host();
- host1.setPath("/etc/hostname");
- host1.setMode("ro");
- vol1.setContainer(con1);
- vol1.setHost(host1);
-
- volumes[0] = vol1;
-
- auxilary.setVolumes(volumes);
-
- ArrayList<Object> ports = new ArrayList();
- ports.add("80:90");
- ports.add("99:99");
-
- TreeMap<String, String> dataBases = new TreeMap<String, String>();
- dataBases.put("TestDB1", "PGaaS");
- dataBases.put("TestDB2", "PGaaS");
- auxilary.setDatabases(dataBases);
-
- Policy pol = new Policy();
- pol.setTrigger_type("docker");
- pol.setScript_path("/opt/app/manager/bin/reconfigure.sh");
- auxilary.setPolicy(pol);
-
- auxilary.setPorts(ports);
-
- manualSpec.setAuxilary(auxilary);
-
- //assertEquals(manualSpec.getAuxilary(), spec.getAuxilary());
-
- Artifacts[] artifacts = new Artifacts[1];
- Artifacts art = new Artifacts();
- art.setType("docker image");
- art.setUri("test.tester");
-
- artifacts[0] = art;
- manualSpec.setArtifacts(artifacts);
-
- //assertEquals(manualSpec.getArtifacts(), spec.getArtifacts());
+ spec.createComponentSpecFromString(test.getComponentSpecAsString());
+ ComponentSpec expectedSpec = test.getComponentSpec();
+
+ assertEquals(expectedSpec.getSelf(), spec.getSelf());
+ assertEquals(expectedSpec.getServices(), spec.getServices());
+ assertEquals(expectedSpec.getStreams(), spec.getStreams());
+ assertArrayEquals(expectedSpec.getParameters(), spec.getParameters());
+ assertEquals(expectedSpec.getAuxilary(), spec.getAuxilary());
+ assertArrayEquals(expectedSpec.getArtifacts(), spec.getArtifacts());
}
/**
@@ -219,11 +77,11 @@ public class BlueprintGeneratorTest {
public void toscaDefinitionTest() {
ComponentSpec cs = new ComponentSpec();
TestComponentSpec test = new TestComponentSpec();
- cs.createComponentSpecFromString(test.getCs());
+ cs.createComponentSpecFromString(test.getComponentSpecAsString());
Blueprint bp = new Blueprint();
bp = bp.createBlueprint(cs, "", 'o', "", "");
- assertEquals(bp.getTosca_definitions_version(), "cloudify_dsl_1_3");
+ assertEquals("cloudify_dsl_1_3", bp.getTosca_definitions_version());
}
/**
@@ -233,19 +91,16 @@ public class BlueprintGeneratorTest {
public void importsTest() {
ComponentSpec cs = new ComponentSpec();
TestComponentSpec test = new TestComponentSpec();
- cs.createComponentSpecFromString(test.getCs());
+ cs.createComponentSpecFromString(test.getComponentSpecAsString());
Blueprint bp = new Blueprint();
bp = bp.createBlueprint(cs, "", 'o', "", "");
- ArrayList<String> imps = new ArrayList<String>();
-
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add(
- "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml");
- imps.add(
- "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml");
- assertEquals(bp.getImports(), imps);
+ ArrayList<String> imps = new ArrayList<>();
+ imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
+ imps.add("plugin:k8splugin?version=3.4.2");
+ imps.add("plugin:dcaepolicyplugin?version=2.4.0");
+ assertEquals(imps, bp.getImports());
}
@Test
@@ -256,50 +111,49 @@ public class BlueprintGeneratorTest {
Blueprint bp = new Blueprint();
bp = bp.createBlueprint(cs, "", 'o', "", "");
- TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<>();
//mr inputs
- LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
stringType.put("type", "string");
//necessary inputs
- LinkedHashMap<String, Object> tag = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> tag = new LinkedHashMap<>();
tag.put("type", "string");
String tester = "test.tester";
tag.put("default", '"' + tester + '"');
- String tagVersion = "tag_version";
inputs.put("tag_version", tag);
inputs.put("log_directory", stringType);
- LinkedHashMap cert = new LinkedHashMap();
+ LinkedHashMap<String, Object> cert = new LinkedHashMap<>();
cert.put("type", "string");
cert.put("default", "");
inputs.put("cert_directory", cert);
- LinkedHashMap<String, Object> env = new LinkedHashMap();
+ LinkedHashMap<String, Object> env = new LinkedHashMap<>();
env.put("default", "{}");
inputs.put("envs", env);
- LinkedHashMap port = new LinkedHashMap();
+ LinkedHashMap<String, Object> port = new LinkedHashMap<>();
port.put("type", "string");
port.put("description", "Kubernetes node port on which collector is exposed");
port.put("default", "99");
inputs.put("external_port", port);
- LinkedHashMap<String, Object> rep = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> rep = new LinkedHashMap<>();
rep.put("type", "integer");
rep.put("description", "number of instances");
rep.put("default", 1);
inputs.put("replicas", rep);
- LinkedHashMap<String, Object> aaf = new LinkedHashMap();
+ LinkedHashMap<String, Object> aaf = new LinkedHashMap<>();
aaf.put("type", "boolean");
aaf.put("default", false);
inputs.put("use_tls", aaf);
//parmaeter input
- LinkedHashMap<String, Object> test = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> test = new LinkedHashMap<>();
test.put("type", "string");
String testParam = "test-param-1";
test.put("default", '"' + testParam + '"');
@@ -325,19 +179,17 @@ public class BlueprintGeneratorTest {
inputs.put("topic0_name", stringType);
inputs.put("topic1_name", stringType);
- LinkedHashMap<String, Object> cpu = new LinkedHashMap();
+ LinkedHashMap<String, Object> cpu = new LinkedHashMap<>();
cpu.put("type", "string");
cpu.put("default", "250m");
inputs.put("test.component.spec_cpu_limit", cpu);
inputs.put("test.component.spec_cpu_request", cpu);
- LinkedHashMap<String, Object> mem = new LinkedHashMap();
+ LinkedHashMap<String, Object> mem = new LinkedHashMap<>();
mem.put("type", "string");
mem.put("default", "128Mi");
inputs.put("test.component.spec_memory_limit", mem);
inputs.put("test.component.spec_memory_request", mem);
-
- assertEquals(true, true);
}
@Test
@@ -355,10 +207,9 @@ public class BlueprintGeneratorTest {
//set the type
testNode.setType("dcae.nodes.ContainerizedServiceComponent");
- ArrayList<String> ports = new ArrayList<String>();
+ ArrayList<String> ports = new ArrayList<>();
ports.add("concat: [\"80:\", {get_input: external_port }]");
ports.add("concat: [\"99:\", {get_input: external_port }]");
- assertEquals(true, true);
}
@Test
@@ -372,7 +223,7 @@ public class BlueprintGeneratorTest {
OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
GetInput par = (GetInput) node.getProperties().getApplication_config().getParams().get("testParam1");
- assertEquals(par.getBpInputName(), "testParam1");
+ assertEquals("testParam1", par.getBpInputName());
}
@Test
@@ -385,13 +236,7 @@ public class BlueprintGeneratorTest {
OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
- boolean test = false;
- if (!node.getProperties().getApplication_config().getStreams_publishes().isEmpty()) {
- test = true;
- System.out.println("tst");
- }
-
- assertEquals(true, test);
+ assertFalse(node.getProperties().getApplication_config().getStreams_publishes().isEmpty());
}
@Test
@@ -405,13 +250,8 @@ public class BlueprintGeneratorTest {
DmaapNode dmaap = (DmaapNode) bp.getNode_templates().get("test.component.spec");
//check if the stream publishes and subscribes are not null to see if the dmaap plugin was invoked properly
- boolean d = false;
-
- if (dmaap.getProperties().getStreams_publishes() != null
- || dmaap.getProperties().getStreams_subscribes() != null) {
- d = true;
- }
- assertEquals(true, d);
+ assertNotNull(dmaap.getProperties().getStreams_publishes());
+ assertNotNull(dmaap.getProperties().getStreams_subscribes());
}
@Test
@@ -442,17 +282,5 @@ public class BlueprintGeneratorTest {
PolicyModel p = new PolicyModel();
p.createPolicyModels(cs, "TestModels");
-
- assertEquals(true, true);
- }
-
- private void assertContainsInputWithDefault(Blueprint bp, String inputName, Object defaultValue) {
- LinkedHashMap<String, Object> input = bp.getInputs().get(inputName);
- assertNotNull(input);
- assertEquals(defaultValue, input.get("default"));
- }
-
- private String inQuotes(String filedName) {
- return String.format("\"%s\"", filedName);
}
}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java
new file mode 100644
index 0000000..1ce296a
--- /dev/null
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java
@@ -0,0 +1,52 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ */
+
+package org.onap.blueprintgenerator.models.blueprint;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Test;
+
+public class ImportsTest {
+
+ private final List<String> expectedImports = Arrays.asList(
+ "https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml",
+ "plugin:k8splugin?version=3.4.1",
+ "plugin:pgaas?version=1.3.0",
+ "plugin:clamppolicyplugin?version=1.1.0",
+ "plugin:dmaap?version=1.5.0"
+ );
+
+ @Test
+ public void shouldReadImportsFromFile() {
+ ArrayList<String> importsFromFile = Imports.createImportsFromFile("TestCases/imports/imports.yaml");
+ assertEquals(expectedImports, importsFromFile);
+ }
+
+ @Test
+ public void shouldRemoveBlankImportsFromFile() {
+ ArrayList<String> importsFromFile =
+ Imports.createImportsFromFile("TestCases/imports/importsWithBlanks.yaml");
+ assertEquals(expectedImports, importsFromFile);
+ }
+
+}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java
index e854b19..1cdb58b 100644
--- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java
@@ -25,7 +25,7 @@ import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalCertificate
import java.util.LinkedHashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.COMMON_NAME_FIELD;
import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_COMMON_NAME;
import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_SANS;
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java
new file mode 100644
index 0000000..9e31002
--- /dev/null
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java
@@ -0,0 +1,245 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.blueprintgenerator.models.dmaapbp;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.onap.blueprintgenerator.models.blueprint.Blueprint;
+import org.onap.blueprintgenerator.models.componentspec.Artifacts;
+import org.onap.blueprintgenerator.models.componentspec.Auxilary;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+import org.onap.blueprintgenerator.models.componentspec.Parameters;
+import org.onap.blueprintgenerator.models.componentspec.Publishes;
+import org.onap.blueprintgenerator.models.componentspec.Self;
+import org.onap.blueprintgenerator.models.componentspec.Streams;
+import org.onap.blueprintgenerator.models.componentspec.Subscribes;
+
+public class DmaapBlueprintTest {
+
+ private static final String MOCKED_NAME = "sample.name";
+ private static final String MESSAGE_ROUTER_TYPE_1 = "message_router";
+ private static final String MESSAGE_ROUTER_TYPE_2 = "message router";
+ private static final String DATA_ROUTER_TYPE_1 = "data_router";
+ private static final String DATA_ROUTER_TYPE_2 = "data router";
+ private static final String CONFIG_KEY_1 = "Configkey1";
+ private static final String CONFIG_KEY_2 = "Configkey2";
+
+ private static final String TOPIC_NODE_1 = CONFIG_KEY_1 + "_topic";
+ private static final String TOPIC_NODE_2 = CONFIG_KEY_2 + "_topic";
+ private static final String FEED_NODE_1 = CONFIG_KEY_1 + "_feed";
+ private static final String FEED_NODE_2 = CONFIG_KEY_2 + "_feed";
+
+ private static final String SAMPLE_FORMAT = "Format";
+ private static final String SAMPLE_VERSION = "1.0.0";
+ private static final String SAMPLE_ROUTE = "SampleRoute";
+ private static final String SAMPLE_DESCRIPTION = "sample description";
+ private static final String SAMPLE_PORTS = "8080:8080";
+ private static final String SAMPLE_ARTIFACT_TYPE = "test";
+ private static final String SAMPLE_ARTIFACT_URI = "test_uri";
+
+ @Test
+ public void dmaapBlueprintShouldHaveNodeTemplateWithDmaapNode() {
+
+ //given
+ ComponentSpec componentSpec = getMockedComponentSpec();
+ DmaapBlueprint dmaapBlueprint = new DmaapBlueprint();
+
+ //when
+ Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", "");
+
+ //then
+ assertTrue(resultBlueprint.getNode_templates().get(MOCKED_NAME) instanceof DmaapNode);
+ }
+
+ @Test
+ public void nodeTemplateHasTopicNodeWhenAddMessageRouterAsPublishes() {
+ //given
+ ComponentSpec componentSpec = getMockedComponentSpec();
+ Streams streams = new Streams();
+ streams.setPublishes(getMessageRouterPublishes());
+ streams.setSubscribes(new Subscribes[0]);
+
+ when(componentSpec.getStreams()).thenReturn(streams);
+ DmaapBlueprint dmaapBlueprint = new DmaapBlueprint();
+
+ //when
+ Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", "");
+
+ //then
+ assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_1));
+ assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_2));
+
+ }
+
+ @Test
+ public void nodeTemplateHasTopicNodeWhenAddMessageRouterAsSubscribes() {
+ //given
+ ComponentSpec componentSpec = getMockedComponentSpec();
+ Streams streams = new Streams();
+ streams.setPublishes(new Publishes[0]);
+ streams.setSubscribes(getMessageRouterSubscribes());
+
+ when(componentSpec.getStreams()).thenReturn(streams);
+ DmaapBlueprint dmaapBlueprint = new DmaapBlueprint();
+
+ //when
+ Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", "");
+
+ //then
+ assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_1));
+ assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_2));
+
+ }
+
+ @Test
+ public void nodeTemplateHasFeedNodeWhenAddDataRouterAsPublishes() {
+ //given
+ ComponentSpec componentSpec = getMockedComponentSpec();
+ Streams streams = new Streams();
+ streams.setPublishes(getDataRouterPublishes());
+ streams.setSubscribes(new Subscribes[0]);
+
+ when(componentSpec.getStreams()).thenReturn(streams);
+ DmaapBlueprint dmaapBlueprint = new DmaapBlueprint();
+
+ //when
+ Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", "");
+
+ //then
+ assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_1));
+ assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_2));
+
+ }
+
+ @Test
+ public void nodeTemplateHasFeedNodeWhenAddDataRouterAsSubscribes() {
+ //given
+ ComponentSpec componentSpec = getMockedComponentSpec();
+ Streams streams = new Streams();
+ streams.setPublishes(new Publishes[0]);
+ streams.setSubscribes(getDataRouterSubscribes());
+
+ when(componentSpec.getStreams()).thenReturn(streams);
+ DmaapBlueprint dmaapBlueprint = new DmaapBlueprint();
+
+ //when
+ Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", "");
+
+ //then
+ assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_1));
+ assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_2));
+
+ }
+
+ private Publishes[] getMessageRouterPublishes() {
+ List<Publishes> publishesList = new ArrayList<>();
+
+ publishesList.add(createSamplePublishes(MESSAGE_ROUTER_TYPE_1, CONFIG_KEY_1));
+ publishesList.add(createSamplePublishes(MESSAGE_ROUTER_TYPE_2, CONFIG_KEY_2));
+ return publishesList.toArray(new Publishes[0]);
+ }
+
+ private Subscribes[] getMessageRouterSubscribes() {
+ List<Subscribes> subscribesList = new ArrayList<>();
+
+ subscribesList.add(createSampleSubscribes(MESSAGE_ROUTER_TYPE_1, CONFIG_KEY_1));
+ subscribesList.add(createSampleSubscribes(MESSAGE_ROUTER_TYPE_2, CONFIG_KEY_2));
+ return subscribesList.toArray(new Subscribes[0]);
+ }
+
+ private Publishes[] getDataRouterPublishes() {
+ List<Publishes> publishesList = new ArrayList<>();
+
+ publishesList.add(createSamplePublishes(DATA_ROUTER_TYPE_1, CONFIG_KEY_1));
+ publishesList.add(createSamplePublishes(DATA_ROUTER_TYPE_2, CONFIG_KEY_2));
+ return publishesList.toArray(new Publishes[0]);
+ }
+
+ private Subscribes[] getDataRouterSubscribes() {
+ List<Subscribes> subscribesList = new ArrayList<>();
+
+ subscribesList.add(createSampleSubscribes(DATA_ROUTER_TYPE_1, CONFIG_KEY_1));
+ subscribesList.add(createSampleSubscribes(DATA_ROUTER_TYPE_2, CONFIG_KEY_2));
+ return subscribesList.toArray(new Subscribes[0]);
+ }
+
+ private Publishes createSamplePublishes(String type, String key) {
+ Publishes publishes = new Publishes();
+
+ publishes.setType(type);
+ publishes.setConfig_key(key);
+ publishes.setFormat(SAMPLE_FORMAT);
+ publishes.setVersion(SAMPLE_VERSION);
+ publishes.setRoute(SAMPLE_ROUTE);
+
+ return publishes;
+ }
+
+ private Subscribes createSampleSubscribes(String type, String key) {
+ Subscribes subscribes = new Subscribes();
+
+ subscribes.setType(type);
+ subscribes.setConfig_key(key);
+ subscribes.setFormat(SAMPLE_FORMAT);
+ subscribes.setVersion(SAMPLE_FORMAT);
+ subscribes.setRoute(SAMPLE_ROUTE);
+
+ return subscribes;
+ }
+
+ private ComponentSpec getMockedComponentSpec() {
+ Self self = mock(Self.class);
+ when(self.getDescription()).thenReturn(SAMPLE_DESCRIPTION);
+ when(self.getName()).thenReturn(MOCKED_NAME);
+
+ Auxilary auxilary = mock(Auxilary.class);
+ ArrayList<Object> ports = new ArrayList<>();
+ ports.add(SAMPLE_PORTS);
+ when(auxilary.getPorts()).thenReturn(ports);
+
+ Streams streams = mock(Streams.class);
+ when(streams.getPublishes()).thenReturn(new Publishes[0]);
+ when(streams.getSubscribes()).thenReturn(new Subscribes[0]);
+
+ Artifacts artifact = new Artifacts();
+ artifact.setType(SAMPLE_ARTIFACT_TYPE);
+ artifact.setUri(SAMPLE_ARTIFACT_URI);
+
+ Artifacts[] arrayArtifacts = new Artifacts[10];
+ arrayArtifacts[0] = artifact;
+
+ ComponentSpec componentSpec = mock(ComponentSpec.class);
+ when(componentSpec.getSelf()).thenReturn(self);
+ when(componentSpec.getAuxilary()).thenReturn(auxilary);
+ when(componentSpec.getStreams()).thenReturn(streams);
+ when(componentSpec.getArtifacts()).thenReturn(arrayArtifacts);
+ when(componentSpec.getParameters()).thenReturn(new Parameters[0]);
+ when(componentSpec.getSelfName()).thenReturn(MOCKED_NAME);
+ return componentSpec;
+ }
+}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java
new file mode 100644
index 0000000..83419e5
--- /dev/null
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java
@@ -0,0 +1,224 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ */
+
+package org.onap.blueprintgenerator.models.dmaapbp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.FEED;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_EVENTS;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_FILES;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOPIC;
+
+import java.util.Map;
+import java.util.TreeMap;
+import org.junit.Test;
+import org.onap.blueprintgenerator.core.TestComponentSpec;
+import org.onap.blueprintgenerator.models.componentspec.Auxilary;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+import org.onap.blueprintgenerator.models.componentspec.Publishes;
+import org.onap.blueprintgenerator.models.componentspec.Streams;
+import org.onap.blueprintgenerator.models.componentspec.Subscribes;
+
+public class DmaapNodeTest {
+
+ private static final String DATA_ROUTER_TYPE = "data_router";
+ private static final String MESSAGE_ROUTER_TYPE = "message_router";
+
+ private static final String CONFIG_KEY = "Configkey";
+
+ private static final String SAMPLE_FORMAT = "Format";
+ private static final String SAMPLE_VERSION = "1.0.0";
+ private static final String SAMPLE_ROUTE = "SampleRoute";
+ private static final String TYPE = "type";
+ private static final String TARGET = "target";
+
+
+ @Test
+ public void dmaapNodeShouldHaveExpectedNodeType() {
+
+ ComponentSpec mockedComponentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createDmaapNode(mockedComponentSpec, new TreeMap<>(), "");
+
+ assertEquals(CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP, dmaapNode.getType());
+ }
+
+ @Test
+ public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForMessageRouterPublishes() {
+ ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ Streams streams = new Streams();
+ streams.setSubscribes(new Subscribes[0]);
+ streams.setPublishes(createSamplePublishes(MESSAGE_ROUTER_TYPE));
+
+ when(componentSpec.getStreams()).thenReturn(streams);
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), "");
+
+ Map<String, String> relationship = dmaapNode.getRelationships().get(0);
+
+ assertNotNull(relationship.get(TYPE));
+ assertNotNull(relationship.get(TARGET));
+ }
+
+ @Test
+ public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForDataRouterPublishes() {
+ ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ Streams streams = new Streams();
+ streams.setSubscribes(new Subscribes[0]);
+ streams.setPublishes(createSamplePublishes(DATA_ROUTER_TYPE));
+
+ when(componentSpec.getStreams()).thenReturn(streams);
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), "");
+
+ Map<String, String> relationship = dmaapNode.getRelationships().get(0);
+
+ assertNotNull(relationship.get(TYPE));
+ assertNotNull(relationship.get(TARGET));
+ }
+
+ @Test
+ public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForMessageRouterSubscribes() {
+ ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ Streams streams = new Streams();
+ streams.setSubscribes(createSampleSubscribes(MESSAGE_ROUTER_TYPE));
+ streams.setPublishes(new Publishes[0]);
+
+ when(componentSpec.getStreams()).thenReturn(streams);
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), "");
+
+ Map<String, String> relationship = dmaapNode.getRelationships().get(0);
+
+ assertEquals(SUBSCRIBE_TO_EVENTS, relationship.get(TYPE));
+ assertNotNull(relationship.get(TARGET));
+ }
+
+ @Test
+ public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForDataRouterSubscribes() {
+ ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ Streams streams = new Streams();
+ streams.setSubscribes(createSampleSubscribes(DATA_ROUTER_TYPE));
+ streams.setPublishes(new Publishes[0]);
+
+ when(componentSpec.getStreams()).thenReturn(streams);
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), "");
+
+ Map<String, String> relationship = dmaapNode.getRelationships().get(0);
+
+ assertEquals(SUBSCRIBE_TO_FILES, relationship.get(TYPE));
+ assertNotNull(relationship.get(TARGET));
+ }
+
+ @Test
+ public void createFeedNodeShouldSetFeedNodeType() {
+ ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createFeedNode(componentSpec, new TreeMap<>(), "");
+
+ assertEquals(FEED, dmaapNode.getType());
+ }
+
+ @Test
+ public void feedNodePropertiesShouldHaveUseExistingField() {
+ ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createFeedNode(componentSpec, new TreeMap<>() ,"");
+
+ assertTrue(dmaapNode.getProperties().getUseExisting());
+ }
+
+ @Test
+ public void createTopicNodeShouldSetTopicNodeType() {
+
+ ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createTopicNode(componentSpec, new TreeMap<>(), "");
+
+ assertEquals(TOPIC, dmaapNode.getType());
+ }
+
+ @Test
+ public void topicNodePropertiesShouldNotHaveUseExistingField() {
+ ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships();
+
+ DmaapNode dmaapNode = new DmaapNode();
+ dmaapNode.createTopicNode(componentSpec, new TreeMap<>() ,"");
+
+ assertNull(dmaapNode.getProperties().getUseExisting());
+ }
+
+ private Publishes[] createSamplePublishes(String type) {
+ Publishes publishes = new Publishes();
+
+ publishes.setType(type);
+ publishes.setConfig_key(CONFIG_KEY);
+ publishes.setFormat(SAMPLE_FORMAT);
+ publishes.setVersion(SAMPLE_VERSION);
+ publishes.setRoute(SAMPLE_ROUTE);
+
+ return new Publishes[]{publishes};
+ }
+
+ private Subscribes[] createSampleSubscribes(String type) {
+ Subscribes subscribes = new Subscribes();
+
+ subscribes.setType(type);
+ subscribes.setConfig_key(CONFIG_KEY);
+ subscribes.setFormat(SAMPLE_FORMAT);
+ subscribes.setVersion(SAMPLE_VERSION);
+ subscribes.setRoute(SAMPLE_ROUTE);
+
+ return new Subscribes[]{subscribes};
+ }
+
+ private ComponentSpec getSpiedComponentSpecWithoutRelationships() {
+ ComponentSpec baseComponentSpec = new ComponentSpec();
+ baseComponentSpec.createComponentSpecFromString(new TestComponentSpec().getComponentSpecAsString());
+ ComponentSpec componentSpec = spy(baseComponentSpec);
+
+ Streams streams = new Streams();
+ streams.setSubscribes(new Subscribes[0]);
+ streams.setPublishes(new Publishes[0]);
+ when(componentSpec.getStreams()).thenReturn(streams);
+
+ Auxilary auxilary = spy(baseComponentSpec.getAuxilary());
+ when(auxilary.getDatabases()).thenReturn(null);
+
+ when(componentSpec.getAuxilary()).thenReturn(auxilary);
+ when(componentSpec.getPolicyInfo()).thenReturn(null);
+
+ return componentSpec;
+ }
+}
diff --git a/mod/bpgenerator/version.properties b/mod/bpgenerator/version.properties
index 9e0d73d..3f9d877 100644
--- a/mod/bpgenerator/version.properties
+++ b/mod/bpgenerator/version.properties
@@ -1,6 +1,6 @@
major=1
-minor=4
-patch=0
+minor=5
+patch=2
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT
diff --git a/mod/runtimeapi/pom.xml b/mod/runtimeapi/pom.xml
index 75b68ce..112a9d7 100644
--- a/mod/runtimeapi/pom.xml
+++ b/mod/runtimeapi/pom.xml
@@ -34,7 +34,7 @@ limitations under the License.
</parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtimeapi</artifactId>
- <version>1.0.2</version>
+ <version>1.1.0</version>
<name>dcaegen2-platform-mod-runtimeapi</name>
<description>MOD Runtime API</description>
<properties>
diff --git a/mod/runtimeapi/runtime-core/pom.xml b/mod/runtimeapi/runtime-core/pom.xml
index 226d4e8..15eda39 100644
--- a/mod/runtimeapi/runtime-core/pom.xml
+++ b/mod/runtimeapi/runtime-core/pom.xml
@@ -25,12 +25,12 @@ limitations under the License.
<parent>
<artifactId>runtimeapi</artifactId>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
- <version>1.0.2</version>
+ <version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>runtime-core</artifactId>
- <version>1.0.1</version>
+ <version>1.1.0</version>
<dependencies>
<dependency>
@@ -46,7 +46,7 @@ limitations under the License.
<dependency>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator</artifactId>
- <version>1.4.0</version>
+ <version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
diff --git a/mod/runtimeapi/runtime-web/pom.xml b/mod/runtimeapi/runtime-web/pom.xml
index c8ce84a..6842cba 100644
--- a/mod/runtimeapi/runtime-web/pom.xml
+++ b/mod/runtimeapi/runtime-web/pom.xml
@@ -24,10 +24,10 @@ limitations under the License.
<parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtimeapi</artifactId>
- <version>1.0.2</version>
+ <version>1.1.0</version>
</parent>
<artifactId>runtime-web</artifactId>
- <version>1.0.6-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>runtime-web</name>
<description>MOD Runtime Web Module</description>
@@ -35,7 +35,7 @@ limitations under the License.
<dependency>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtime-core</artifactId>
- <version>1.0.1</version>
+ <version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/mod2/auth-service/Dockerfile b/mod2/auth-service/Dockerfile
new file mode 100644
index 0000000..aa8707f
--- /dev/null
+++ b/mod2/auth-service/Dockerfile
@@ -0,0 +1,14 @@
+FROM onap/integration-java11:7.1.0
+WORKDIR /usr/app
+VOLUME /tmp
+
+ARG PROJECT_BUILD_DIR_NAME
+ARG FINAL_JAR
+
+EXPOSE 8082
+
+COPY ${PROJECT_BUILD_DIR_NAME}/${FINAL_JAR} .
+
+ENTRYPOINT ["java", \
+ "-Djava.security.egd=file:/dev/./urandom", \
+ "-jar", "auth-service-1.0.0-SNAPSHOT.jar"] \ No newline at end of file
diff --git a/mod2/auth-service/pom.xml b/mod2/auth-service/pom.xml
new file mode 100644
index 0000000..75782f4
--- /dev/null
+++ b/mod2/auth-service/pom.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ /*
+ ~ * ============LICENSE_START=======================================================
+ ~ * org.onap.dcae
+ ~ * ================================================================================
+ ~ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ ~ * ================================================================================
+ ~ * Licensed under the Apache License, Version 2.0 (the "License");
+ ~ * you may not use this file except in compliance with the License.
+ ~ * You may obtain a copy of the License at
+ ~ *
+ ~ * http://www.apache.org/licenses/LICENSE-2.0
+ ~ *
+ ~ * Unless required by applicable law or agreed to in writing, software
+ ~ * distributed under the License is distributed on an "AS IS" BASIS,
+ ~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ * See the License for the specific language governing permissions and
+ ~ * limitations under the License.
+ ~ * ============LICENSE_END=========================================================
+ ~ */
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>2.0.0</version>
+ </parent>
+ <groupId>org.onap.dcaegen2.platform.mod</groupId>
+ <artifactId>auth-service</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>auth-service</name>
+ <description>REST APIs to serve Auth Service</description>
+
+ <properties>
+ <java.version>11</java.version>
+ <maven.compiler.source>${java.version}</maven.compiler.source>
+ <maven.compiler.target>${java.version}</maven.compiler.target>
+ <dockerfile-maven-plugin.version>1.4.10</dockerfile-maven-plugin.version>
+ <docker.image.name>${project.groupId}.${project.artifactId}</docker.image.name>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-mongodb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.8.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.jsonwebtoken</groupId>
+ <artifactId>jjwt</artifactId>
+ <version>0.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-validation</artifactId>
+ </dependency>
+ <!-- CODE GENERATION -->
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>okhttp</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+
+ <!--TEST DEPENDENCIES-->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>mockwebserver</artifactId>
+ <version>4.0.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>RELEASE</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <!-- Import dependency management from Spring Boot -->
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>2.2.5.RELEASE</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>2.2.5.RELEASE</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>${dockerfile-maven-plugin.version}</version>
+ <configuration>
+ <contextDirectory>${project.basedir}</contextDirectory>
+ <repository>${onap.nexus.dockerregistry.daily}/${docker.image.name}</repository>
+ <buildArgs>
+ <PROJECT_BUILD_DIR_NAME>target</PROJECT_BUILD_DIR_NAME>
+ <FINAL_JAR>${project.build.finalName}.jar</FINAL_JAR>
+ </buildArgs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>build-image</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>tag-and-push-image-latest</id>
+ <phase>package</phase>
+ <goals>
+ <goal>tag</goal>
+ <goal>push</goal>
+ </goals>
+ <configuration>
+ <repository>${onap.nexus.dockerregistry.daily}/${docker.image.name}</repository>
+ <tag>latest</tag>
+ <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
+ </configuration>
+ </execution>
+ <execution>
+ <id>tag-and-push-image-with-version</id>
+ <phase>package</phase>
+ <goals>
+ <goal>tag</goal>
+ <goal>push</goal>
+ </goals>
+ <configuration>
+ <repository>${onap.nexus.dockerregistry.daily}/${docker.image.name}</repository>
+ <tag>${project.version}</tag>
+ <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.2</version>
+ </plugin>
+ </plugins>
+ <finalName>mod-auth-service</finalName>
+ </build>
+</project>
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/AuthServiceApplication.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/AuthServiceApplication.java
new file mode 100644
index 0000000..5b147bf
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/AuthServiceApplication.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Auth Service Application
+ */
+@SpringBootApplication
+public class AuthServiceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(AuthServiceApplication.class, args);
+ }
+
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/DataLoader.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/DataLoader.java
new file mode 100644
index 0000000..959b450
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/DataLoader.java
@@ -0,0 +1,97 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod;
+
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.Role;
+import org.onap.dcaegen2.platform.mod.repositories.RoleRepository;
+import org.onap.dcaegen2.platform.mod.repositories.UserRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * To Initialize Roles and create Default Admin User
+ */
+@Component
+public class DataLoader implements ApplicationRunner {
+
+ @Autowired
+ private RoleRepository roleRepository;
+
+ @Autowired
+ private UserRepository userRepository;
+
+ @Autowired
+ PasswordEncoder passwordEncoder;
+
+ @Override
+ public void run(ApplicationArguments args) throws Exception {
+ populateRoles();
+ populateAdminUser();
+ }
+
+ private void populateRoles() {
+ List<Role> roles = createRoles();
+ roles.forEach((role) -> {
+ boolean roleNotPresent = !roleRepository.findByName(role.getName()).isPresent();
+ if(roleNotPresent)
+ roleRepository.save(role);
+ });
+
+ }
+
+ private List<Role> createRoles() {
+ Role admin = new Role("ROLE_ADMIN");
+ Role user = new Role("ROLE_USER");
+ Role developer = new Role("ROLE_DEVELOPER");
+ return Arrays.asList(admin, user, developer);
+ }
+
+ private void populateAdminUser() {
+ boolean adminNotPresent = !userRepository.findByUsername("admin").isPresent();
+ if(adminNotPresent) {
+ ModUser admin = createAdmin();
+ userRepository.save(admin);
+ }
+ }
+
+ private ModUser createAdmin() {
+ ModUser admin = new ModUser();
+ admin.setUsername("admin");
+ admin.setFullName("Admin");
+ admin.setPassword(passwordEncoder.encode("admin@mod"));
+ HashSet<Role> roleAdmin = new HashSet<>();
+ roleAdmin.add(roleRepository.findByName("ROLE_ADMIN").get());
+ admin.setRoles(roleAdmin);
+ return admin;
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/AuthController.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/AuthController.java
new file mode 100644
index 0000000..6612138
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/AuthController.java
@@ -0,0 +1,171 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.controllers;
+
+import org.onap.dcaegen2.platform.mod.exceptions.RoleNotExistsException;
+import org.onap.dcaegen2.platform.mod.exceptions.UserAlreadyExistsException;
+import org.onap.dcaegen2.platform.mod.models.LoginRequest;
+import org.onap.dcaegen2.platform.mod.models.JwtResponse;
+import org.onap.dcaegen2.platform.mod.models.SignupRequest;
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.GenericResponse;
+import org.onap.dcaegen2.platform.mod.models.Role;
+import org.onap.dcaegen2.platform.mod.repositories.RoleRepository;
+import org.onap.dcaegen2.platform.mod.repositories.UserRepository;
+import org.onap.dcaegen2.platform.mod.security.jwt.JwtUtils;
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+
+import javax.validation.Valid;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Authentication Operations
+ */
+@RestController
+@RequestMapping("/api/auth")
+@CrossOrigin(origins = "*")
+public class AuthController {
+
+ @Autowired
+ AuthenticationManager authenticationManager;
+
+ @Autowired
+ UserRepository userRepository;
+
+ @Autowired
+ RoleRepository roleRepository;
+
+ @Autowired
+ PasswordEncoder passwordEncoder;
+
+ @Autowired
+ JwtUtils jwtUtils;
+
+ @PreAuthorize("isAuthenticated()")
+ @PostMapping("/validate-token")
+ public ResponseEntity<?> validateToken() {
+ return new ResponseEntity("true", HttpStatus.OK);
+ }
+
+ @PostMapping("/signin")
+ public ResponseEntity<?> authenticateUser(@RequestBody @Valid LoginRequest loginRequest) {
+ Authentication authentication = authenticateLoginRequest(loginRequest);
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+ String jwt = jwtUtils.generateJwtToken(authentication);
+ return setUserContext(authentication, jwt);
+ }
+
+ private Authentication authenticateLoginRequest(@RequestBody @Valid LoginRequest loginRequest) {
+ return authenticationManager.authenticate(
+ new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword())
+ );
+ }
+
+ private ResponseEntity<?> setUserContext(Authentication authentication, String jwt) {
+ UserDetailsImpl userDetails = (UserDetailsImpl) authentication.getPrincipal();
+ List<String> roles = setRolesFromUserDetails(userDetails);
+ return buildUserContext(jwt, userDetails, roles);
+ }
+
+ private List<String> setRolesFromUserDetails(UserDetailsImpl userDetails) {
+ return userDetails.getAuthorities().stream()
+ .map(item -> ((GrantedAuthority) item).getAuthority())
+ .collect(Collectors.toList());
+ }
+
+ private ResponseEntity<JwtResponse> buildUserContext(String jwt, UserDetailsImpl userDetails, List<String> roles) {
+ return ResponseEntity.ok(JwtResponse.builder()
+ .id(userDetails.getId())
+ .roles(roles)
+ .username(userDetails.getUsername())
+ .token(jwt)
+ .fullName(userDetails.getFullName())
+ .build()
+ );
+ }
+
+ @PreAuthorize("hasRole('ADMIN')")
+ @PostMapping("/signup")
+ public ResponseEntity<?> registerUser(@RequestBody @Valid SignupRequest request) {
+ checkIfUserExists(request);
+ ModUser user = createNewUser(request);
+ userRepository.save(user);
+ return ResponseEntity.ok(new GenericResponse("User registered successfully!"));
+ }
+
+ private void checkIfUserExists(@RequestBody @Valid SignupRequest signUpRequest) {
+ if (userRepository.existsByUsername(signUpRequest.getUsername()))
+ throw new UserAlreadyExistsException("Username already exists!");
+ }
+
+ private ModUser createNewUser(@RequestBody @Valid SignupRequest request) {
+ ModUser user = new ModUser();
+ user.setUsername(request.getUsername());
+ user.setFullName(request.getFullName());
+ user.setPassword(getEncodedPassword(request));
+ Set<Role> roles = createRoles(request.getRoles());
+ user.setRoles(roles);
+ return user;
+ }
+
+ private String getEncodedPassword(@RequestBody @Valid SignupRequest request) {
+ return passwordEncoder.encode(request.getPassword());
+ }
+
+ public Set<Role> createRoles(Set<String> roleStrings) {
+ Set<Role> roles = new HashSet<>();
+ for (String roleStr : roleStrings) {
+ roles.add(getRole(roleStr));
+ }
+ return roles;
+ }
+
+ private Role getRole(String roleStr) {
+ return roleRepository.findByName(roleStr).orElseThrow(
+ () -> new RoleNotExistsException(String.format("Role %s does not exist", roleStr)));
+ }
+}
+
+
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/RoleController.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/RoleController.java
new file mode 100644
index 0000000..e129cda
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/RoleController.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.controllers;
+
+import org.onap.dcaegen2.platform.mod.repositories.RoleRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Role Operations
+ */
+@RestController
+@RequestMapping("/api/roles")
+@CrossOrigin(origins = "*")
+public class RoleController {
+
+ @Autowired
+ RoleRepository roleRepository;
+
+ @GetMapping
+ @ResponseStatus(HttpStatus.OK)
+ public List<String> getRoles(){
+ return roleRepository.findAll()
+ .stream()
+ .map(role -> role.getName())
+ .collect(Collectors.toList());
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/UserController.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/UserController.java
new file mode 100644
index 0000000..90e7b62
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/controllers/UserController.java
@@ -0,0 +1,96 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.controllers;
+
+import org.onap.dcaegen2.platform.mod.exceptions.UserNotFoundException;
+import org.onap.dcaegen2.platform.mod.models.GenericResponse;
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.UpdateUserRequest;
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsServiceImpl;
+import org.onap.dcaegen2.platform.mod.services.MODUserDetailService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+
+/**
+ * @author
+ * @date 09/08/2020
+ * User Operations
+ */
+@RestController
+@RequestMapping("/api/users")
+@CrossOrigin(origins = "*")
+public class UserController {
+
+ @Autowired
+ private MODUserDetailService modUserDetailService;
+
+ @Autowired
+ private UserDetailsServiceImpl userDetailsService;
+
+ @PreAuthorize("hasRole('ADMIN')")
+ @GetMapping("/getAll")
+ @ResponseStatus(HttpStatus.OK)
+ public List<ModUser> getAllUsers() {
+ return modUserDetailService.findAll();
+ }
+
+ @PreAuthorize("hasRole('ADMIN') or hasRole('USER')")
+ @GetMapping("/{username}")
+ public UserDetails getUser(@PathVariable String username) {
+ return userDetailsService.loadUserByUsername(username);
+ }
+
+ @PreAuthorize("hasRole('ADMIN')")
+ @PatchMapping("/admin/{username}")
+ public ModUser adminUpdateUserProfile(@PathVariable String username, @RequestBody @Valid UpdateUserRequest
+ userRequest, @RequestHeader (name="Authorization") String token) {
+ return userDetailsService.adminUpdateUser(username, userRequest, token);
+ }
+
+ @PreAuthorize("hasRole('USER') or hasRole('DEVELOPER')")
+ @PatchMapping("/user/{username}")
+ public ModUser userUpdateOwnProfile(@PathVariable String username, @RequestBody @Valid UpdateUserRequest
+ userRequest, @RequestHeader (name="Authorization") String token) {
+ return userDetailsService.userUpdateOwnProfile(username, userRequest, token);
+ }
+
+ @PreAuthorize("hasRole('ADMIN')")
+ @DeleteMapping("/{username}")
+ public ResponseEntity<?> deleteUser(@PathVariable String username) {
+ modUserDetailService.deleteUserByUsername(username);
+ return ResponseEntity.ok(new GenericResponse("User " + username + " was removed"));
+ }
+
+ @ExceptionHandler
+ @ResponseStatus(HttpStatus.NOT_FOUND)
+ public void userNotFoundHandler(UserNotFoundException ex) {
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/AppExceptionHandler.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/AppExceptionHandler.java
new file mode 100644
index 0000000..e029e69
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/AppExceptionHandler.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.exceptions;
+
+import org.onap.dcaegen2.platform.mod.models.GenericResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Exception handler for the Auth Service Application
+ */
+@ControllerAdvice
+@Slf4j
+public class AppExceptionHandler {
+
+ @ExceptionHandler
+ public ResponseEntity<GenericResponse> resolveRuntimeException(UserAlreadyExistsException ex){
+ log.error(ex.getMessage());
+ return new ResponseEntity<>(new GenericResponse(ex.getMessage()), HttpStatus.CONFLICT);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<GenericResponse> resolveRoleNotFoundException(RoleNotExistsException ex){
+ log.error(ex.getMessage());
+ return new ResponseEntity<>(new GenericResponse(ex.getMessage()), HttpStatus.BAD_REQUEST);
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/IllegalUserOperationException.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/IllegalUserOperationException.java
new file mode 100644
index 0000000..4a5837a
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/IllegalUserOperationException.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.exceptions;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Exception for Illegal Operation
+ */
+public class IllegalUserOperationException extends RuntimeException {
+ public IllegalUserOperationException(String s) {
+ super(s);
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/RoleNotExistsException.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/RoleNotExistsException.java
new file mode 100644
index 0000000..dfa6efb
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/RoleNotExistsException.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.exceptions;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Exception for Role not exist
+ */
+public class RoleNotExistsException extends RuntimeException {
+ public RoleNotExistsException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/UserAlreadyExistsException.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/UserAlreadyExistsException.java
new file mode 100644
index 0000000..475dc44
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/UserAlreadyExistsException.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.exceptions;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Exception for User already exists
+ */
+public class UserAlreadyExistsException extends RuntimeException {
+ public UserAlreadyExistsException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/UserNotFoundException.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/UserNotFoundException.java
new file mode 100644
index 0000000..95c6a70
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/exceptions/UserNotFoundException.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.exceptions;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Exception for User Not Found
+ */
+public class UserNotFoundException extends RuntimeException {
+ public UserNotFoundException(String s) {
+ super(s);
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/GenericResponse.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/GenericResponse.java
new file mode 100644
index 0000000..c4625a4
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/GenericResponse.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.models;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Generic Response for the Auth Service Request
+ */
+@Getter
+@Setter
+@AllArgsConstructor
+public class GenericResponse {
+
+ private String message;
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/JwtResponse.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/JwtResponse.java
new file mode 100644
index 0000000..8855245
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/JwtResponse.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.models;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * JWT Response for the Auth Service Request
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class JwtResponse {
+
+ private String token;
+ private String type = "Bearer";
+ private String id;
+ private String username;
+ private String fullName;
+ private List<String> roles;
+
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/LoginRequest.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/LoginRequest.java
new file mode 100644
index 0000000..af0f710
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/LoginRequest.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.models;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Login request
+ */
+@Data
+public class LoginRequest {
+
+ @NotBlank
+ private String username;
+
+ @NotBlank
+ private String password;
+
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/ModUser.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/ModUser.java
new file mode 100644
index 0000000..4da5c98
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/ModUser.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.models;
+
+import lombok.Data;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Assigning Roles to User
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Getter
+@Setter
+@Document(collection = "users")
+public class ModUser implements Serializable {
+
+ @Id
+ public String _id;
+
+ @NotBlank
+ @Size(max = 10)
+ private String username;
+
+ @NotBlank
+ private String password;
+
+ @NotBlank
+ private String fullName;
+
+ @DBRef
+ private Set<Role> roles = new HashSet<>();
+
+ public ModUser(@NotBlank @Size(max = 10) String username, @NotBlank String password, @NotBlank String fullName) {
+ this.username = username;
+ this.password = password;
+ this.fullName=fullName;
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/Role.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/Role.java
new file mode 100644
index 0000000..8cce344
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/Role.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.models;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Roles
+ */
+@Document(collection = "roles")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Role {
+
+ @Id
+ private String id;
+
+ private String name;
+
+ public Role(String name) {
+ this.name = name;
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/SignupRequest.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/SignupRequest.java
new file mode 100644
index 0000000..f705d76
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/SignupRequest.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.models;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.Set;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * To validate User enter Details
+ */
+@Data
+public class SignupRequest {
+
+ @NotBlank(message = "username must not be blank")
+ @Size(min = 5, max = 10, message = "username must be between 5 and 10 characters.")
+ private String username;
+
+ @NotNull(message = "username must not be null")
+ @Size(min = 1, message = "At least 1 role must be passed")
+ private Set<String> roles;
+
+ @NotBlank(message = "password must not be blank")
+ private String password;
+
+ @NotBlank(message = "Full name must not be blank")
+ private String fullName;
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/UpdateUserRequest.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/UpdateUserRequest.java
new file mode 100644
index 0000000..6e3abf6
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/models/UpdateUserRequest.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.models;
+
+import lombok.Data;
+
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import java.util.Set;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * To update User Details of Name and Password
+ */
+@Data
+public class UpdateUserRequest {
+
+ @Size(min = 1, message = "At least 1 role must be passed")
+ private Set<String> roles;
+
+ @Pattern(regexp = "^(?!\\s*$).+", message = "password must not be blank")
+ private String password;
+
+ @Pattern(regexp = "^(?!\\s*$).+", message = "fullName must not be blank")
+ private String fullName;
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/repositories/RoleRepository.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/repositories/RoleRepository.java
new file mode 100644
index 0000000..6efad17
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/repositories/RoleRepository.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.repositories;
+
+import org.onap.dcaegen2.platform.mod.models.Role;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+import java.util.Optional;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Interface to find user exists or not
+ */
+public interface RoleRepository extends MongoRepository<Role, String> {
+ Optional<Role> findByName(String name);
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/repositories/UserRepository.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/repositories/UserRepository.java
new file mode 100644
index 0000000..442ebf1
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/repositories/UserRepository.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.repositories;
+
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+import java.util.Optional;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Interface to Find/Valid/Delete user
+ */
+public interface UserRepository extends MongoRepository<ModUser, String>{
+ Optional<ModUser> findByUsername(String username);
+ Boolean existsByUsername(String username);
+ void deleteByUsername(String username);
+}
+
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/WebSecurityConfigurer.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/WebSecurityConfigurer.java
new file mode 100644
index 0000000..cfccce4
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/WebSecurityConfigurer.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.security;
+
+import org.onap.dcaegen2.platform.mod.security.jwt.AuthEntryPointJwt;
+import org.onap.dcaegen2.platform.mod.security.jwt.AuthTokenFilter;
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Allows customization to the Spring WebSecurity
+ */
+
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(prePostEnabled = true)
+public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
+
+ @Autowired
+ UserDetailsServiceImpl userDetailsService;
+
+ @Autowired
+ private AuthEntryPointJwt unauthorizedHandler;
+
+ @Bean
+ public AuthTokenFilter authenticationJwtTokenFilter(){
+ return new AuthTokenFilter();
+ }
+
+ @Override
+ protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
+ authenticationManagerBuilder.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
+ }
+
+ @Bean
+ @Override
+ public AuthenticationManager authenticationManagerBean() throws Exception{
+ return super.authenticationManagerBean();
+ }
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.cors().and().csrf().disable()
+ .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
+ .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
+ .authorizeRequests().antMatchers("/api/auth/**").permitAll()
+ .antMatchers("/api/users/**").permitAll()
+ .anyRequest().authenticated();
+
+ http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/AuthEntryPointJwt.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/AuthEntryPointJwt.java
new file mode 100644
index 0000000..310d487
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/AuthEntryPointJwt.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.security.jwt;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * JWT Authentication Entry Point
+ */
+
+@Slf4j
+@Component
+public class AuthEntryPointJwt implements AuthenticationEntryPoint {
+
+ @Override
+ public void commence(HttpServletRequest request, HttpServletResponse response,
+ AuthenticationException authException) throws IOException, ServletException {
+ log.error("Unauthorized error: {}", authException.getMessage());
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Error: Unauthorized");
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/AuthTokenFilter.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/AuthTokenFilter.java
new file mode 100644
index 0000000..012c333
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/AuthTokenFilter.java
@@ -0,0 +1,81 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.security.jwt;
+
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
+import org.springframework.util.StringUtils;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * Authentication Token Filter
+ */
+@Slf4j
+public class AuthTokenFilter extends OncePerRequestFilter {
+
+ @Autowired
+ private JwtUtils jwtUtils;
+
+ @Autowired
+ private UserDetailsServiceImpl userDetailsService;
+
+ @Override
+ protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
+ try{
+ String jwt = parseJwt(httpServletRequest);
+ if (jwt != null && jwtUtils.validateJwtToken(jwt)){
+ String username = jwtUtils.getUserNameFromJwtToken(jwt);
+ UserDetails userDetails = userDetailsService.loadUserByUsername(username);
+ UsernamePasswordAuthenticationToken authenticationToken =
+ new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
+ authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
+ SecurityContextHolder.getContext().setAuthentication(authenticationToken);
+ }
+ }catch (Exception e){
+ logger.error("Cannot set user authentication: {}", e);
+ }
+ filterChain.doFilter(httpServletRequest, httpServletResponse);
+ }
+
+ private String parseJwt(HttpServletRequest httpServletRequest) {
+ String headerAuth = httpServletRequest.getHeader("Authorization");
+
+ if(StringUtils.hasText(headerAuth) && headerAuth.startsWith("Bearer ")){
+ return headerAuth.substring(7, headerAuth.length());
+ }
+ return null;
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/JwtUtils.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/JwtUtils.java
new file mode 100644
index 0000000..3b6d311
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/jwt/JwtUtils.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.security.jwt;
+
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsImpl;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+import io.jsonwebtoken.SignatureException;
+import io.jsonwebtoken.MalformedJwtException;
+import io.jsonwebtoken.ExpiredJwtException;
+import io.jsonwebtoken.UnsupportedJwtException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.core.Authentication;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * JWT Utils
+ */
+@Slf4j
+@Component
+public class JwtUtils {
+
+ @Value("${mod-portal.jwt.secret}")
+ private String jwtSecret;
+
+ @Value("${mod-portal.jwt.jwtExpirationMs}")
+ private int jwtExpirationMs;
+
+ public String generateJwtToken(Authentication authentication) {
+
+ UserDetailsImpl userPrincipal = (UserDetailsImpl) authentication.getPrincipal();
+
+ return Jwts.builder()
+ .setSubject((userPrincipal.getUsername()))
+ .claim("roles", userPrincipal.getAuthoritiesAsList())
+ .claim("fullName", userPrincipal.getFullName())
+ .setIssuedAt(new Date())
+ .setExpiration(new Date((new Date()).getTime() + jwtExpirationMs))
+ .signWith(SignatureAlgorithm.HS512, jwtSecret)
+ .compact();
+ }
+
+ public String getUserNameFromJwtToken(String token) {
+ return Jwts.parser().setSigningKey(jwtSecret).parseClaimsJws(token).getBody().getSubject();
+ }
+
+ public boolean validateJwtToken(String authToken) {
+ try {
+ Jwts.parser().setSigningKey(jwtSecret).parseClaimsJws(authToken);
+ return true;
+ } catch (SignatureException e) {
+ log.error("Invalid JWT signature: {}", e.getMessage());
+ } catch (MalformedJwtException e) {
+ log.error("Invalid JWT token: {}", e.getMessage());
+ } catch (ExpiredJwtException e) {
+ log.error("JWT token is expired: {}", e.getMessage());
+ } catch (UnsupportedJwtException e) {
+ log.error("JWT token is unsupported: {}", e.getMessage());
+ } catch (IllegalArgumentException e) {
+ log.error("JWT claims string is empty: {}", e.getMessage());
+ }
+
+ return false;
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/services/UserDetailsImpl.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/services/UserDetailsImpl.java
new file mode 100644
index 0000000..82cb577
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/services/UserDetailsImpl.java
@@ -0,0 +1,127 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.security.services;
+
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.EqualsAndHashCode;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * User Details Implementation
+ */
+@EqualsAndHashCode
+public class UserDetailsImpl implements UserDetails{
+
+ private static final long serialVersionUID = 1L;
+
+ private String id;
+
+ private String username;
+
+ private String fullName;
+
+ @JsonIgnore
+ private String password;
+
+ private Collection<? extends GrantedAuthority> authorities;
+
+ public UserDetailsImpl(String id, String username, String fullName, String password, Collection<?
+ extends GrantedAuthority> authorities) {
+ this.id = id;
+ this.username = username;
+ this.fullName = fullName;
+ this.password = password;
+ this.authorities = authorities;
+ }
+
+ public static UserDetails build(ModUser user) {
+ List<GrantedAuthority> authorities = user.getRoles().stream()
+ .map(role -> new SimpleGrantedAuthority(role.getName()))
+ .collect(Collectors.toList());
+
+ return new UserDetailsImpl(
+ user.get_id(),
+ user.getUsername(),
+ user.getFullName(),
+ user.getPassword(),
+ authorities
+ );
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public Collection<? extends GrantedAuthority> getAuthorities() {
+ return authorities;
+ }
+
+ public List<String> getAuthoritiesAsList(){
+ return authorities.stream().map(GrantedAuthority::getAuthority)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public String getPassword() {
+ return password;
+ }
+
+ @Override
+ public String getUsername() {
+ return username;
+ }
+
+ public String getFullName() {
+ return fullName;
+ }
+
+ @Override
+ public boolean isAccountNonExpired() {
+ return true;
+ }
+
+ @Override
+ public boolean isAccountNonLocked() {
+ return true;
+ }
+
+ @Override
+ public boolean isCredentialsNonExpired() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/services/UserDetailsServiceImpl.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/services/UserDetailsServiceImpl.java
new file mode 100644
index 0000000..5c13e11
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/security/services/UserDetailsServiceImpl.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.security.services;
+
+import org.onap.dcaegen2.platform.mod.controllers.AuthController;
+import org.onap.dcaegen2.platform.mod.exceptions.UserNotFoundException;
+import org.onap.dcaegen2.platform.mod.exceptions.IllegalUserOperationException;
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.Role;
+import org.onap.dcaegen2.platform.mod.models.UpdateUserRequest;
+import org.onap.dcaegen2.platform.mod.repositories.UserRepository;
+import org.onap.dcaegen2.platform.mod.security.jwt.JwtUtils;
+import lombok.Setter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Service;
+
+import java.util.Set;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * User Details Service
+ */
+@Service
+public class UserDetailsServiceImpl implements UserDetailsService {
+
+ @Autowired
+ @Setter
+ UserRepository userRepository;
+
+ @Autowired
+ PasswordEncoder passwordEncoder;
+
+ @Autowired
+ AuthController authController;
+
+ @Autowired
+ private JwtUtils jwtUtils;
+
+ @Override
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+ ModUser user = userRepository.findByUsername(username)
+ .orElseThrow(() -> new UsernameNotFoundException("User not found with username: " + username));
+
+ return UserDetailsImpl.build(user);
+ }
+
+ public ModUser adminUpdateUser(String username, UpdateUserRequest userRequest, String token) {
+ return updateUserProfile(username, userRequest);
+ }
+
+ public ModUser userUpdateOwnProfile(String username, UpdateUserRequest userRequest, String token) {
+ String usernameFromToken = jwtUtils.getUserNameFromJwtToken(token.substring(7));
+ if (usernameFromToken.equals(username)) {
+ return updateUserProfile(username, userRequest);
+ } else {
+ throw new IllegalUserOperationException("Permission denied to update user profile of " + username);
+ }
+ }
+
+ private ModUser updateUserProfile(String username, UpdateUserRequest userRequest) {
+ ModUser modUser = userRepository.findByUsername(username).orElseThrow(() -> new UserNotFoundException(String.format("User %s not found", username)));
+ modUser = updateUserFields(modUser, userRequest);
+ return userRepository.save(modUser);
+ }
+
+ private ModUser updateUserFields(ModUser modUser, UpdateUserRequest userRequest) {
+ if (userRequest.getFullName() != null) modUser.setFullName(userRequest.getFullName());
+ if (userRequest.getPassword() != null) modUser.setPassword(passwordEncoder.encode(userRequest.getPassword()));
+ if (userRequest.getRoles() != null) {
+ Set<Role> roles = authController.createRoles(userRequest.getRoles());
+ modUser.setRoles(roles);
+ }
+ return modUser;
+ }
+}
diff --git a/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/services/MODUserDetailService.java b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/services/MODUserDetailService.java
new file mode 100644
index 0000000..a6a6de5
--- /dev/null
+++ b/mod2/auth-service/src/main/java/org/onap/dcaegen2/platform/mod/services/MODUserDetailService.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.services;
+
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.repositories.UserRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author
+ * @date 09/08/2020
+ * This Service provides APIs to manage User Entity
+ */
+
+@Service
+public class MODUserDetailService {
+
+ @Autowired
+ private UserRepository userRepository;
+
+ public MODUserDetailService(UserRepository userRepository) {
+ this.userRepository = userRepository;
+ }
+
+ public List<ModUser> findAll() {
+ return userRepository.findAll();
+ }
+
+ public void deleteUserByUsername(String username) {
+ userRepository.deleteByUsername(username);
+ }
+
+}
diff --git a/mod2/auth-service/src/main/resources/application.properties b/mod2/auth-service/src/main/resources/application.properties
new file mode 100644
index 0000000..f3f5d37
--- /dev/null
+++ b/mod2/auth-service/src/main/resources/application.properties
@@ -0,0 +1,32 @@
+#
+# /*
+# * ============LICENSE_START=======================================================
+# * org.onap.dcae
+# * ================================================================================
+# * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+# * ================================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# * ============LICENSE_END=========================================================
+# */
+#
+
+server.port=8082
+
+#spring.data.mongodb.host=mongo_db
+spring.data.mongodb.host=localhost
+#spring.data.mongodb.host=zlecdyh2bdcc1s2dokr05.ec53e7.dyh2b.tci.att.com
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=dcae_mod
+
+mod-portal.jwt.secret=mod2020!
+mod-portal.jwt.jwtExpirationMs=43200000 \ No newline at end of file
diff --git a/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/AuthObjectMother.java b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/AuthObjectMother.java
new file mode 100644
index 0000000..3a22af3
--- /dev/null
+++ b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/AuthObjectMother.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.objectmothers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.dcaegen2.platform.mod.models.LoginRequest;
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.Role;
+import org.onap.dcaegen2.platform.mod.models.SignupRequest;
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsImpl;
+import org.onap.dcaegen2.platform.mod.util.TestUtil;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author
+ * @date 09/22/2020
+ * Mock for AuthenticationController Test Case
+ */
+
+public class AuthObjectMother {
+ public static final String LOGIN_REQUEST = "src/test/resources/http/requests/AuthLoginRequest.json";
+ public static final String SIGNUP_REQUEST = "src/test/resources/http/requests/AuthSignupRequest.json";
+
+ public static String asJsonString(final Object object) {
+ try {
+ return new ObjectMapper().writeValueAsString(object);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static LoginRequest getLoginRequest() {
+ return TestUtil.deserializeJsonFileToModel(LOGIN_REQUEST, LoginRequest.class);
+ }
+
+ public static SignupRequest getSignupRequest() {
+ return TestUtil.deserializeJsonFileToModel(SIGNUP_REQUEST, SignupRequest.class);
+ }
+
+ public static UserDetailsImpl getUserDetailsImpl() {
+ SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority("ROLE_ADMIN");
+ List authorities = new ArrayList();
+ authorities.add(simpleGrantedAuthority);
+ return new UserDetailsImpl("admin123", "admin123", "admin123", "admin123", authorities);
+ }
+
+ public static ModUser getModUser() {
+ ModUser user = new ModUser();
+ user.setUsername("test");
+ user.setFullName("test");
+ user.setPassword("password");
+ Set<Role> roles = new HashSet<>();
+ Role role = new Role();
+ role.setName("test");
+ role.setId("123");
+ roles.add(role);
+ user.setRoles(roles);
+ return user;
+ }
+}
diff --git a/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/RoleObjectMother.java b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/RoleObjectMother.java
new file mode 100644
index 0000000..68002ac
--- /dev/null
+++ b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/RoleObjectMother.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.objectmothers;
+
+
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.Role;
+import org.onap.dcaegen2.platform.mod.repositories.RoleRepository;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author
+ * @date 09/22/2020
+ * Mock for RoleController Test Case
+ */
+public class RoleObjectMother {
+
+ public static List<Role> getRoles() {
+ List<Role> roles = new ArrayList();
+ Role role1 = new Role();
+ role1.setId("123");
+ role1.setName("Admin123");
+
+ Role role2 = new Role();
+ role2.setId("1234");
+ role2.setName("Admin1234");
+
+ roles.add(role1);
+ roles.add(role2);
+
+ return roles;
+ }
+
+}
diff --git a/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/UserObjectMother.java b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/UserObjectMother.java
new file mode 100644
index 0000000..301b81f
--- /dev/null
+++ b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/UserObjectMother.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.objectmothers;
+
+
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.Role;
+import org.onap.dcaegen2.platform.mod.models.UpdateUserRequest;
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsImpl;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author
+ * @date 09/22/2020
+ * Mock for UserController Test Case
+ */
+public class UserObjectMother {
+
+ public static final String userId = "admin";
+
+ public static List<ModUser> getUsers() {
+ List<ModUser> users = new ArrayList();
+ ModUser modUser1 = new ModUser();
+ modUser1.set_id("123");
+ modUser1.setFullName("Admin123");
+ modUser1.setPassword("Admin123");
+ Set<Role> roles = new HashSet<>();
+ Role role = new Role();
+ role.setName("test");
+ role.setId("123");
+ roles.add(role);
+ modUser1.setRoles(roles);
+
+ ModUser modUser2 = new ModUser();
+ modUser2.set_id("1234");
+ modUser2.setFullName("Admin1234");
+ modUser2.setPassword("Admin1234");
+ Set<Role> roles1 = new HashSet<>();
+ Role role1 = new Role();
+ role.setName("test1");
+ role.setId("1234");
+ roles.add(role1);
+ modUser2.setRoles(roles1);
+
+ users.add(modUser1);
+ users.add(modUser2);
+
+ return users;
+ }
+
+ public static ModUser getModUser() {
+ ModUser user = new ModUser();
+ user.setUsername("test");
+ user.setFullName("test");
+ user.setPassword("password");
+ Set<Role> roles = new HashSet<>();
+ Role role = new Role();
+ role.setName("test");
+ role.setId("123");
+ roles.add(role);
+ user.setRoles(roles);
+ return user;
+ }
+
+ public static UpdateUserRequest getUpdateUserRequest(){
+ UpdateUserRequest user = new UpdateUserRequest();
+ user.setFullName("test");
+ user.setPassword("password");
+ Set<String> roles = new HashSet<>();
+ roles.add("ROLE_PST");
+ user.setRoles(roles);
+ return user;
+ }
+
+}
diff --git a/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/util/TestUtil.java b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/util/TestUtil.java
new file mode 100644
index 0000000..111653f
--- /dev/null
+++ b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/util/TestUtil.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.util;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author
+ * @date 09/22/2020
+ * TestUtils for test cases
+ */
+public class TestUtil {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ private TestUtil() {}
+
+ public static Map<String, Object> readJsonFileAsObjectMap(String filePath) {
+ try {
+ return MAPPER.readValue(new File(filePath), new TypeReference<Map<String, Object>>() {});
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException();
+ }
+ }
+
+ public static <T> T deserializeJsonFileToModel(String filePath, Class<T> modelClass) {
+ try {
+ return MAPPER.readValue(new File(filePath), modelClass);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException();
+ }
+ }
+}
diff --git a/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/AuthControllerTest.java b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/AuthControllerTest.java
new file mode 100644
index 0000000..2aad289
--- /dev/null
+++ b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/AuthControllerTest.java
@@ -0,0 +1,149 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.web;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.onap.dcaegen2.platform.mod.controllers.AuthController;
+import org.onap.dcaegen2.platform.mod.models.*;
+import org.onap.dcaegen2.platform.mod.repositories.RoleRepository;
+import org.onap.dcaegen2.platform.mod.repositories.UserRepository;
+import org.onap.dcaegen2.platform.mod.security.jwt.AuthEntryPointJwt;
+import org.onap.dcaegen2.platform.mod.security.jwt.JwtUtils;
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.*;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.test.context.support.WithMockUser;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.web.client.RestTemplate;
+import org.testng.annotations.BeforeTest;
+
+import java.io.IOException;
+import java.util.Optional;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.mockito.Mockito.*;
+import static org.onap.dcaegen2.platform.mod.objectmothers.AuthObjectMother.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+/**
+ * @author
+ * @date 09/22/2020
+ * Mock Test cases for AuthenticationController
+ */
+@WebMvcTest(AuthController.class)
+public class AuthControllerTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @MockBean
+ JwtUtils jwtUtils;
+
+ @MockBean
+ AuthenticationManager authenticationManager;
+
+ @MockBean
+ UserRepository userRepository;
+
+ @MockBean
+ RoleRepository roleRepository;
+
+ @MockBean
+ PasswordEncoder passwordEncoder;
+
+ @MockBean
+ UserDetailsServiceImpl userDetailsService;
+
+ @MockBean
+ AuthEntryPointJwt authEntryPointJwt;
+
+ @Mock
+ Authentication authentication;
+
+ @BeforeEach
+ void setUp() {
+ }
+
+
+ @Test
+ void test_signin_returnsSuccessResponse() throws Exception {
+
+ LoginRequest loginRequest = getLoginRequest();
+
+ when(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword()))).thenReturn(authentication);
+ when(authentication.getPrincipal()).thenReturn(getUserDetailsImpl());
+ when(jwtUtils.generateJwtToken(any())).thenReturn("Demo");
+
+ mockMvc.perform(post("/api/auth/signin")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(asJsonString(loginRequest)).accept(MediaType.APPLICATION_JSON))
+ .andExpect(jsonPath("$.token", notNullValue()))
+ .andExpect(status().isOk());
+
+ verify(authenticationManager, times(1)).authenticate(new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword()));
+ verify(jwtUtils, times(1)).generateJwtToken(any());
+ }
+
+
+ @WithMockUser(roles="ADMIN")
+ @Test
+ void test_signup_returnsSuccessResponse() throws Exception {
+
+ SignupRequest signUpRequest = getSignupRequest();
+
+ when(userRepository.existsByUsername(signUpRequest.getUsername())).thenReturn(false);
+ when(passwordEncoder.encode(signUpRequest.getPassword())).thenReturn("password");
+ when(roleRepository.findByName(anyString())).thenReturn(Optional.of(new Role()));
+ when(userRepository.save(any())).thenReturn(getModUser());
+
+ mockMvc.perform(post("/api/auth/signup")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(asJsonString(signUpRequest)).accept(MediaType.APPLICATION_JSON))
+ .andExpect(jsonPath("$.message", notNullValue()))
+ .andExpect(status().isOk());
+
+ verify(userRepository, times(1)).existsByUsername(signUpRequest.getUsername());
+ verify(passwordEncoder, times(1)).encode(signUpRequest.getPassword());
+ verify(roleRepository, times(1)).findByName(anyString());
+ verify(userRepository, times(1)).save(any());
+ }
+
+
+}
diff --git a/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/RoleControllerTest.java b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/RoleControllerTest.java
new file mode 100644
index 0000000..48b5d4b
--- /dev/null
+++ b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/RoleControllerTest.java
@@ -0,0 +1,109 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.web;
+
+import org.hamcrest.Matchers;
+import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.dcaegen2.platform.mod.controllers.RoleController;
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.Role;
+import org.onap.dcaegen2.platform.mod.repositories.RoleRepository;
+import org.onap.dcaegen2.platform.mod.security.jwt.AuthEntryPointJwt;
+import org.onap.dcaegen2.platform.mod.security.jwt.JwtUtils;
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.security.core.Authentication;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.onap.dcaegen2.platform.mod.objectmothers.AuthObjectMother.asJsonString;
+import static org.onap.dcaegen2.platform.mod.objectmothers.RoleObjectMother.getRoles;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+/**
+ * @author
+ * @date 09/22/2020
+ * Mock Test cases for RoleController
+ */
+@WebMvcTest(RoleController.class)
+public class RoleControllerTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @MockBean
+ RoleRepository roleRepository;
+
+ @MockBean
+ UserDetailsServiceImpl userDetailsService;
+
+ @MockBean
+ AuthEntryPointJwt authEntryPointJwt;
+
+ @MockBean
+ JwtUtils jwtUtils;
+
+ @Mock
+ Authentication authentication;
+
+ @BeforeEach
+ void setUp() {
+ }
+
+
+ @Test
+ void test_getRoles() throws Exception {
+
+ Mockito.when(roleRepository.findAll()).thenReturn(getRoles());
+
+ MvcResult result = mockMvc.perform(get("/api/roles")
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk()).andReturn();
+
+ Assert.assertNotNull(result.getResponse().getContentAsString());
+
+ }
+
+}
diff --git a/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/UserControllerTest.java b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/UserControllerTest.java
new file mode 100644
index 0000000..1374e0e
--- /dev/null
+++ b/mod2/auth-service/src/test/java/org/onap/dcaegen2/platform/mod/web/UserControllerTest.java
@@ -0,0 +1,168 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * ================================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcaegen2.platform.mod.web;
+
+import org.apache.tools.ant.taskdefs.optional.extension.Specification;
+import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.Request;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.dcaegen2.platform.mod.controllers.RoleController;
+import org.onap.dcaegen2.platform.mod.controllers.UserController;
+import org.onap.dcaegen2.platform.mod.models.LoginRequest;
+import org.onap.dcaegen2.platform.mod.models.ModUser;
+import org.onap.dcaegen2.platform.mod.models.UpdateUserRequest;
+import org.onap.dcaegen2.platform.mod.repositories.RoleRepository;
+import org.onap.dcaegen2.platform.mod.repositories.UserRepository;
+import org.onap.dcaegen2.platform.mod.security.jwt.AuthEntryPointJwt;
+import org.onap.dcaegen2.platform.mod.security.jwt.JwtUtils;
+import org.onap.dcaegen2.platform.mod.security.services.UserDetailsServiceImpl;
+import org.onap.dcaegen2.platform.mod.services.MODUserDetailService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.MediaType;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.test.context.support.WithMockUser;
+import org.springframework.test.web.client.RequestMatcher;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.ResultMatcher;
+
+import java.util.Optional;
+
+import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.*;
+import static org.onap.dcaegen2.platform.mod.objectmothers.AuthObjectMother.asJsonString;
+import static org.onap.dcaegen2.platform.mod.objectmothers.AuthObjectMother.getModUser;
+import static org.onap.dcaegen2.platform.mod.objectmothers.RoleObjectMother.getRoles;
+import static org.onap.dcaegen2.platform.mod.objectmothers.UserObjectMother.*;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+/**
+ * @author
+ * @date 09/22/2020
+ * Mock Test cases for UserController
+ */
+@WebMvcTest(UserController.class)
+public class UserControllerTest {
+
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @MockBean
+ UserDetailsServiceImpl userDetailsService;
+
+ @MockBean
+ UserRepository userRepository;
+
+ @MockBean
+ MODUserDetailService modUserDetailService;
+
+ @MockBean
+ RoleRepository roleRepository;
+
+ @MockBean
+ AuthEntryPointJwt authEntryPointJwt;
+
+ @MockBean
+ JwtUtils jwtUtils;
+
+ @Mock
+ Authentication authentication;
+
+
+ @BeforeEach
+ void setUp() {
+ }
+
+ @WithMockUser(roles="ADMIN")
+ @Test
+ void test_getUsername() throws Exception {
+
+ when(userRepository.findByUsername(any())).thenReturn(Optional.of(new ModUser()));
+
+ MvcResult result = mockMvc.perform(get("/api/users/" + userId)
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk()).andReturn();
+
+ Assert.assertNotNull(result.getResponse().getContentAsString());
+ verify(userRepository, times(1)).findByUsername(any());
+ }
+
+ @Test
+ void test_getAllUsers() throws Exception {
+
+ when(modUserDetailService.findAll()).thenReturn(getUsers());
+
+ MvcResult result = mockMvc.perform(get("/api/users/getAll")
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk()).andReturn();
+
+ Assert.assertNotNull(result.getResponse().getContentAsString());
+ verify(modUserDetailService, times(1)).findAll();
+ }
+
+
+ @WithMockUser(roles="ADMIN")
+ @Test
+ void test_deleteUser() throws Exception {
+
+ doNothing().when(modUserDetailService).deleteUserByUsername(any(String.class));
+
+ MvcResult result = mockMvc.perform(delete("/api/users/" + userId)
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk()).andReturn();
+
+ Assert.assertNotNull(result.getResponse().getContentAsString());
+ verify(modUserDetailService, times(1)).deleteUserByUsername(any(String.class));
+ }
+
+
+ @WithMockUser(username="ADMIN")
+ @Test
+ void test_userUpdateOwnProfile_returnsSuccessResponse() throws Exception {
+ //arrange
+ UpdateUserRequest updateUserRequest = getUpdateUserRequest();
+
+ when(userDetailsService.adminUpdateUser(userId,updateUserRequest,"token")).thenReturn(getModUser());
+
+ mockMvc.perform(patch("/api/users/admin/" + userId)
+ //.header("Authorization", "token")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(asJsonString(updateUserRequest)).accept(MediaType.APPLICATION_JSON))
+ //.andExpect(jsonPath("$.message", notNullValue()))
+ .andExpect(status().isOk()).andReturn();
+
+ verify(userDetailsService, times(1)).adminUpdateUser(anyString(),updateUserRequest,anyString());
+ }
+
+
+} \ No newline at end of file
diff --git a/mod2/auth-service/src/test/resources/application.properties b/mod2/auth-service/src/test/resources/application.properties
new file mode 100644
index 0000000..d6a913c
--- /dev/null
+++ b/mod2/auth-service/src/test/resources/application.properties
@@ -0,0 +1 @@
+#spring.data.mongodb.port=0 \ No newline at end of file
diff --git a/mod2/auth-service/src/test/resources/http/requests/AuthLoginRequest.json b/mod2/auth-service/src/test/resources/http/requests/AuthLoginRequest.json
new file mode 100644
index 0000000..fbdc4a9
--- /dev/null
+++ b/mod2/auth-service/src/test/resources/http/requests/AuthLoginRequest.json
@@ -0,0 +1,4 @@
+{
+ "username": "admin",
+ "password": "admin@mod"
+}
diff --git a/mod2/auth-service/src/test/resources/http/requests/AuthSignupRequest.json b/mod2/auth-service/src/test/resources/http/requests/AuthSignupRequest.json
new file mode 100644
index 0000000..25be086
--- /dev/null
+++ b/mod2/auth-service/src/test/resources/http/requests/AuthSignupRequest.json
@@ -0,0 +1,6 @@
+{
+ "username": "admin1",
+ "fullName": "Administrator",
+ "password": "admin@mod",
+ "roles": ["ROLE_PST"]
+} \ No newline at end of file
diff --git a/mod2/auth-service/src/test/resources/specification/componentSpec_hello_world-with-dmaap.json b/mod2/auth-service/src/test/resources/specification/componentSpec_hello_world-with-dmaap.json
new file mode 100644
index 0000000..0ad6b6e
--- /dev/null
+++ b/mod2/auth-service/src/test/resources/specification/componentSpec_hello_world-with-dmaap.json
@@ -0,0 +1,149 @@
+{
+ "self": {
+ "component_type": "docker",
+ "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR",
+ "name": "dcae-collectors-vcc-helloworld-pm",
+ "version": "1.0.1"
+ },
+
+ "services": {
+ "calls": [],
+ "provides": []
+ },
+
+ "streams": {
+ "publishes": [{
+ "config_key": "DCAE-HELLO-WORLD-PUB-DR",
+ "format": "dataformat_Hello_World_PM",
+ "type": "data_router",
+ "version": "1.0.0"
+ },
+ {
+ "config_key": "DCAE-HELLO-WORLD-PUB-MR",
+ "format": "dataformat_Hello_World_PM",
+ "type": "message_router",
+ "version": "1.0.0"
+ }
+ ],
+
+ "subscribes": [{
+ "config_key": "DCAE-HELLO-WORLD-SUB-MR",
+ "format": "dataformat_Hello_World_PM",
+ "route": "/DCAE_HELLO_WORLD_SUB_MR",
+ "type": "message_router",
+ "version": "1.0.0"
+ },
+ {
+ "config_key": "DCAE-HELLO-WORLD-SUB-DR",
+ "format": "dataformat_Hello_World_PM",
+ "route": "/DCAE-HELLO-WORLD-SUB-DR",
+ "type": "data_router",
+ "version": "1.0.0"
+ }
+ ]
+ },
+
+ "parameters":
+ [
+ {
+ "name": "vcc_hello_name",
+ "value": "120",
+ "type": "integer",
+ "description": "the name entered for specific person",
+ "sourced_at_deployment": false,
+ "designer_editable": false,
+ "policy_editable": false
+ },
+
+ {
+ "name": "useDtiConfig",
+ "value": false,
+ "type" : "boolean",
+ "description": "component depends on configuration from dti.",
+ "sourced_at_deployment": false,
+ "designer_editable": true,
+ "policy_editable": false,
+ "required" : true
+ },
+
+ {
+ "name": "isSelfServeComponent",
+ "value": false,
+ "type": "boolean",
+ "description": "Is this used as self serve component.",
+ "sourced_at_deployment": false,
+ "designer_editable": true,
+ "policy_editable": false,
+ "required" : true
+ }
+ ],
+
+ "auxilary": {
+ "healthcheck": {
+ "interval": "60s",
+ "initialDelaySeconds": "120s",
+ "timeout": "20s",
+ "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh",
+ "type": "docker"
+ },
+ "livehealthcheck": {
+ "interval": "60s",
+ "initialDelaySeconds": "120s",
+ "timeout": "20s",
+ "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh",
+ "type": "docker"
+ },
+ "reconfigs":{
+ "app_reconfig" : "abc"
+ },
+
+ "volumes": [
+ {
+ "container": {
+ "bind": "/opt/app/dcae-certificate"
+ },
+ "host": {
+ "path": "/opt/app/dcae-certificate"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/logs/DCAE/dmd/AGENT"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/dmd/AGENT"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/logs/DCAE/dmd/WATCHER"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/dmd/WATCHER"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/app/vcc/logs/DCAE"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/vcc-logs"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/app/vcc/archive/data"
+ },
+ "host": {
+ "path": "/opt/data/DCAE/helloworldpm/vcc-archive"
+ }
+ }
+
+ ]
+
+ },
+ "artifacts": [{
+ "type": "docker image",
+ "uri": "dockercentral.it.att.com:5100/com.att.sample/dcae-controller-vcc-helloworld-pm:18.02-001"
+ }]
+} \ No newline at end of file
diff --git a/mod2/auth-service/src/test/resources/specification/policy_json_sample_3.json b/mod2/auth-service/src/test/resources/specification/policy_json_sample_3.json
new file mode 100644
index 0000000..4a8c76f
--- /dev/null
+++ b/mod2/auth-service/src/test/resources/specification/policy_json_sample_3.json
@@ -0,0 +1,28 @@
+{
+ "policies": [
+ {
+ "configAttributes": "",
+ "configName": "",
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_",
+ "unique": false
+ },
+ {
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_",
+ "unique": true
+ },
+ {
+ "configAttributes": "",
+ "configName": "",
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_*",
+ "unique": false
+ }
+ ],
+ "policy": [
+ {
+ "policy_id" : "id_0"
+ }
+ ]
+} \ No newline at end of file
diff --git a/mod2/catalog-service/Dockerfile b/mod2/catalog-service/Dockerfile
new file mode 100644
index 0000000..0870a21
--- /dev/null
+++ b/mod2/catalog-service/Dockerfile
@@ -0,0 +1,14 @@
+FROM onap/integration-java11:7.1.0
+
+ARG PROJECT_BUILD_DIR_NAME
+ARG FINAL_JAR
+
+WORKDIR /usr/app
+VOLUME /tmp
+
+COPY ${PROJECT_BUILD_DIR_NAME}/${FINAL_JAR} .
+
+EXPOSE 8080
+ENTRYPOINT ["java", \
+ "-Djava.security.egd=file:/dev/./urandom", \
+ "-jar", "mod-catalog-service.jar"]
diff --git a/mod2/catalog-service/lombok.config b/mod2/catalog-service/lombok.config
new file mode 100644
index 0000000..8f7e8aa
--- /dev/null
+++ b/mod2/catalog-service/lombok.config
@@ -0,0 +1 @@
+lombok.addLombokGeneratedAnnotation = true \ No newline at end of file
diff --git a/mod2/catalog-service/pom.xml b/mod2/catalog-service/pom.xml
new file mode 100644
index 0000000..37aaf46
--- /dev/null
+++ b/mod2/catalog-service/pom.xml
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ org.onap.dcae
+ ~ ================================================================================
+ ~ Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ ~ ================================================================================
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~ ============LICENSE_END=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>2.0.0</version>
+ </parent>
+ <groupId>org.onap.dcaegen2.platform.mod</groupId>
+ <artifactId>catalog-service</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <properties>
+ <java.version>11</java.version>
+ <maven.compiler.source>${java.version}</maven.compiler.source>
+ <maven.compiler.target>${java.version}</maven.compiler.target>
+ <spring-boot.version>2.2.9.RELEASE</spring-boot.version>
+ <dockerfile-maven-plugin.version>1.4.10</dockerfile-maven-plugin.version>
+ <docker.image.name>${project.groupId}.${project.artifactId}</docker.image.name>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.8.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-validation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>2.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>2.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.10</version>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>okhttp</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>mockwebserver</artifactId>
+ <version>4.0.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <!-- Import dependency management from Spring Boot -->
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>2.2.5.RELEASE</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring-boot.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>${dockerfile-maven-plugin.version}</version>
+ <configuration>
+ <contextDirectory>${project.basedir}</contextDirectory>
+ <repository>${onap.nexus.dockerregistry.daily}/${docker.image.name}</repository>
+ <buildArgs>
+ <PROJECT_BUILD_DIR_NAME>target</PROJECT_BUILD_DIR_NAME>
+ <FINAL_JAR>${project.build.finalName}.jar</FINAL_JAR>
+ </buildArgs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>build-image</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>tag-and-push-image-latest</id>
+ <phase>package</phase>
+ <goals>
+ <goal>tag</goal>
+ <goal>push</goal>
+ </goals>
+ <configuration>
+ <repository>${onap.nexus.dockerregistry.daily}/${docker.image.name}</repository>
+ <tag>latest</tag>
+ <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
+ </configuration>
+ </execution>
+ <execution>
+ <id>tag-and-push-image-with-version</id>
+ <phase>package</phase>
+ <goals>
+ <goal>tag</goal>
+ <goal>push</goal>
+ </goals>
+ <configuration>
+ <repository>${onap.nexus.dockerregistry.daily}/${docker.image.name}</repository>
+ <tag>${project.version}</tag>
+ <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.2</version>
+ </plugin>
+ </plugins>
+ <finalName>mod-catalog-service</finalName>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.7</version>
+ </plugin>
+ </plugins>
+ </reporting>
+</project> \ No newline at end of file
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/ModCatalogApplication.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/ModCatalogApplication.java
new file mode 100644
index 0000000..d514a69
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/ModCatalogApplication.java
@@ -0,0 +1,68 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+
+/**
+ * The application class
+ */
+@SpringBootApplication
+@EnableSwagger2
+public class ModCatalogApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ModCatalogApplication.class, args);
+ }
+
+ @Bean
+ public Docket swaggerConfiguration(){
+ // return a prepared Docket instance
+ return new Docket(DocumentationType.SWAGGER_2)
+ .select()
+ //.paths(PathSelectors.ant("/api/*"))
+ .apis(RequestHandlerSelectors.basePackage("org.onap.dcaegen2.platform.mod"))
+ .build()
+ .apiInfo(apiDetails());
+ }
+
+ private ApiInfo apiDetails() {
+ Contact DEFAULT_CONTACT = new Contact("", "", "");
+ return new ApiInfo(
+ "MOD APIs",
+ "APIs for MOD",
+ "1.0.0"
+ ,"", DEFAULT_CONTACT, "", "", new ArrayList<>()
+ );
+ }
+ //http://localhost:8080/swagger-ui.html for web page view
+ //http://localhost:8080/v2/api-docs for json view
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockDeploymentArtifactGenerator.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockDeploymentArtifactGenerator.java
new file mode 100644
index 0000000..24c31ed
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockDeploymentArtifactGenerator.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mock;
+
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactGeneratorStrategy;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * Mock implementation for DeploymentArtifactGenerator
+ */
+@Component
+public class MockDeploymentArtifactGenerator implements DeploymentArtifactGeneratorStrategy {
+
+ /**
+ * null implementation.
+ * @param activeSpec
+ * @param release
+ * @return
+ */
+ @Override
+ public Map<String, Object> generateForRelease(Specification activeSpec, String release) {
+ return null;
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockSpecificationValidationStratergy.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockSpecificationValidationStratergy.java
new file mode 100644
index 0000000..8f9f921
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockSpecificationValidationStratergy.java
@@ -0,0 +1,42 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mock;
+
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationValidationStratergy;
+import org.springframework.stereotype.Component;
+
+/**
+ * Mock implementation for SpecificationValidationStrategy
+ */
+@Component
+public class MockSpecificationValidationStratergy implements SpecificationValidationStratergy {
+
+ /**
+ * Mock implementation
+ * @param specificationRequest
+ * @param release
+ */
+ @Override
+ public void validate(SpecificationRequest specificationRequest, String release) {
+ //do nothing
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMicroservice.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMicroservice.java
new file mode 100644
index 0000000..3e5891f
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMicroservice.java
@@ -0,0 +1,65 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.basemicroservice;
+
+import org.onap.dcaegen2.platform.mod.model.common.AuditFields;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A model class which represents Base-Microservice entity
+ */
+@Data
+@NoArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+//TODO: migrate the document to microservices
+@Document("base-microservices")
+public class BaseMicroservice {
+ private String id;
+
+ @ApiModelProperty(required = true)
+ private String name;
+
+ @ApiModelProperty(required = true)
+ private String tag;
+
+ private String serviceName;
+
+ private BaseMsType type;
+
+ private BaseMsLocation location;
+
+ private String namespace;
+
+ private BaseMsStatus status;
+
+ private AuditFields metadata;
+
+ private List<Map<String, String>> msInstances = new ArrayList<>();
+}
+
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsLocation.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsLocation.java
new file mode 100644
index 0000000..e8114a5
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsLocation.java
@@ -0,0 +1,29 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.basemicroservice;
+/**
+ * Supported values for Base-Microservice location
+ */
+public enum BaseMsLocation {
+ CENTRAL,
+ EDGE,
+ UNSPECIFIED
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsStatus.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsStatus.java
new file mode 100644
index 0000000..4460e04
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsStatus.java
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.basemicroservice;
+
+/**
+ * Supported statuses for Base-Microservice entity
+ */
+public enum BaseMsStatus {
+ ACTIVE, RETIRED
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsType.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsType.java
new file mode 100644
index 0000000..1cc81e8
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/basemicroservice/BaseMsType.java
@@ -0,0 +1,32 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.basemicroservice;
+
+/**
+ * Supported Types for Base-Microservice
+ */
+public enum BaseMsType {
+ TICK,
+ FM_COLLECTOR,
+ PM_COLLECTOR,
+ ANALYTIC,
+ OTHER
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/common/AuditFields.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/common/AuditFields.java
new file mode 100644
index 0000000..d062456
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/common/AuditFields.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Builder;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A model class for auditfields
+ */
+@Data
+@Builder
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class AuditFields {
+
+ private String createdBy;
+ private Date createdOn;
+ private String updatedBy;
+ private Date updatedOn;
+ //TODO set default empty values if not exist
+ private String notes = "";
+ private List<String> labels = new ArrayList<>();
+
+ public void setLabels(Object labels) {
+ if(labels instanceof List)
+ this.labels = (List<String>) labels;
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifact.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifact.java
new file mode 100644
index 0000000..600c735
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifact.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.deploymentartifact;
+
+import lombok.Data;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.Map;
+
+/**
+ * A model class which represents Deployment-Artifact entity
+ */
+@Data
+@Document("deployment-artifact")
+public class DeploymentArtifact {
+
+ private String id;
+
+ private Integer version;
+
+ private String content;
+
+ private String fileName;
+
+ private DeploymentArtifactStatus status;
+
+ private Map<String, Object> metadata;
+
+ private MsInstanceInfo msInstanceInfo;
+
+ private Map<String, Object> specificationInfo;
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactFilter.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactFilter.java
new file mode 100644
index 0000000..870ca46
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactFilter.java
@@ -0,0 +1,40 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.deploymentartifact;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+/**
+ * A model class to construct a filter that can be passed in DeploymentArtifactSearch
+ * @see org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactSearch
+ */
+@Data
+public class DeploymentArtifactFilter {
+ @JsonProperty("release")
+ private String release;
+
+ @JsonProperty("status")
+ private DeploymentArtifactStatus status;
+
+ @JsonProperty("tag")
+ private String tag;
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactSearch.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactSearch.java
new file mode 100644
index 0000000..9e955cd
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactSearch.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.deploymentartifact;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+/**
+ * A model class to define Deployment-Artifact's searching criteria.
+ */
+@Data
+public class DeploymentArtifactSearch {
+
+ @JsonProperty("filter")
+ private DeploymentArtifactFilter filter;
+
+ public DeploymentArtifactSearch() {
+ this.filter = new DeploymentArtifactFilter();
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactStatus.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactStatus.java
new file mode 100644
index 0000000..4ee4e0e
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/DeploymentArtifactStatus.java
@@ -0,0 +1,30 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.deploymentartifact;
+
+/**
+ * Supported Statuses for a Deployment-Artifact
+ */
+public enum DeploymentArtifactStatus {
+
+ IN_DEV, NOT_NEEDED, DEV_COMPLETE,
+ IN_PROD, PROD_FAILED
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/MsInstanceInfo.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/MsInstanceInfo.java
new file mode 100644
index 0000000..665961c
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/deploymentartifact/MsInstanceInfo.java
@@ -0,0 +1,33 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.deploymentartifact;
+
+import lombok.Data;
+
+/**
+ * MsInstance Reference model used in DeploymentArtifact entity
+ */
+@Data
+public class MsInstanceInfo {
+ String id;
+ String name;
+ String release;
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ErrorMessages.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ErrorMessages.java
new file mode 100644
index 0000000..9b96066
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ErrorMessages.java
@@ -0,0 +1,33 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions;
+
+public class ErrorMessages {
+
+ public static final String MICROSERVICE_NAME_CONFLICT_MESSAGE = "Microservice with this name already exists.";
+ public static final String MICROSERVICE_TAG_CONFLICT_MESSAGE = "Microservice with this tag name already exists.";
+ public static final String MS_TAG_NAME_VALIDATION_MESSAGE =
+ "Microservice tag name is Invalid. Accepts lowercase letters and hyphens." +
+ " Tag name length cannot exceed 50 characters";
+ public static final String MS_SERVICE_NAME_CONFLICT_MESSAGE = "Microservice with this core name already exists.";
+ public static final String MS_SERVICE_NAME_VALIDATION_MESSAGE =
+ "Service name is Invalid. Accepts lowercase letters and hyphens";
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/MissingRequestBodyException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/MissingRequestBodyException.java
new file mode 100644
index 0000000..2d7d785
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/MissingRequestBodyException.java
@@ -0,0 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions;
+
+public class MissingRequestBodyException extends RuntimeException {
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/OperationNotAllowedException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/OperationNotAllowedException.java
new file mode 100644
index 0000000..47dafc9
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/OperationNotAllowedException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions;
+
+public class OperationNotAllowedException extends RuntimeException {
+ public OperationNotAllowedException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ReleaseNotSupportedException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ReleaseNotSupportedException.java
new file mode 100644
index 0000000..7ea6834
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ReleaseNotSupportedException.java
@@ -0,0 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions;
+
+public class ReleaseNotSupportedException extends RuntimeException{
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ResourceConflictException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ResourceConflictException.java
new file mode 100644
index 0000000..d81c68c
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/ResourceConflictException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions;
+
+public class ResourceConflictException extends RuntimeException{
+ public ResourceConflictException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceNotFoundException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceNotFoundException.java
new file mode 100644
index 0000000..3ee81e4
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceNotFoundException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.basemicroservice;
+
+public class BaseMicroserviceNotFoundException extends RuntimeException {
+ public BaseMicroserviceNotFoundException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceTagAlreadyExists.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceTagAlreadyExists.java
new file mode 100644
index 0000000..e0bd119
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceTagAlreadyExists.java
@@ -0,0 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.basemicroservice;
+
+public class BaseMicroserviceTagAlreadyExists extends RuntimeException {
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceTagInvalid.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceTagInvalid.java
new file mode 100644
index 0000000..79282aa
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMicroserviceTagInvalid.java
@@ -0,0 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.basemicroservice;
+
+public class BaseMicroserviceTagInvalid extends RuntimeException {
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMsServiceNameAlreadyExists.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMsServiceNameAlreadyExists.java
new file mode 100644
index 0000000..3ae1b6f
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMsServiceNameAlreadyExists.java
@@ -0,0 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.basemicroservice;
+
+public class BaseMsServiceNameAlreadyExists extends RuntimeException {
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMsServiceNameInvalid.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMsServiceNameInvalid.java
new file mode 100644
index 0000000..6de3014
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/basemicroservice/BaseMsServiceNameInvalid.java
@@ -0,0 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.basemicroservice;
+
+public class BaseMsServiceNameInvalid extends RuntimeException {
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/common/UserNotPassedException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/common/UserNotPassedException.java
new file mode 100644
index 0000000..b34e065
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/common/UserNotPassedException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.common;
+
+public class UserNotPassedException extends RuntimeException {
+ public UserNotPassedException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/BlueprintFileNameCreateException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/BlueprintFileNameCreateException.java
new file mode 100644
index 0000000..5f52885
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/BlueprintFileNameCreateException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact;
+
+public class BlueprintFileNameCreateException extends RuntimeException{
+ public BlueprintFileNameCreateException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/DeploymentArtifactNotFound.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/DeploymentArtifactNotFound.java
new file mode 100644
index 0000000..e10c54e
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/DeploymentArtifactNotFound.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact;
+
+public class DeploymentArtifactNotFound extends RuntimeException{
+ public DeploymentArtifactNotFound(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/StatusChangeNotValidException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/StatusChangeNotValidException.java
new file mode 100644
index 0000000..99faf50
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/deploymentartifact/StatusChangeNotValidException.java
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact;
+
+public class StatusChangeNotValidException extends RuntimeException {
+
+ public StatusChangeNotValidException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/msinstance/MsInstanceAlreadyExistsException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/msinstance/MsInstanceAlreadyExistsException.java
new file mode 100644
index 0000000..80778ea
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/msinstance/MsInstanceAlreadyExistsException.java
@@ -0,0 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.msinstance;
+
+public class MsInstanceAlreadyExistsException extends RuntimeException {
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/msinstance/MsInstanceNotFoundException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/msinstance/MsInstanceNotFoundException.java
new file mode 100644
index 0000000..9ea977c
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/msinstance/MsInstanceNotFoundException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.msinstance;
+
+public class MsInstanceNotFoundException extends RuntimeException{
+ public MsInstanceNotFoundException(String message) {
+ super(message);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/specification/SpecificationInvalid.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/specification/SpecificationInvalid.java
new file mode 100644
index 0000000..1b56d35
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/specification/SpecificationInvalid.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.specification;
+
+import java.util.Map;
+
+public class SpecificationInvalid extends RuntimeException {
+
+ Map<String, Object> errorsMap;
+
+ public SpecificationInvalid(String message) {
+ super(message);
+ }
+
+ public SpecificationInvalid(Map<String, Object> errorsMap){
+ this.errorsMap = errorsMap;
+ }
+
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/specification/SpecificationNotFoundException.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/specification/SpecificationNotFoundException.java
new file mode 100644
index 0000000..9728b15
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/exceptions/specification/SpecificationNotFoundException.java
@@ -0,0 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.exceptions.specification;
+
+public class SpecificationNotFoundException extends RuntimeException {
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/DeploymentArtifactsRef.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/DeploymentArtifactsRef.java
new file mode 100644
index 0000000..fe1aed5
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/DeploymentArtifactsRef.java
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.microserviceinstance;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * DeploymentArtifacts Reference model used in Microservice-Instance entity
+ */
+@Data
+public class DeploymentArtifactsRef {
+
+ private int mostRecentVersion;
+ private List<String> deploymentArtifacts;
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/MsInstance.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/MsInstance.java
new file mode 100644
index 0000000..d305aa4
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/MsInstance.java
@@ -0,0 +1,56 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.microserviceinstance;
+
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.Map;
+
+/**
+ * A model class which represents Microservice-Instance entity
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@Document("ms-instance")
+public class MsInstance {
+ @Id
+ private String id;
+ private String name;
+ private String release;
+ private String version;
+ private MsInstanceStatus status;
+ private Map<String, Object> metadata;
+ private Map<String,Object> msInfo;
+
+ @DBRef
+ private Specification activeSpec;
+
+ private DeploymentArtifactsRef deploymentArtifactsInfo;
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/MsInstanceStatus.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/MsInstanceStatus.java
new file mode 100644
index 0000000..223f3dc
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/microserviceinstance/MsInstanceStatus.java
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.microserviceinstance;
+
+/**
+ * Supported Statuses for Microservice-Instance entity
+ */
+public enum MsInstanceStatus {
+ NEW, IN_DEV, DEV_COMPLETE, IN_TEST, CERTIFIED, PROD_DEPLOYED
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/DeploymentArtifactPatchRequest.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/DeploymentArtifactPatchRequest.java
new file mode 100644
index 0000000..8d52488
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/DeploymentArtifactPatchRequest.java
@@ -0,0 +1,40 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.util.Map;
+
+/**
+ * A model that represent request body to patch DeploymentArtifact entity.
+ */
+@Data
+public class DeploymentArtifactPatchRequest {
+
+ @JsonProperty("status")
+ private DeploymentArtifactStatus status;
+
+ @JsonProperty("metadata")
+ private Map<String, Object> metaData;
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/ErrorResponse.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/ErrorResponse.java
new file mode 100644
index 0000000..fe78f94
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/ErrorResponse.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+/**
+ * A model that represent response body to send a simple error response.
+ */
+@Data
+@AllArgsConstructor
+public class ErrorResponse {
+
+ private String message;
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/GenericErrorResponse.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/GenericErrorResponse.java
new file mode 100644
index 0000000..76597e2
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/GenericErrorResponse.java
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import lombok.Data;
+import org.springframework.http.HttpStatus;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A model that represent response body to send a detailed error response.
+ */
+@Data
+public class GenericErrorResponse {
+ private List<String> errors = new ArrayList<>();
+ private HttpStatus status;
+ private String message;
+
+ public GenericErrorResponse() {
+ }
+
+ public GenericErrorResponse(List<String> errors, HttpStatus status, String message) {
+ this.errors = errors;
+ this.status = status;
+ this.message = message;
+ }
+
+ public GenericErrorResponse(String error, HttpStatus status, String message) {
+ this.status = status;
+ this.message = message;
+ errors = Arrays.asList(error);
+ }
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MicroserviceCreateRequest.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MicroserviceCreateRequest.java
new file mode 100644
index 0000000..f8288cb
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MicroserviceCreateRequest.java
@@ -0,0 +1,59 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsLocation;
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsType;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import java.util.Map;
+
+/**
+ * A model that represent request body to create a Microservice entity.
+ */
+@NoArgsConstructor
+@Data
+public class MicroserviceCreateRequest {
+
+ @NotBlank(message = "Microservice tag can not be blank")
+ @Pattern(regexp = "^([a-z0-9](-[a-z0-9])*)+$", message = "Microservice tag name is Invalid. Accepts alphanumerics and hyphens.")
+ @Size(min = 5, max = 50, message = "Tag name length cannot exceed 50 characters")
+ private String tag;
+
+ @NotBlank(message = "Microservice name cannot be blank")
+ private String name;
+
+ @Pattern(regexp = "^[a-z-]*$", message = "Microservice core name is Invalid. Accepts lowercase letters and hyphens.")
+ private String serviceName;
+
+ private BaseMsType type;
+ private BaseMsLocation location;
+ private String namespace;
+ private Map<String, Object> metadata;
+
+ @NotBlank(message = "user can not be blank")
+ private String user;
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MicroserviceUpdateRequest.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MicroserviceUpdateRequest.java
new file mode 100644
index 0000000..a7262d6
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MicroserviceUpdateRequest.java
@@ -0,0 +1,52 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsLocation;
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsType;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import java.util.Map;
+
+/**
+ * A model that represent request body to update a Microservice entity.
+ */
+@NoArgsConstructor
+@Data
+public class MicroserviceUpdateRequest {
+
+ @Pattern(regexp = "^(?!\\s*$).+", message = "must not be blank")
+ private String name;
+
+ @Pattern(regexp = "^[a-z-]*$", message = "Microservice core name is Invalid. Accepts lowercase letters and hyphens.")
+ private String serviceName;
+
+ private BaseMsType type;
+ private BaseMsLocation location;
+ private String namespace;
+ private Map<String, Object> metadata;
+
+ @NotBlank(message = "user cannot be blank")
+ private String user;
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MsInstanceRequest.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MsInstanceRequest.java
new file mode 100644
index 0000000..803d417
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MsInstanceRequest.java
@@ -0,0 +1,52 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotBlank;
+import java.util.Map;
+
+/**
+ * A model that represent request body to create MsInsance entity.
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class MsInstanceRequest {
+
+ @NotBlank
+ private String name;
+
+ @NotBlank
+ private String release;
+
+ private String version;
+
+ @NotBlank
+ private String user;
+
+ private Map<String,Object> metadata;
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MsInstanceUpdateRequest.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MsInstanceUpdateRequest.java
new file mode 100644
index 0000000..2af61a8
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/MsInstanceUpdateRequest.java
@@ -0,0 +1,42 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.util.Map;
+
+/**
+ * A model that represent request body to patch MsInstance entity.
+ */
+@Data
+public class MsInstanceUpdateRequest {
+
+ private String release;
+ private String version;
+ private Map<String,Object> metadata;
+
+ @NotBlank(message = "User cannot be blank.")
+ private String user;
+}
+
+
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/SpecificationRequest.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/SpecificationRequest.java
new file mode 100644
index 0000000..e34379e
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/SpecificationRequest.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import org.onap.dcaegen2.platform.mod.model.specification.DeploymentType;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Map;
+
+/**
+ * A model that represent request body to create Specification entity.
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class SpecificationRequest {
+
+ private Map<String,Object> specContent;
+ private Map<String, Object> policyJson;
+ private DeploymentType type;
+ private String user;
+ private Map<String,Object> metadata;
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/SuccessResponse.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/SuccessResponse.java
new file mode 100644
index 0000000..d428407
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/restapi/SuccessResponse.java
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.restapi;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+/**
+ * A model that represent a simple Success response body.
+ */
+@Data
+@AllArgsConstructor
+public class SuccessResponse {
+
+ private String message;
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/DeploymentType.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/DeploymentType.java
new file mode 100644
index 0000000..815a529
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/DeploymentType.java
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.specification;
+
+/**
+ * Supported Deployment Types in Specification entity
+ */
+public enum DeploymentType {
+ K8S, DOCKER
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/Specification.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/Specification.java
new file mode 100644
index 0000000..32778a3
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/Specification.java
@@ -0,0 +1,52 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.specification;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.Map;
+
+/**
+ * A model class which represents Specification entity
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Document("specification")
+public class Specification {
+
+ @Id
+ private String id;
+ private SpecificationStatus status;
+ private Map<String,Object> specContent;
+ private Map<String, Object> policyJson;
+ private DeploymentType type;
+ private Map<String,Object> metadata;
+ private Map<String,Object> msInstanceInfo;
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/SpecificationStatus.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/SpecificationStatus.java
new file mode 100644
index 0000000..3e6cd1a
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/model/specification/SpecificationStatus.java
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.model.specification;
+
+/**
+ * Supported statuses for Specification entity
+ */
+public enum SpecificationStatus {
+ ACTIVE, INACTIVE
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/basemicroservice/BaseMicroserviceMongoGateway.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/basemicroservice/BaseMicroserviceMongoGateway.java
new file mode 100644
index 0000000..9101234
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/basemicroservice/BaseMicroserviceMongoGateway.java
@@ -0,0 +1,71 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mongo.basemicroservice;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.web.service.basemicroservice.BaseMicroserviceGateway;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Mongo implementation of BaseMicroserviceGateway
+ */
+@Service
+public class BaseMicroserviceMongoGateway implements BaseMicroserviceGateway {
+
+ @Autowired
+ BaseMicroserviceMongoRepo repo;
+
+ @Override
+ public Optional<BaseMicroservice> findByName(String name) {
+ return repo.findByNameIgnoreCase(name);
+ }
+
+ @Override
+ public Optional<BaseMicroservice> findByTag(String tag) {
+ return repo.findByTagIgnoreCase(tag);
+ }
+
+ @Override
+ public Optional<BaseMicroservice> findByServiceName(String serviceName) {
+ return repo.findByServiceNameIgnoreCase(serviceName);
+ }
+
+ @Override
+ public BaseMicroservice save(BaseMicroservice microservice) {
+ return repo.save(microservice);
+ }
+
+ @Override
+ public List<BaseMicroservice> findAll() {
+ Sort sortByCreatedDate = Sort.by(Sort.Direction.DESC, "metadata.createdOn");
+ return repo.findAll(sortByCreatedDate);
+ }
+
+ @Override
+ public Optional<BaseMicroservice> findById(String msId) {
+ return Optional.empty();
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/basemicroservice/BaseMicroserviceMongoRepo.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/basemicroservice/BaseMicroserviceMongoRepo.java
new file mode 100644
index 0000000..b3795b2
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/basemicroservice/BaseMicroserviceMongoRepo.java
@@ -0,0 +1,40 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mongo.basemicroservice;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.Optional;
+
+/**
+ * An interface to use Spring MongoRepository
+ */
+@Repository
+public interface BaseMicroserviceMongoRepo extends MongoRepository<BaseMicroservice, String> {
+
+ Optional<BaseMicroservice> findByNameIgnoreCase(String name);
+
+ Optional<BaseMicroservice> findByTagIgnoreCase(String tag);
+
+ Optional<BaseMicroservice> findByServiceNameIgnoreCase(String serviceName);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/deploymentartifact/DeploymentArtifactMongoGateway.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/deploymentartifact/DeploymentArtifactMongoGateway.java
new file mode 100644
index 0000000..72e9ec6
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/deploymentartifact/DeploymentArtifactMongoGateway.java
@@ -0,0 +1,86 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mongo.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactSearch;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.MsInstanceInfo;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactGateway;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Mongo implementation of BaseMicroserviceGateway
+ */
+@Service
+public class DeploymentArtifactMongoGateway implements DeploymentArtifactGateway {
+
+ @Autowired
+ DeploymentArtifactMongoRepo crudRepo;
+
+ public DeploymentArtifactMongoGateway(DeploymentArtifactMongoRepo repo) {
+ this.crudRepo = repo;
+ }
+
+ @Override
+ public List<DeploymentArtifact> findAll() {
+ return crudRepo.findAll();
+ }
+
+ @Override
+ public List<DeploymentArtifact> findByMsInstanceId(String id) {
+ return crudRepo.findByMsInstanceInfo_Id(id);
+ }
+
+ @Override
+ public Optional<DeploymentArtifact> findById(String id) {
+ return crudRepo.findById(id);
+ }
+
+ @Override
+ public void deleteById(String deploymentArtifactId) {
+ crudRepo.deleteById(deploymentArtifactId);
+ }
+
+ @Override
+ public DeploymentArtifact save(DeploymentArtifact deploymentArtifact) {
+ return crudRepo.save(deploymentArtifact);
+ }
+
+ @Override
+ public List<DeploymentArtifact> findAll(DeploymentArtifactSearch search) {
+ DeploymentArtifact artifact = new DeploymentArtifact();
+ artifact.setStatus(search.getFilter().getStatus());
+ //Currently searching tag in filename as it is not present in DeploymentArtifact record
+ artifact.setFileName(search.getFilter().getTag());
+
+ MsInstanceInfo msInstanceInfo = new MsInstanceInfo();
+ msInstanceInfo.setRelease(search.getFilter().getRelease());
+ artifact.setMsInstanceInfo(msInstanceInfo);
+
+ return crudRepo.findAll(Example.of(artifact,ExampleMatcher.matching().withIgnoreCase()));
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/deploymentartifact/DeploymentArtifactMongoRepo.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/deploymentartifact/DeploymentArtifactMongoRepo.java
new file mode 100644
index 0000000..cb8d0bb
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/deploymentartifact/DeploymentArtifactMongoRepo.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mongo.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * An interface to use Spring MongoRepository
+ */
+@Repository
+public interface DeploymentArtifactMongoRepo extends MongoRepository<DeploymentArtifact, String> {
+
+ List<DeploymentArtifact> findByMsInstanceInfo_Id(String id);
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/microserviceinstance/MsInstanceMongoGateway.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/microserviceinstance/MsInstanceMongoGateway.java
new file mode 100644
index 0000000..d6d0d35
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/microserviceinstance/MsInstanceMongoGateway.java
@@ -0,0 +1,61 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mongo.microserviceinstance;
+
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceGateway;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Mongo implementation of MsInstance
+ */
+@Service
+public class MsInstanceMongoGateway implements MsInstanceGateway {
+
+ @Autowired
+ private MsInstanceMongoRepo repo;
+
+ @Override
+ public Optional<MsInstance> findByNameAndRelease(String name, String release) {
+ return repo.findByNameIgnoreCaseAndReleaseIgnoreCase(name, release);
+ }
+
+ @Override
+ public Optional<MsInstance> findById(String msInstanceId) {
+ return repo.findById(msInstanceId);
+ }
+
+ @Override
+ public List<MsInstance> findAll() {
+ Sort sortByCreatedDate = Sort.by(Sort.Direction.DESC, "metadata.createdOn");
+ return repo.findAll(sortByCreatedDate);
+ }
+
+ @Override
+ public MsInstance save(MsInstance msInstance) {
+ return repo.save(msInstance);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/microserviceinstance/MsInstanceMongoRepo.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/microserviceinstance/MsInstanceMongoRepo.java
new file mode 100644
index 0000000..1d6a277
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/microserviceinstance/MsInstanceMongoRepo.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mongo.microserviceinstance;
+
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.Optional;
+
+/**
+ * An interface to use Spring MongoRepository
+ */
+@Repository
+public interface MsInstanceMongoRepo extends MongoRepository<MsInstance, String> {
+
+ Optional<MsInstance> findByNameIgnoreCaseAndReleaseIgnoreCase(String name, String release);
+
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/specification/SpecificationMongoGateway.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/specification/SpecificationMongoGateway.java
new file mode 100644
index 0000000..ae3a421
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/specification/SpecificationMongoGateway.java
@@ -0,0 +1,48 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mongo.specification;
+
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationGateway;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * Mongo implementation of Specification
+ */
+@Service
+public class SpecificationMongoGateway implements SpecificationGateway {
+
+ @Autowired
+ private SpecificationMongoRepo repo;
+
+ @Override
+ public List<Specification> getSpecificationByMsInstanceId(String id) {
+ return repo.getSpecificationsByMsInstaceId(id);
+ }
+
+ @Override
+ public Specification save(Specification newSpec) {
+ return repo.save(newSpec);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/specification/SpecificationMongoRepo.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/specification/SpecificationMongoRepo.java
new file mode 100644
index 0000000..306e78a
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mongo/specification/SpecificationMongoRepo.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.mongo.specification;
+
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.mongodb.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * An interface to use Spring MongoRepository
+ */
+@Repository
+public interface SpecificationMongoRepo extends MongoRepository<Specification, String> {
+
+ @Query(value = "{'msInstanceInfo.id':?0}")
+ List<Specification> getSpecificationsByMsInstaceId(String id);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/AppExceptionHandler.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/AppExceptionHandler.java
new file mode 100644
index 0000000..1a2f5f9
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/AppExceptionHandler.java
@@ -0,0 +1,149 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.controller;
+
+import org.onap.dcaegen2.platform.mod.model.exceptions.MissingRequestBodyException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.OperationNotAllowedException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.ResourceConflictException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.basemicroservice.BaseMicroserviceNotFoundException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.common.UserNotPassedException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.DeploymentArtifactNotFound;
+import org.onap.dcaegen2.platform.mod.model.exceptions.msinstance.MsInstanceNotFoundException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.specification.SpecificationInvalid;
+import org.onap.dcaegen2.platform.mod.model.restapi.ErrorResponse;
+import org.onap.dcaegen2.platform.mod.model.restapi.GenericErrorResponse;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.google.gson.Gson;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.context.request.WebRequest;
+import org.springframework.web.reactive.function.client.WebClientResponseException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * a class to manage all exceptions
+ */
+@ControllerAdvice
+@Slf4j
+public class AppExceptionHandler {
+
+ @ExceptionHandler(value = {WebClientResponseException.class})
+ public ResponseEntity<ErrorResponse> handleCompSpecInvalidException
+ (WebClientResponseException ex, WebRequest request) {
+ return new ResponseEntity<ErrorResponse>
+ (new ErrorResponse(ex.getResponseBodyAsString()), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ @ExceptionHandler(value = {JsonParseException.class})
+ public ResponseEntity<GenericErrorResponse> handleJsonParsedException
+ (JsonParseException ex, WebRequest request) {
+
+ GenericErrorResponse response = new GenericErrorResponse();
+ response.setStatus(HttpStatus.BAD_REQUEST);
+ response.setMessage("Invalid JSON request body format.");
+ response.setErrors(Arrays.asList(ex.getMessage()));
+ return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<GenericErrorResponse> specificationInvalid(SpecificationInvalid ex) {
+ Map<String, Object> errorResponse = new Gson().fromJson(ex.getMessage(), Map.class);
+ GenericErrorResponse response = new GenericErrorResponse();
+ response.setMessage((String) errorResponse.get("summary"));
+ response.setStatus(HttpStatus.BAD_REQUEST);
+ response.setErrors((List<String>) errorResponse.get("errors"));
+ return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<GenericErrorResponse> missingRequestBodyException(MissingRequestBodyException ex){
+ GenericErrorResponse response = new GenericErrorResponse();
+ response.setMessage("Missing paramaters");
+ response.setStatus(HttpStatus.BAD_REQUEST);
+ response.setErrors(Arrays.asList("Missing required request body paramaters"));
+ return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<ErrorResponse> resolveUserNotPassedException(UserNotPassedException ex){
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()), HttpStatus.BAD_REQUEST);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<ErrorResponse> resolveMsInstanceNotFoundException(MsInstanceNotFoundException ex) {
+ log.error(ex.getMessage());
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()), HttpStatus.BAD_REQUEST);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<ErrorResponse> resolveDeploymentArtifactNotFound(DeploymentArtifactNotFound ex) {
+ log.error(ex.getMessage());
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()),
+ HttpStatus.BAD_REQUEST);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<ErrorResponse> resolveOperationNotAllowed(OperationNotAllowedException ex) {
+ log.error(ex.getMessage());
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()),
+ HttpStatus.CONFLICT);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<ErrorResponse> resolveResourceConflict(ResourceConflictException ex) {
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()), HttpStatus.CONFLICT);
+ }
+
+ @ExceptionHandler(value = {BaseMicroserviceNotFoundException.class})
+ public ResponseEntity<ErrorResponse> resolveResourceNotFoundExcetions(RuntimeException ex) {
+ log.error(ex.getMessage(), ex);
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()), HttpStatus.CONFLICT);
+ }
+
+ @ExceptionHandler(MethodArgumentNotValidException.class)
+ public ResponseEntity<GenericErrorResponse> resolveBeanValidationException(MethodArgumentNotValidException ex){
+ log.error(ex.getMessage());
+ GenericErrorResponse response = new GenericErrorResponse();
+ response.setMessage("Validation failed.");
+ response.setStatus(HttpStatus.BAD_REQUEST);
+ response.setErrors(getBeanValidationErrors(ex));
+ return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
+ }
+
+ private List<String> getBeanValidationErrors(MethodArgumentNotValidException ex) {
+ List<String> errors = new ArrayList<>();
+ ex.getBindingResult().getAllErrors().forEach((error) -> {
+ String fieldName = ((FieldError) error).getField();
+ String errorMessage = error.getDefaultMessage();
+ errors.add(String.format("%s: %s", fieldName, errorMessage));
+ });
+ return errors;
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/BaseMicroserviceController.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/BaseMicroserviceController.java
new file mode 100644
index 0000000..073b93a
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/BaseMicroserviceController.java
@@ -0,0 +1,70 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.controller;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceCreateRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceUpdateRequest;
+import org.onap.dcaegen2.platform.mod.web.service.basemicroservice.MsService;
+import io.swagger.annotations.Api;
+import lombok.Setter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+import static org.onap.dcaegen2.platform.mod.web.controller.BaseMicroserviceController.API_BASE_MICROSERVICE;
+
+/**
+ * Controller class to manage Microservice's REST endpoints
+ */
+@CrossOrigin
+@RestController
+@RequestMapping(API_BASE_MICROSERVICE)
+@Api(tags = "Base Microservice", description = "APIs to manage Base Microservice")
+public class BaseMicroserviceController {
+
+ public static final String API_BASE_MICROSERVICE = "/api/base-microservice";
+ @Autowired
+ @Setter
+ MsService baseMsService;
+
+ @GetMapping
+ public List<BaseMicroservice> getAll() {
+ return baseMsService.getAllMicroservices();
+ }
+
+
+ @PostMapping
+ @ResponseStatus(HttpStatus.CREATED)
+ public BaseMicroservice createMicroservice(@RequestBody @Valid MicroserviceCreateRequest request) {
+ return baseMsService.createMicroservice(request);
+ }
+
+ @PatchMapping(value = "/{msId}")
+ @ResponseStatus(HttpStatus.NO_CONTENT)
+ public void updateMicroservice(@RequestBody @Valid MicroserviceUpdateRequest request,
+ @PathVariable("msId") String msId){
+ baseMsService.updateMicroservice(msId, request);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/DeploymentArtifactController.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/DeploymentArtifactController.java
new file mode 100644
index 0000000..e1cd512
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/DeploymentArtifactController.java
@@ -0,0 +1,115 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.controller;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactSearch;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.BlueprintFileNameCreateException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.StatusChangeNotValidException;
+import org.onap.dcaegen2.platform.mod.model.restapi.DeploymentArtifactPatchRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.ErrorResponse;
+import org.onap.dcaegen2.platform.mod.model.restapi.SuccessResponse;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactService;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.onap.dcaegen2.platform.mod.web.controller.DeploymentArtifactController.DEPLOYMENT_ARTIFACTS_BASE_URL;
+
+/**
+ * Controller class to manage DeploymentArtifact's REST endpoints
+ */
+@RestController
+@CrossOrigin
+@RequestMapping(DEPLOYMENT_ARTIFACTS_BASE_URL)
+@Slf4j
+@Api(tags = "Deployment Artifact", value = "APIs to manage Deployment Artifacts")
+public class DeploymentArtifactController {
+
+ public static final String DEPLOYMENT_ARTIFACTS_BASE_URL = "/api/deployment-artifact";
+
+ public static final String GET_STATUSES = "/statuses";
+
+ @Autowired
+ private DeploymentArtifactService service;
+
+ @PostMapping("/{msInstanceId}")
+ @ResponseStatus(HttpStatus.CREATED)
+ public DeploymentArtifact generateDeploymentArtifactForMSInstance(@PathVariable String msInstanceId,
+ @RequestParam String user ){
+ return service.generateDeploymentArtifact(msInstanceId, user);
+ }
+
+ @GetMapping
+ @ResponseStatus(HttpStatus.OK)
+ public List<DeploymentArtifact> getAllDeploymentArtifacts(){
+ return service.getAllDeploymentArtifacts();
+ }
+
+ @PostMapping("/search")
+ @ResponseStatus(HttpStatus.OK)
+ public List<DeploymentArtifact> searchDeploymentArtifacts(@RequestBody DeploymentArtifactSearch searchRequest){
+ log.info("Search on deployment artifacts: {}", searchRequest);
+ return service.searchDeploymentArtifacts(searchRequest);
+ }
+
+ @GetMapping(GET_STATUSES)
+ @ResponseStatus(HttpStatus.OK)
+ public List<DeploymentArtifactStatus> getDeploymentArtifactStatuses(){
+ return Arrays.asList(DeploymentArtifactStatus.values());
+ }
+
+ @PatchMapping(value = "/{deploymentArtifactId}", params = {"user!="})
+ public ResponseEntity<SuccessResponse> patchDeploymentArtifact(@PathVariable("deploymentArtifactId") String id,
+ @RequestBody DeploymentArtifactPatchRequest deploymentArtifactPatchRequest,
+ @RequestParam("user") String user){
+ log.info("***Received request {} to update DeploymentArtifact id {} by {}", deploymentArtifactPatchRequest, id, user);
+ service.updateDeploymentArtifact(id, deploymentArtifactPatchRequest, user);
+ return new ResponseEntity<>(new SuccessResponse("Deployment Artifact was updated."),HttpStatus.OK);
+ }
+
+ @DeleteMapping( value = "/{deploymentArtifactId}", params = {"user!="})
+ public ResponseEntity<SuccessResponse> deleteDeploymentArtifact(@PathVariable("deploymentArtifactId") String id,
+ @RequestParam("user") String user){
+ log.info("***Received request to delete DeploymentArtifact id {} by {}", id, user);
+ service.deleteDeploymentArtifact(id);
+ return new ResponseEntity<>(new SuccessResponse("Deployment Artifact was deleted"), HttpStatus.OK);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<ErrorResponse> resolveBaseMsServiceNameRegex(BlueprintFileNameCreateException ex) {
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()),
+ HttpStatus.BAD_REQUEST);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<ErrorResponse> resolveStatusValidationFailure(StatusChangeNotValidException ex) {
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()),
+ HttpStatus.BAD_REQUEST);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/MicroserviceInstanceController.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/MicroserviceInstanceController.java
new file mode 100644
index 0000000..14eb154
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/MicroserviceInstanceController.java
@@ -0,0 +1,75 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.controller;
+
+import org.onap.dcaegen2.platform.mod.model.exceptions.msinstance.MsInstanceAlreadyExistsException;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.ErrorResponse;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceUpdateRequest;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * Controller class to manage MicroserviceInstance's REST endpoints
+ */
+@CrossOrigin
+@RestController
+@Api(tags = "Microservice Instance", description = "APIs to manage Microservice Instance")
+@RequestMapping("/api/microservice-instance")
+public class MicroserviceInstanceController {
+
+ @Autowired
+ MsInstanceService msInstanceService;
+
+ @GetMapping
+ @ApiOperation("Get all Microservices Instances")
+ public List<MsInstance> getAll() {
+ return msInstanceService.getAll();
+ }
+
+
+ @PostMapping("/{msName}")
+ @ApiOperation("Create a Microservice Instance")
+ @ResponseStatus(HttpStatus.CREATED)
+ public MsInstance createMsInstance(@PathVariable String msName, @RequestBody MsInstanceRequest request) {
+ return msInstanceService.createMicroserviceInstance(msName, request);
+ }
+
+ @PatchMapping("/{msId}")
+ @ApiOperation("Patch a Microservice Instance")
+ @ResponseStatus(HttpStatus.OK)
+ public MsInstance patchMsInstance(@RequestBody MsInstanceUpdateRequest request, @PathVariable String msId){
+ return msInstanceService.updateMsInstance(request, msId);
+ }
+
+ @ExceptionHandler
+ public ResponseEntity<ErrorResponse> resolveMsInstanceConflict(MsInstanceAlreadyExistsException ex) {
+ return new ResponseEntity<>(new ErrorResponse("Microservice Instance for the given name and release already exists"), HttpStatus.CONFLICT);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/SpecificationController.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/SpecificationController.java
new file mode 100644
index 0000000..854e7e6
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/controller/SpecificationController.java
@@ -0,0 +1,62 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.controller;
+
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * Controller class to manage Specification's REST endpoints
+ */
+@CrossOrigin
+@RestController
+@Api(tags = "Component Specification", description = "APIs to manage Component Specifications")
+@RequestMapping("/api/specification")
+@Slf4j
+public class SpecificationController {
+
+ @Autowired
+ SpecificationService specificationService;
+
+ @GetMapping("/{msInstanceId}")
+ @ApiOperation("Get all specifications for a Microservice Instance")
+ public List<Specification> getAllSpecsByMsInstanceId(@PathVariable String msInstanceId) {
+ log.info(msInstanceId);
+ return specificationService.getAllSpecsByMsInstanceId(msInstanceId);
+ }
+
+ @PostMapping("/{msInstanceId}")
+ @ApiOperation("Create Specification for a Microservice Instance")
+ @ResponseStatus(HttpStatus.CREATED)
+ public Specification createSpecification(@PathVariable String msInstanceId, @RequestBody SpecificationRequest request) {
+ log.info(request.toString());
+ return specificationService.createSpecification(msInstanceId, request);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/BaseMicroserviceGateway.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/BaseMicroserviceGateway.java
new file mode 100644
index 0000000..a516d90
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/BaseMicroserviceGateway.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.basemicroservice;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * An interface to interact with BaseMicroservice persistence
+ */
+public interface BaseMicroserviceGateway {
+
+ List<BaseMicroservice> findAll();
+
+ Optional<BaseMicroservice> findByName(String name);
+
+ Optional<BaseMicroservice> findByTag(String tag);
+
+ Optional<BaseMicroservice> findByServiceName(String serviceName);
+
+ BaseMicroservice save(BaseMicroservice microservice);
+
+ Optional<BaseMicroservice> findById(String msId);
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/MsService.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/MsService.java
new file mode 100644
index 0000000..cdc1921
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/MsService.java
@@ -0,0 +1,47 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.basemicroservice;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceCreateRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceUpdateRequest;
+
+import java.util.List;
+
+/**
+ * An interface to access Ms Services
+ */
+public interface MsService {
+ BaseMicroservice createMicroservice(MicroserviceCreateRequest microserviceRequest);
+
+ List<BaseMicroservice> getAllMicroservices();
+
+ BaseMicroservice getMicroserviceById(String baseMsId);
+
+ BaseMicroservice getMicroserviceByName(String msName);
+
+ void updateMicroservice(String requestedMsId, MicroserviceUpdateRequest updateRequest);
+
+ void saveMsInstanceReferenceToMs(BaseMicroservice microservice, MsInstance msInstance);
+
+ void updateMsInstanceRef(MsInstance msInstance);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/MsServiceImpl.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/MsServiceImpl.java
new file mode 100644
index 0000000..9cf46e6
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/basemicroservice/MsServiceImpl.java
@@ -0,0 +1,257 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.basemicroservice;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsStatus;
+import org.onap.dcaegen2.platform.mod.model.common.AuditFields;
+import org.onap.dcaegen2.platform.mod.model.exceptions.ErrorMessages;
+import org.onap.dcaegen2.platform.mod.model.exceptions.ResourceConflictException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.basemicroservice.BaseMicroserviceNotFoundException;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceCreateRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceUpdateRequest;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import lombok.Setter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * MsService implementation
+ */
+@Service
+public class MsServiceImpl implements MsService {
+
+ @Autowired
+ @Setter
+ private BaseMicroserviceGateway repository;
+
+ @Autowired
+ @Setter
+ private MsInstanceService msInstanceService;
+
+ /**
+ * creates Microservice record
+ * @param microserviceRequest
+ * @return
+ */
+ @Override
+ public BaseMicroservice createMicroservice(MicroserviceCreateRequest microserviceRequest) {
+ checkIfThereAreAnyConflicts(microserviceRequest); //TODO: Make fields unique in entity itself
+ BaseMicroservice microservice = new BaseMsCreator().create(microserviceRequest);
+ return repository.save(microservice);
+ }
+
+ /**
+ * name, tag and serviceName are unique for the given ms. This method make sure that.
+ * */
+ private void checkIfThereAreAnyConflicts(MicroserviceCreateRequest microserviceRequest) {
+ checkIfMsNameAlreadyExists(microserviceRequest.getName());
+ checkIfMsTagAlreadyExists(microserviceRequest.getTag());
+ checkiIfServiceNameAlreadyExists(microserviceRequest.getServiceName());
+ }
+
+ private void checkIfMsNameAlreadyExists(String msName) {
+ if (repository.findByName(msName).isPresent())
+ throw new ResourceConflictException(ErrorMessages.MICROSERVICE_NAME_CONFLICT_MESSAGE);
+ }
+
+ private void checkIfMsTagAlreadyExists(String msTag) {
+ if (repository.findByTag(msTag).isPresent())
+ throw new ResourceConflictException(ErrorMessages.MICROSERVICE_TAG_CONFLICT_MESSAGE);
+ }
+
+ private void checkiIfServiceNameAlreadyExists(String serviceName) {
+ boolean serviceNameIsEmpty = serviceName == null || serviceName.isEmpty();
+ if(serviceNameIsEmpty)
+ return;
+ if (repository.findByServiceName(serviceName).isPresent())
+ throw new ResourceConflictException(ErrorMessages.MS_SERVICE_NAME_CONFLICT_MESSAGE);
+ }
+
+ /**
+ * lists all microservice records
+ * @return
+ */
+ @Override
+ public List<BaseMicroservice> getAllMicroservices() {
+ return repository.findAll();
+ }
+
+ /**
+ * gets a Mioroservice by id
+ * @param baseMsId
+ * @return
+ */
+ @Override
+ public BaseMicroservice getMicroserviceById(String baseMsId) {
+ return repository.findById(baseMsId).orElseThrow(() ->
+ new BaseMicroserviceNotFoundException(String.format("Microservice with id %s not found", baseMsId)));
+ }
+
+ /**
+ * gets a Microservice by name
+ * @param msName
+ * @return
+ */
+ @Override
+ public BaseMicroservice getMicroserviceByName(String msName) {
+ return repository.findByName(msName).orElseThrow(() ->
+ new BaseMicroserviceNotFoundException(String.format("Microservice with name %s not found", msName)));
+ }
+
+ /**
+ * updates a Microservice
+ * @param requestedMsId
+ * @param updateRequest
+ */
+ @Override
+ public void updateMicroservice(String requestedMsId, MicroserviceUpdateRequest updateRequest) {
+ BaseMicroservice microservice = getMicroserviceById(requestedMsId);
+ updateMetadata(updateRequest, microservice);
+ updateOtherFields(updateRequest, microservice);
+ repository.save(microservice);
+ msInstanceService.updateMicroserviceReference(microservice);
+ }
+
+ //TODO: Get rid of nulls!
+ private void updateMetadata(MicroserviceUpdateRequest updateRequest, BaseMicroservice microservice) {
+ if(updateRequest.getUser() != null){
+ microservice.getMetadata().setUpdatedBy(updateRequest.getUser());
+ }
+ if(updateRequest.getMetadata() != null && updateRequest.getMetadata().containsKey("notes")){
+ microservice.getMetadata().setNotes((String) updateRequest.getMetadata().get("notes"));
+ }
+ if(updateRequest.getMetadata() != null && updateRequest.getMetadata().containsKey("labels")){
+ microservice.getMetadata().setLabels((List<String>) updateRequest.getMetadata().get("labels"));
+ }
+ microservice.getMetadata().setUpdatedOn(new Date());
+ }
+
+ private void updateOtherFields(MicroserviceUpdateRequest updateRequest, BaseMicroservice microservice) {
+ if(updateRequest.getName() != null){
+ updateName(updateRequest, microservice);
+ }
+ if(updateRequest.getType() != null){
+ microservice.setType(updateRequest.getType());
+ }
+ if(updateRequest.getLocation() != null){
+ microservice.setLocation(updateRequest.getLocation());
+ }
+ if(updateRequest.getServiceName() != null){
+ updateServiceName(updateRequest, microservice);
+ }
+ if(updateRequest.getNamespace() != null){
+ microservice.setNamespace(updateRequest.getNamespace());
+ }
+ }
+
+ /**
+ * If name requested in the updateRequest doesn't match the name of the ms record which is being worked on,
+ * then only check for the uniqueness.
+ */
+ private void updateName(MicroserviceUpdateRequest updateRequest, BaseMicroservice microservice) {
+ boolean notMatchesWithCurrentName = !updateRequest.getName().equals(microservice.getName());
+ if(notMatchesWithCurrentName)
+ checkIfMsNameAlreadyExists(updateRequest.getName());
+ microservice.setName(updateRequest.getName());
+ }
+
+ /**
+ * If serviceName requested in the updateRequest doesn't match the serviceName of the ms record which is
+ * being worked on, then only check for the uniqueness.
+ */
+ private void updateServiceName(MicroserviceUpdateRequest updateRequest, BaseMicroservice microservice) {
+ boolean notMatchesWithCurrentServiceName = !updateRequest.getServiceName().equals(microservice.getServiceName());
+ if(notMatchesWithCurrentServiceName)
+ checkiIfServiceNameAlreadyExists(updateRequest.getServiceName());
+ microservice.setServiceName(updateRequest.getServiceName());
+ }
+
+ /**
+ * saves msInstance reference in a given Microservice
+ * @param microservice
+ * @param msInstance
+ */
+ @Override
+ public void saveMsInstanceReferenceToMs(BaseMicroservice microservice, MsInstance msInstance) {
+ microservice.getMsInstances().add(getMsInstanceReference(msInstance));
+ repository.save(microservice);
+ }
+
+ /**
+ * updates MsIntstance ref in Microservice record
+ * @param msInstance
+ */
+ @Override
+ public void updateMsInstanceRef(MsInstance msInstance) {
+ BaseMicroservice microservice = getMicroserviceById((String) msInstance.getMsInfo().get("id"));
+ List<Map<String, String>> msInstancesRef = microservice.getMsInstances();
+ msInstancesRef.forEach((ref) -> {
+ if(ref.get("id").equals(msInstance.getId()))
+ ref.put("name", msInstance.getName());
+ });
+ repository.save(microservice);
+ }
+
+ private Map<String, String> getMsInstanceReference(MsInstance msInstance) {
+ Map<String,String> msInstanceInfo = new HashMap<>();
+ msInstanceInfo.put("id", msInstance.getId());
+ msInstanceInfo.put("name", msInstance.getName());
+ return msInstanceInfo;
+ }
+
+ private class BaseMsCreator {
+
+ BaseMicroservice create(MicroserviceCreateRequest createRequest) {
+ BaseMicroservice microservice = new BaseMicroservice();
+ microservice.setLocation(createRequest.getLocation());
+ microservice.setName(createRequest.getName());
+ microservice.setTag(createRequest.getTag());
+ microservice.setServiceName(createRequest.getServiceName());
+ microservice.setNamespace(createRequest.getNamespace());
+ microservice.setStatus(BaseMsStatus.ACTIVE);
+ microservice.setType(createRequest.getType());
+ microservice.setMetadata(getMetadataFields(createRequest));
+ return microservice;
+ }
+
+ private AuditFields getMetadataFields(MicroserviceCreateRequest request) {
+ AuditFields auditFields = AuditFields.builder().build();
+ auditFields.setCreatedBy(request.getUser());
+ auditFields.setCreatedOn(new Date());
+
+ if (request.getMetadata().containsKey("notes"))
+ auditFields.setNotes((String) request.getMetadata().get("notes"));
+ if (request.getMetadata().containsKey("labels"))
+// auditFields.setLabels((List<String>) request.getMetadata().get("labels"));
+ auditFields.setLabels(request.getMetadata().get("labels"));
+
+ return auditFields;
+
+ }
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/ArtifactFileNameCreator.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/ArtifactFileNameCreator.java
new file mode 100644
index 0000000..7713020
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/ArtifactFileNameCreator.java
@@ -0,0 +1,59 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.BlueprintFileNameCreateException;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.springframework.stereotype.Component;
+
+/**
+ * A name creator for Deployment Artifact files.
+ */
+@Component
+public class ArtifactFileNameCreator {
+
+ private static final String FILE_FORMAT = ".yaml";
+
+ /**
+ * creates a file name
+ * @param msInstance
+ * @param version
+ * @return
+ */
+ public String createFileName(MsInstance msInstance, int version) {
+ if(msInstance.getMsInfo() == null || !msInstance.getMsInfo().containsKey("tag")){
+ throwException("MS-tag");
+ }
+ if(msInstance.getActiveSpec() == null){
+ throwException("active-spec");
+ }
+ return msInstance.getMsInfo().get("tag") + "_"
+ + msInstance.getActiveSpec().getType().toString().toLowerCase() + "_"
+ + msInstance.getRelease() + "_"
+ + version
+ + FILE_FORMAT;
+ }
+
+ private void throwException(String missingProperty) {
+ throw new BlueprintFileNameCreateException("Can not create bluerprint file name: "
+ + missingProperty + " is missing");
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactGateway.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactGateway.java
new file mode 100644
index 0000000..6bf2c2a
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactGateway.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactSearch;
+
+import java.util.List;
+import java.util.Optional;
+
+ /**
+ * An interface to interact with DeploymentArtifact persistence
+ */
+public interface DeploymentArtifactGateway {
+
+ List<DeploymentArtifact> findAll();
+
+ List<DeploymentArtifact> findByMsInstanceId(String id);
+
+ Optional<DeploymentArtifact> findById(String id);
+
+ void deleteById(String deploymentArtifactId);
+
+ DeploymentArtifact save(DeploymentArtifact deploymentArtifact);
+
+ List<DeploymentArtifact> findAll(DeploymentArtifactSearch search);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactGeneratorStrategy.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactGeneratorStrategy.java
new file mode 100644
index 0000000..9bb0870
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactGeneratorStrategy.java
@@ -0,0 +1,32 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+
+import java.util.Map;
+
+/**
+ * provides abstraction to generate Deployment Artifacts
+ */
+public interface DeploymentArtifactGeneratorStrategy {
+ Map<String, Object> generateForRelease(Specification activeSpec, String release);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactService.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactService.java
new file mode 100644
index 0000000..3e7f899
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactService.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactSearch;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.DeploymentArtifactPatchRequest;
+
+import java.util.List;
+
+/**
+ * An interface to access DeploymentArtifact Services
+ */
+public interface DeploymentArtifactService {
+
+ DeploymentArtifact generateDeploymentArtifact(String msInstanceId, String user);
+
+ List<DeploymentArtifact> getAllDeploymentArtifacts();
+
+ DeploymentArtifact findDeploymentArtifactById(String id);
+
+ void updateDeploymentArtifact(String deploymentArtifactId, DeploymentArtifactPatchRequest deploymentArtifactPatchRequest, String user);
+
+ List<DeploymentArtifact> findByMsInstanceId(String msInstanceId);
+
+ void deleteDeploymentArtifact(String deploymentArtifactId);
+
+ void updateMsInstanceRef(MsInstance msInstance);
+
+ List<DeploymentArtifact> searchDeploymentArtifacts(DeploymentArtifactSearch search);
+}
+
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImpl.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImpl.java
new file mode 100644
index 0000000..8b97bba
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImpl.java
@@ -0,0 +1,205 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactSearch;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.MsInstanceInfo;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.DeploymentArtifactNotFound;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.DeploymentArtifactsRef;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.DeploymentArtifactPatchRequest;
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+
+/**
+ * DeploymentArtifact Service implementation
+ */
+@Service
+@Slf4j
+@Setter
+public class DeploymentArtifactServiceImpl implements DeploymentArtifactService{
+
+ private static final String VERSION_KEY = "mostRecentVersion";
+
+ @Autowired
+ private MsInstanceService msInstanceService;
+
+ @Autowired
+ private DeploymentArtifactGeneratorStrategy deploymentArtifactGeneratorStrategy;
+
+ @Autowired
+ private DeploymentArtifactGateway deploymentArtifactGateway;
+
+ @Autowired
+ private ArtifactFileNameCreator fileNameCreator;
+
+ @Autowired
+ private DeploymentArtifactStatusChangeHandler statusChangeHandler;
+
+ ///////////////FIND METHODS//////////////////////////
+ @Override
+ public List<DeploymentArtifact> getAllDeploymentArtifacts() {
+ return deploymentArtifactGateway.findAll();
+ }
+
+ @Override
+ public List<DeploymentArtifact> searchDeploymentArtifacts(DeploymentArtifactSearch search) {
+ return deploymentArtifactGateway.findAll(search);
+ }
+
+ @Override
+ public DeploymentArtifact findDeploymentArtifactById(String id){
+ return deploymentArtifactGateway.findById(id).orElseThrow(
+ () -> new DeploymentArtifactNotFound("Deployment Artifact with id " + id + " not found")
+ );
+ }
+
+ @Override
+ public List<DeploymentArtifact> findByMsInstanceId(String msInstanceId) {
+ return deploymentArtifactGateway.findByMsInstanceId(msInstanceId);
+ }
+
+ @Override
+ @Transactional
+ public void deleteDeploymentArtifact(String deploymentArtifactId) {
+ DeploymentArtifact deploymentArtifact = findDeploymentArtifactById(deploymentArtifactId);
+ log.info("deleting {}", deploymentArtifact.getFileName());
+ deploymentArtifactGateway.deleteById(deploymentArtifactId);
+ msInstanceService.removeDeploymentArtifactFromMsInstance(deploymentArtifact);
+ }
+
+ @Override
+ @Transactional
+ public void updateMsInstanceRef(MsInstance msInstance) {
+ List<DeploymentArtifact> deploymentArtifacts = findByMsInstanceId(msInstance.getId());
+ deploymentArtifacts.forEach((deploymentArtifact) -> {
+ deploymentArtifact.getMsInstanceInfo().setName(msInstance.getName());
+ deploymentArtifact.getMsInstanceInfo().setRelease(msInstance.getRelease());
+ deploymentArtifactGateway.save(deploymentArtifact);
+ });
+ }
+
+ //////////////////////////////////////////////////////
+
+ @Override
+ @Transactional
+ //only status update was implemented
+ public void updateDeploymentArtifact(String deploymentArtifactId, DeploymentArtifactPatchRequest deploymentArtifactPatchRequest,
+ String user) {
+ DeploymentArtifact deploymentArtifact = findDeploymentArtifactById(deploymentArtifactId);
+ updateStatus(deploymentArtifactPatchRequest, deploymentArtifact);
+ updateMetadata(user, deploymentArtifact);
+ log.info("Updating the artifact in database..");
+ deploymentArtifactGateway.save(deploymentArtifact);
+ msInstanceService.updateStatusBasedOnDeploymentArtifactsStatuses(deploymentArtifact.getMsInstanceInfo().getId());
+ }
+
+ private void updateMetadata(String user, DeploymentArtifact deploymentArtifact) {
+ deploymentArtifact.getMetadata().put("updatedBy", user);
+ deploymentArtifact.getMetadata().put("updatedOn", new Date());
+ }
+
+ private void updateStatus(DeploymentArtifactPatchRequest deploymentArtifactPatchRequest, DeploymentArtifact deploymentArtifact) {
+ DeploymentArtifactStatus changeToStatus = deploymentArtifactPatchRequest.getStatus();
+ if(changeToStatus != null){
+ log.info("Sent request to deployment artifact status change handler: {}", changeToStatus);
+ statusChangeHandler.handleStatusChange(changeToStatus, deploymentArtifact);
+ }
+ }
+
+ @Override
+ @Transactional
+ public DeploymentArtifact generateDeploymentArtifact(String msInstanceId, String user) {
+ MsInstance msInstance = msInstanceService.getMsInstanceById(msInstanceId);
+
+ //Generate the Blueprint for the active specification for the instance
+ Map<String, Object> deploymentArtifact = deploymentArtifactGeneratorStrategy.generateForRelease(msInstance.getActiveSpec(), msInstance.getRelease());
+
+ DeploymentArtifact artifact = new DeploymentArtifact();
+ artifact.setContent(String.valueOf(deploymentArtifact.get("content")));
+ artifact.setVersion(updateLatestVersion(msInstance.getDeploymentArtifactsInfo()));
+ artifact.setStatus(DeploymentArtifactStatus.IN_DEV);
+ artifact.setMsInstanceInfo(createMsInstanceReferenceInfo(msInstance));
+ artifact.setSpecificationInfo(createSpecificationReferenceInfo(msInstance.getActiveSpec()));
+ artifact.setMetadata(createMetadata(user));
+
+ artifact.setFileName(fileNameCreator.createFileName(msInstance, artifact.getVersion()));
+
+ DeploymentArtifact savedDao = deploymentArtifactGateway.save(artifact);
+ artifact.setId(savedDao.getId());
+
+ msInstance.setDeploymentArtifactsInfo(updateMsDeploymentArtifactRef(msInstance.getDeploymentArtifactsInfo(), savedDao.getId()));
+ msInstanceService.updateMsInstance(msInstance);
+
+ return artifact;
+ }
+
+ private int updateLatestVersion(DeploymentArtifactsRef ref) {
+ if(ref == null) return 1;
+ else return ref.getMostRecentVersion() + 1;
+ }
+
+ private DeploymentArtifactsRef updateMsDeploymentArtifactRef(DeploymentArtifactsRef ref, String deploymentArtifactId) {
+ if(ref == null){
+ ref = new DeploymentArtifactsRef();
+ ref.setMostRecentVersion(1);
+ List<String> deploymentArtifacts = new ArrayList<>();
+ deploymentArtifacts.add(deploymentArtifactId);
+ ref.setDeploymentArtifacts(deploymentArtifacts);
+ }
+ else{
+ ref.setMostRecentVersion(ref.getMostRecentVersion() + 1);
+ List<String> deploymentArtifactList = ref.getDeploymentArtifacts();
+ deploymentArtifactList.add(deploymentArtifactId);
+ }
+ return ref;
+ }
+
+ private Map<String, Object> createMetadata(String user) {
+ Map<String, Object> metadata = new HashMap<>();
+ metadata.put("createdOn", new Date());
+ metadata.put("createdBy", user);
+ return metadata;
+ }
+
+ private Map<String, Object> createSpecificationReferenceInfo(Specification activeSpec) {
+ Map<String, Object> specInfo = new HashMap<>();
+ specInfo.put("id", activeSpec.getId());
+ return specInfo;
+ }
+
+ private MsInstanceInfo createMsInstanceReferenceInfo(MsInstance msInstance) {
+ MsInstanceInfo msInstanceInfo = new MsInstanceInfo();
+ msInstanceInfo.setId(msInstance.getId());
+ msInstanceInfo.setName(msInstance.getName());
+ msInstanceInfo.setRelease(msInstance.getRelease());
+ return msInstanceInfo;
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactStatusChangeHandler.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactStatusChangeHandler.java
new file mode 100644
index 0000000..48b18bf
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactStatusChangeHandler.java
@@ -0,0 +1,77 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.StatusChangeNotValidException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * A class responsible for handling status changes of Deployment Artifacts
+ */
+@Component
+@Slf4j
+public class DeploymentArtifactStatusChangeHandler {
+
+ @Autowired
+ DeploymentArtifactService deploymentArtifactService;
+
+ /**
+ * setter
+ * @param deploymentArtifactService
+ */
+ public void setDeploymentArtifactService(DeploymentArtifactService deploymentArtifactService) {
+ this.deploymentArtifactService = deploymentArtifactService;
+ }
+
+ /**
+ * handles status changes
+ * @param status
+ * @param deploymentArtifact
+ */
+ public void handleStatusChange(DeploymentArtifactStatus status, DeploymentArtifact deploymentArtifact) {
+ String msInstanceId = deploymentArtifact.getMsInstanceInfo().getId();
+ List<DeploymentArtifact> artifacts = deploymentArtifactService.findByMsInstanceId(msInstanceId);
+ if( status == DeploymentArtifactStatus.DEV_COMPLETE){
+ for(DeploymentArtifact artifact : artifacts){
+ if(artifact.getStatus() == DeploymentArtifactStatus.DEV_COMPLETE){
+ log.error("Status change is not allowed.");
+ throw new StatusChangeNotValidException(createValidationErrorMessage(deploymentArtifact));
+ }
+ }
+ }
+ deploymentArtifact.setStatus(status);
+ log.info("Deployment Artifact's status changed successfully.");
+ }
+
+ private String createValidationErrorMessage(DeploymentArtifact artifact) {
+ return String.format( "%s (v%d) for %s - Status change not allowed."
+ + " Only 1 blueprint can be in the DEV_COMPLETE state. " +
+ "Change the current DEV_COMPLETE blueprint to NOT_NEEDED or IN_DEV before changing another"
+ + " to DEV_COMPLETE.", artifact.getMsInstanceInfo().getName(),
+ artifact.getVersion(), artifact.getMsInstanceInfo().getRelease());
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceGateway.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceGateway.java
new file mode 100644
index 0000000..12a510a
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceGateway.java
@@ -0,0 +1,40 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.microserviceinstance;
+
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * An interface to interact with MsInstance persistence
+ */
+public interface MsInstanceGateway {
+
+ Optional<MsInstance> findByNameAndRelease(String name, String release);
+
+ Optional<MsInstance> findById(String msInstanceId);
+
+ List<MsInstance> findAll();
+
+ MsInstance save(MsInstance msInstance);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceService.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceService.java
new file mode 100644
index 0000000..3c28f4d
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceService.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.microserviceinstance;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceUpdateRequest;
+
+import java.util.List;
+
+/**
+ * An interface to access MsInstance Services
+ */
+public interface MsInstanceService {
+
+ List<MsInstance> getAll();
+
+ MsInstance createMicroserviceInstance(String msName, MsInstanceRequest request);
+
+ MsInstance getMsInstanceById(String id);
+
+ void updateMsInstance(MsInstance msInstance);
+
+ void updateStatusBasedOnDeploymentArtifactsStatuses(String msInstanceId);
+
+ void removeDeploymentArtifactFromMsInstance(DeploymentArtifact deploymentArtifact);
+
+ void updateMicroserviceReference(BaseMicroservice msToBeUpdated);
+
+ MsInstance updateMsInstance(MsInstanceUpdateRequest updateRequest, String msInstanceId);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceServiceImpl.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceServiceImpl.java
new file mode 100644
index 0000000..e4d5694
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceServiceImpl.java
@@ -0,0 +1,213 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.microserviceinstance;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.exceptions.msinstance.MsInstanceAlreadyExistsException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.msinstance.MsInstanceNotFoundException;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstanceStatus;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceUpdateRequest;
+import org.onap.dcaegen2.platform.mod.web.service.basemicroservice.MsService;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactService;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationService;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * MsInstance Service implementation
+ */
+@Service
+@Setter
+@Slf4j
+public class MsInstanceServiceImpl implements MsInstanceService {
+
+ @Autowired
+ private MsInstanceGateway msInstanceRepository;
+
+ @Autowired
+ private MsService msService;
+
+ @Autowired
+ private MsInstanceStatusChangeHandler msInstanceStatusChangeHandler;
+
+ @Autowired
+ private SpecificationService specificationService;
+
+ @Autowired
+ private DeploymentArtifactService deploymentArtifactService;
+
+ @Override
+ public List<MsInstance> getAll() {
+ return msInstanceRepository.findAll();
+ }
+
+ @Override
+ @Transactional
+ public MsInstance createMicroserviceInstance(String msName, MsInstanceRequest request) {
+ BaseMicroservice microservice = msService.getMicroserviceByName(msName);
+ checkIftheCombinationOfNameAndReleaseIsUnique(request.getName(), request.getRelease());
+ MsInstance msInstance = new MsInstanceCreator(request, microservice).create();
+ MsInstance savedMsInstance = msInstanceRepository.save(msInstance);
+ msService.saveMsInstanceReferenceToMs(microservice, savedMsInstance);
+ return savedMsInstance;
+ }
+
+ private void checkIftheCombinationOfNameAndReleaseIsUnique(String name, String release) {
+ if (msInstanceRepository.findByNameAndRelease(name, release).isPresent())
+ throw new MsInstanceAlreadyExistsException();
+ }
+
+ @Override
+ public MsInstance getMsInstanceById(String id) {
+ return msInstanceRepository.findById(id).orElseThrow(() ->
+ new MsInstanceNotFoundException(String.format("Ms Instance with id %s not found", id)));
+ }
+
+ @Override
+ public void updateMsInstance(MsInstance msInstance) {
+ log.info("Saving the msInstance {} to database..", msInstance);
+ if(msInstance != null) msInstanceRepository.save(msInstance);
+ }
+
+ @Override
+ public void updateStatusBasedOnDeploymentArtifactsStatuses(String msInstanceId) {
+ MsInstance msInstance = getMsInstanceById(msInstanceId);
+ msInstanceStatusChangeHandler.updateStatusBasedOnDeploymentArtifactsStatuses(msInstance);
+ updateMsInstance(msInstance);
+ }
+
+ @Override
+ @Transactional
+ public void removeDeploymentArtifactFromMsInstance(DeploymentArtifact deploymentArtifact) {
+ MsInstance msInstance = getMsInstanceById(deploymentArtifact.getMsInstanceInfo().getId());
+ removeDeploymentArtifactReferenceFromMsInstance(msInstance, deploymentArtifact.getId());
+ msInstanceStatusChangeHandler.updateStatusBasedOnDeploymentArtifactsStatuses(msInstance);
+ updateMsInstance(msInstance);
+ }
+
+ @Override
+ //TODO: update msInstanceReference in specification and deployment artifact
+ public void updateMicroserviceReference(BaseMicroservice microservice) {
+ List<Map<String, String>> msInstanceRefs = microservice.getMsInstances();
+ for(Map<String, String> ref : msInstanceRefs){
+ MsInstance msInstance = getMsInstanceById(ref.get("id"));
+ msInstance.setName(microservice.getName());
+ msInstance.getMsInfo().put("name", microservice.getName());
+ cascadeUpdates(msInstance);
+ msInstanceRepository.save(msInstance);
+ }
+ }
+
+ @Override
+ @Transactional
+ public MsInstance updateMsInstance(MsInstanceUpdateRequest updateRequest, String msInstanceId) {
+ MsInstance msInstance = getMsInstanceById(msInstanceId);
+ updateRelease(updateRequest, msInstance);
+ updateVersion(updateRequest, msInstance);
+ updateMetadata(updateRequest, msInstance);
+ cascadeUpdates(msInstance);
+ return msInstanceRepository.save(msInstance);
+ }
+
+ private void cascadeUpdates(MsInstance msInstance) {
+ specificationService.updateMsInstanceRef(msInstance);
+ deploymentArtifactService.updateMsInstanceRef(msInstance);
+ msService.updateMsInstanceRef(msInstance);
+ }
+
+ private void updateMetadata(MsInstanceUpdateRequest updateRequest, MsInstance msInstance) {
+ if(updateRequest.getMetadata() != null){
+ msInstance.getMetadata().putAll(updateRequest.getMetadata());
+ }
+
+ msInstance.getMetadata().put("updatedOn", new Date());
+ msInstance.getMetadata().put("updatedBy", updateRequest.getUser());
+ }
+
+ private void updateVersion(MsInstanceUpdateRequest updateRequest, MsInstance msInstance) {
+ if(updateRequest.getVersion() != null){
+ msInstance.setVersion(updateRequest.getVersion());
+ }
+ }
+
+ private void updateRelease(MsInstanceUpdateRequest updateRequest, MsInstance msInstance) {
+ if(updateRequest.getRelease() != null) {
+ if(!updateRequest.getRelease().equals(msInstance.getRelease()))
+ checkIftheCombinationOfNameAndReleaseIsUnique(msInstance.getName(), updateRequest.getRelease());
+ msInstance.setRelease(updateRequest.getRelease());
+ }
+ }
+
+ private void removeDeploymentArtifactReferenceFromMsInstance(MsInstance msInstance, String deploymentArtifactId) {
+ if(msInstance.getDeploymentArtifactsInfo() != null){
+ List<String> refIds = msInstance.getDeploymentArtifactsInfo().getDeploymentArtifacts();
+ refIds.remove(deploymentArtifactId);
+ }
+ }
+
+ private class MsInstanceCreator {
+ private MsInstanceRequest request;
+ private BaseMicroservice microserviceDAO;
+
+ MsInstanceCreator(MsInstanceRequest request, BaseMicroservice microserviceDAO) {
+ this.request = request;
+ this.microserviceDAO = microserviceDAO;
+ }
+
+ MsInstance create() {
+ //prepare MsInstance from the request
+ return MsInstance.builder()
+ .name(request.getName())
+ .release(request.getRelease())
+ .status(MsInstanceStatus.NEW)
+ .version(request.getVersion())
+ .msInfo(getMsReference(microserviceDAO))
+ .metadata(getMetadata(request))
+ .build();
+ }
+
+ private Map<String, Object> getMsReference(BaseMicroservice microserviceDAO) {
+ Map<String,Object> msInfo = new HashMap<>();
+ msInfo.put("id", microserviceDAO.getId());
+ msInfo.put("name", microserviceDAO.getName());
+ msInfo.put("tag", microserviceDAO.getTag());
+ return msInfo;
+ }
+
+ private Map<String, Object> getMetadata(MsInstanceRequest request) {
+ Map<String, Object> metadata = request.getMetadata();
+ metadata.put("createdBy", request.getUser());
+ metadata.put("createdOn", new Date());
+ return metadata;
+ }
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceStatusChangeHandler.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceStatusChangeHandler.java
new file mode 100644
index 0000000..bc26fab
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/microserviceinstance/MsInstanceStatusChangeHandler.java
@@ -0,0 +1,75 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.microserviceinstance;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstanceStatus;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * A class responsible for handling status changes of Ms Instances
+ */
+@Component
+@Slf4j
+public class MsInstanceStatusChangeHandler {
+
+ @Autowired
+ private MsInstanceService msInstanceService;
+
+ @Autowired
+ private DeploymentArtifactService deploymentArtifactService;
+
+ public void setMsInstanceService(MsInstanceService msInstanceService) {
+ this.msInstanceService = msInstanceService;
+ }
+
+ public void setDeploymentArtifactService(DeploymentArtifactService deploymentArtifactService) {
+ this.deploymentArtifactService = deploymentArtifactService;
+ }
+
+ public void updateStatusBasedOnDeploymentArtifactsStatuses(MsInstance msInstance) {
+ log.info("Checking if any Status change required for msInstance {}...", msInstance);
+ List<DeploymentArtifact> artifacts = deploymentArtifactService.findByMsInstanceId(msInstance.getId());
+ MsInstanceStatus newStatus = getValidStatusBasedOnArtifacts(artifacts);
+ msInstance.setStatus(newStatus);
+ log.info("Changed Status to {}", newStatus);
+ }
+
+ private MsInstanceStatus getValidStatusBasedOnArtifacts(List<DeploymentArtifact> artifacts) {
+ if(atLeastOneArtifactHasDevCompleteStatus(artifacts)){
+ return MsInstanceStatus.DEV_COMPLETE;
+ }
+ return MsInstanceStatus.IN_DEV;
+ }
+
+ private boolean atLeastOneArtifactHasDevCompleteStatus(List<DeploymentArtifact> artifacts) {
+ return artifacts
+ .stream()
+ .anyMatch(artifact -> artifact.getStatus() == DeploymentArtifactStatus.DEV_COMPLETE);
+ }
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationGateway.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationGateway.java
new file mode 100644
index 0000000..5fcfbb1
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationGateway.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.specification;
+
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * An interface to interact with Specification persistence
+ */
+@Repository
+public interface SpecificationGateway{
+
+ List<Specification> getSpecificationByMsInstanceId(String id);
+
+ Specification save(Specification newSpec);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationService.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationService.java
new file mode 100644
index 0000000..33724ac
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationService.java
@@ -0,0 +1,40 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.specification;
+
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+
+import java.util.List;
+
+/**
+ * An interface to access Specification Services
+ */
+public interface SpecificationService {
+
+ List<Specification> getAllSpecsByMsInstanceId(String id);
+
+ Specification createSpecification(String msInstanceId, SpecificationRequest request);
+
+ void updateMsInstanceRef(MsInstance msInstance);
+}
+
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationServiceImpl.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationServiceImpl.java
new file mode 100644
index 0000000..7869801
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationServiceImpl.java
@@ -0,0 +1,138 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.specification;
+
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstanceStatus;
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.onap.dcaegen2.platform.mod.model.specification.SpecificationStatus;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import lombok.Setter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Specification Service implementation
+ */
+@Service
+@Setter
+public class SpecificationServiceImpl implements SpecificationService {
+
+ @Autowired
+ private SpecificationGateway specificationGateway;
+
+ @Autowired
+ private MsInstanceService msInstanceService;
+
+ @Autowired
+ private SpecificationValidatorService specificationValidatorService;
+
+ /**
+ * Lists all Ms Instances
+ * @param id
+ * @return
+ */
+ @Override
+ public List<Specification> getAllSpecsByMsInstanceId(String id) {
+ return specificationGateway.getSpecificationByMsInstanceId(id);
+ }
+
+ /**
+ * creates a Specification
+ * @param msInstanceId
+ * @param request
+ * @return
+ */
+ @Override
+ @Transactional
+ public Specification createSpecification(String msInstanceId, SpecificationRequest request) {
+ MsInstance msInstance = msInstanceService.getMsInstanceById(msInstanceId);
+ specificationValidatorService.validateSpecForRelease(request, msInstance.getRelease());
+ Specification newSpec = createSpecification(request, msInstance);
+ makePreviousSpecInactive(msInstance);
+ Specification savedSpec = specificationGateway.save(newSpec);
+ updateMsInstance(msInstance, savedSpec);
+ return savedSpec;
+ }
+
+ private Specification createSpecification(SpecificationRequest request, MsInstance msInstance) {
+ return Specification.builder()
+ .status(SpecificationStatus.ACTIVE)
+ .specContent(request.getSpecContent())
+ .policyJson(request.getPolicyJson())
+ .type(request.getType())
+ .metadata(getMetadata(request))
+ .msInstanceInfo(buildMsInstanceInfo(msInstance))
+ .build();
+ }
+
+ private void updateMsInstance(MsInstance msInstance, Specification savedSpecification) {
+ msInstance.setActiveSpec(savedSpecification);
+ msInstance.setStatus(MsInstanceStatus.IN_DEV);
+ msInstanceService.updateMsInstance(msInstance);
+ }
+
+ private void makePreviousSpecInactive(MsInstance msInstance) {
+ if (msInstance.getActiveSpec() != null) {
+ msInstance.getActiveSpec().setStatus(SpecificationStatus.INACTIVE);
+ specificationGateway.save(msInstance.getActiveSpec());
+ }
+ }
+
+ private Map<String, Object> getMetadata(SpecificationRequest request) {
+ Map<String, Object> metadata = request.getMetadata();
+ metadata.put("createdBy", request.getUser());
+ metadata.put("createdOn", new Date());
+ return metadata;
+ }
+
+ private Map<String, Object> buildMsInstanceInfo(MsInstance msInstance) {
+ Map<String, Object> msInstanceInfo = new HashMap<>();
+ msInstanceInfo.put("id", msInstance.getId());
+ msInstanceInfo.put("name", msInstance.getName());
+ msInstanceInfo.put("release", msInstance.getRelease());
+ return msInstanceInfo;
+ }
+
+ /**
+ * Updates a MsInstance reference in a Specification record
+ * @param msInstance
+ */
+ @Override
+ @Transactional
+ public void updateMsInstanceRef(MsInstance msInstance) {
+ List<Specification> specifications = getAllSpecsByMsInstanceId(msInstance.getId());
+ specifications.forEach((specification) ->{
+ specification.getMsInstanceInfo().put("name", msInstance.getName());
+ specification.getMsInstanceInfo().put("release", msInstance.getRelease());
+ specificationGateway.save(specification);
+ });
+ }
+
+
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationValidationStratergy.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationValidationStratergy.java
new file mode 100644
index 0000000..58eff19
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationValidationStratergy.java
@@ -0,0 +1,30 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.specification;
+
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+
+/**
+ * Abstraction for Specification Validation.
+ */
+public interface SpecificationValidationStratergy {
+ public void validate(SpecificationRequest specificationRequest, String release);
+}
diff --git a/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationValidatorService.java b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationValidatorService.java
new file mode 100644
index 0000000..6d10aee
--- /dev/null
+++ b/mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/web/service/specification/SpecificationValidatorService.java
@@ -0,0 +1,61 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.specification;
+
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * A service to validate specification
+ */
+@Service
+public class SpecificationValidatorService {
+
+ @Autowired
+ SpecificationValidationStratergy specValidator;
+
+ public void validateSpecForRelease(SpecificationRequest specificationRequest, String release) {
+ specValidator.validate(specificationRequest, release);
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mod2/catalog-service/src/main/resources/application.properties b/mod2/catalog-service/src/main/resources/application.properties
new file mode 100644
index 0000000..1f20c6a
--- /dev/null
+++ b/mod2/catalog-service/src/main/resources/application.properties
@@ -0,0 +1,24 @@
+#
+# ============LICENSE_START=======================================================
+# org.onap.dcae
+# ================================================================================
+# Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+
+#add connection to mongo db once its up and running
+spring.data.mongodb.host=mongo_db
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=dcae_mod \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/BaseMsObjectMother.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/BaseMsObjectMother.java
new file mode 100644
index 0000000..fc57442
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/BaseMsObjectMother.java
@@ -0,0 +1,131 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.objectmothers;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsLocation;
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsStatus;
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsType;
+import org.onap.dcaegen2.platform.mod.model.common.AuditFields;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceCreateRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceUpdateRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.*;
+
+public class BaseMsObjectMother {
+
+ public static final String BASE_MS_NAME = "ms-1";
+ public static final String BASE_MS_ID = "id123";
+ public static final BaseMsType BASE_MS_TYPE = BaseMsType.TICK;
+ public static final BaseMsLocation LOCATION = BaseMsLocation.CENTRAL;
+ public static final String NAMESPACE = "sam.collector.namespace";
+ public static final String NOTE = "Sample Note";
+ public static final String LABEL_1 = "mylabel1";
+ public static final String LABEL_2 = "mylabel2";
+ public static final String USER = "abc123";
+ private static final String BASE_MS_TAG = "sample-ms-tag" ;
+ private static final String BASE_MS_SERVICE_NAME = "sample-core";
+
+
+ public static MicroserviceCreateRequest createMockMsRequest() {
+ Map<String, Object> metadata = new HashMap();
+ metadata.put("notes", NOTE);
+ metadata.put("labels", Arrays.asList(LABEL_1, LABEL_2));
+
+ MicroserviceCreateRequest request = new MicroserviceCreateRequest();
+ request.setName(BASE_MS_NAME);
+ request.setTag(BASE_MS_TAG);
+ request.setServiceName(BASE_MS_SERVICE_NAME);
+ request.setType(BASE_MS_TYPE);
+ request.setLocation(LOCATION);
+ request.setNamespace(NAMESPACE);
+ request.setMetadata(metadata);
+ request.setUser(USER);
+
+ return request;
+ }
+
+ public static BaseMicroservice createMockMsObject() {
+ BaseMicroservice microservice = new BaseMicroservice();
+ microservice.setId(BASE_MS_ID);
+ microservice.setName(BASE_MS_NAME);
+ microservice.setServiceName(BASE_MS_SERVICE_NAME);
+ microservice.setTag(BASE_MS_TAG);
+ microservice.setType(BASE_MS_TYPE);
+ microservice.setLocation(LOCATION);
+ microservice.setNamespace(NAMESPACE);
+ microservice.setStatus(BaseMsStatus.ACTIVE);
+ microservice.setMetadata(prepareAuditFields());
+ microservice.setMsInstances(createMsInstanceReferences());
+ return microservice;
+ }
+
+ private static List<Map<String, String>> createMsInstanceReferences() {
+ List<Map<String, String>> msInstanceRefs = new ArrayList<>();
+ Map<String, String> msInstance_1 = new HashMap<>();
+ msInstance_1.put("name", BASE_MS_NAME);
+ msInstance_1.put("id", "instance-1");
+ Map<String, String> msInstance_2 = new HashMap<>();
+ msInstance_2.put("name", BASE_MS_NAME);
+ msInstance_2.put("id", "instance-2");
+ msInstanceRefs.add(msInstance_1);
+ msInstanceRefs.add(msInstance_2);
+ return msInstanceRefs;
+ }
+
+
+ public static AuditFields prepareAuditFields() {
+ return AuditFields.builder()
+ .createdBy(USER) // prepared by core
+ .createdOn(new Date(12323132L))
+ .updatedBy(USER)
+ .updatedOn(new Date(12323133L))
+ .notes(NOTE)
+ .labels(Arrays.asList(LABEL_1, LABEL_2))
+ .build();
+
+ }
+
+ public static MicroserviceUpdateRequest createUpdateMsRequest() {
+ MicroserviceUpdateRequest updateRequest = new MicroserviceUpdateRequest();
+ updateRequest.setName("updatedName");
+ updateRequest.setLocation(BaseMsLocation.EDGE);
+ updateRequest.setServiceName("updated-core-name");
+ updateRequest.setNamespace("updatedNameSpace");
+ updateRequest.setType(BaseMsType.ANALYTIC);
+ updateRequest.setUser("updater");
+
+ Map<String, Object> metadata = new HashMap();
+ metadata.put("notes", "updatedNote");
+ metadata.put("labels", Arrays.asList("updatedLabel1", "updatedLabel2"));
+ updateRequest.setMetadata(metadata);
+ return updateRequest;
+ }
+
+ public static String asJsonString(final Object object) {
+ try {
+ return new ObjectMapper().writeValueAsString(object);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/DeploymentArtifactObjectMother.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/DeploymentArtifactObjectMother.java
new file mode 100644
index 0000000..da52624
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/DeploymentArtifactObjectMother.java
@@ -0,0 +1,222 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.objectmothers;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.MsInstanceInfo;
+
+import java.util.*;
+
+import static org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother.USER;
+
+public class DeploymentArtifactObjectMother {
+
+
+ public static final String BLUEPRINT_FILENAME = "hello-world-k8s-blueprint.yaml";
+ public static final String BLUEPRINT_CONTENT = "\\n#Basic java app to print out at&t buzzwords\\n#1.0" +
+ ".0\\n#\\n---\\" + "ntosca_definitions_version: cloudify_dsl_1_3\\nimports:\\n- http://www.getcloudify" +
+ ".org/spec/cloudify/4.4/types" + ".yaml\\n- http://dockercentral.it.att" +
+ ".com:8093/nexus/repository/rawcentral/com.att.dcae.controller/type_files/" + "k8splugin/1.7.4/node-type" +
+ ".yaml\\n- http://dockercentral.it.att.com:8093/nexus/repository/rawcentral/com.att.d" + "cae.controller" +
+ "/type_files/relationship/2006001.1.0/types.yaml\\n- http://dockercentral.it.att.com:8093/nexus/" +
+ "repository/rawcentral/com.att.dcae.controller/type_files/cloudifydmaapplugin/1.4.10/node-type.yaml\\n- " +
+ "http:/" + "/dockercentral.it.att.com:8093/nexus/repository/rawcentral/com.att.dcae" +
+ ".controller/type_files/dcaepolicyplugi" + "n/2.3.3/node-type.yaml\\n- http://dockercentral.it.att" +
+ ".com:8093/nexus/repository/rawcentral/com.att.dcae.cont" + "roller/type_files/pgaas/0.3.2/pgaas_types" +
+ ".yaml\\ninputs:\\n ConsulTest1:\\n type: string\\n description" + ": test description\\n " +
+ "default: 'TEST1'\\n ConsulTest2:\\n type: string\\n description: test description\\n default: " +
+ "'TEST2'\\n aaf_cert_directory:\\n type: string\\n default: '/opt/app/aafcertman'\\n " +
+ "description: directory location for the aaf-tls certs\\n additionalsans:\\n type: string\\n " +
+ "default: ''\\n description: additional sans (string)\\n annotations:\\n default: {}\\n " +
+ "app_name:\\n type: string\\n default: 'dcae'\\n description: This is used to generateForRelease different" +
+ " secret code for DCAE or D2A based\\n on Tosca or Helm based BP\\n dcae_service_location:\\n " +
+ "type: string\\n description: Docker host override for docker bps (string)\\n " +
+ "dti_sidecar_cpu_limit:\\n type: string\\n default: '250m'\\n description: cpu limit for " +
+ "deployment (string)\\n dti_sidecar_cpu_request:\\n type: string\\n default: '250m'\\n " +
+ "description: cpu requested for deployment (string)\\n dti_sidecar_image:\\n type: string\\n " +
+ "default: 'dockercentral.it.att.com:5100/com.att.dcae.controller/dcae-controller-sidecar:19.11-001'\\n " +
+ " description: dti side car image for dti (string)\\n dti_sidecar_memory_limit:\\n type: string\\n " +
+ " default: '128Mi'\\n description: memory limit for deployment (string)\\n " +
+ "dti_sidecar_memory_request:\\n type: string\\n default: '128Mi'\\n description: memory " +
+ "requested for deployment (string)\\n dti_sidecar_port:\\n type: string\\n default: ''\\n " +
+ "description: Port for the side car (string)\\n hello-buzzword_cpu_limit:\\n type: string\\n " +
+ "default: '250m'\\n description: cpu limit for deployment (string)\\n hello-buzzword_cpu_request:\\n " +
+ " type: string\\n default: '250m'\\n description: cpu requested for deployment (string)\\n " +
+ "hello-buzzword_memory_limit:\\n type: string\\n default: '128Mi'\\n description: memory limit " +
+ "for deployment (string)\\n hello-buzzword_memory_request:\\n type: string\\n default: '128Mi'\\n " +
+ " description: memory requested for deployment (string)\\n idns_fqdn:\\n type: string\\n " +
+ "default: ''\\n description: The idns you will be using for your deployment (string)\\n image:\\n " +
+ "type: string\\n default: 'test-image-uri'\\n description: The docker image for your microservice " +
+ "(string)\\n namespace:\\n type: string\\n replicas:\\n type: integer\\n default: 1\\n " +
+ "description: The number of replicas for your kubernetes deployment (integer)\\n " +
+ "service_component_name_override:\\n type: string\\n default: 'hello-buzzword'\\n description: " +
+ "Unique identifier for your deployment (string)\\n use_aaf_tls:\\n type: boolean\\n default: " +
+ "false\\n description: To use or not use the aaf section (boolean)\\n use_dti_info:\\n type: " +
+ "boolean\\n default: true\\n description: Flag to use or not use dti (boolean)\\nnode_templates:\\n" +
+ " hello-buzzword_hello-buzzword:\\n type: dcae.nodes.ContainerizedServiceComponent\\n " +
+ "properties:\\n application_config:\\n services_calls: []\\n streams_publishes: {}\\n " +
+ " streams_subscribes: {}\\n ConsulTest1:\\n get_input: ConsulTest1\\n " +
+ "ConsulTest2:\\n get_input: ConsulTest2\\n docker_config:\\n healthcheck:\\n " +
+ " interval: 180s\\n timeout: 30s\\n script: \\\"true\\\"\\n type: docker\\n " +
+ " livehealthcheck:\\n interval: 180s\\n timeout: 30s\\n script: " +
+ "\\\"true\\\"\\n type: docker\\n reconfigs:\\n dti: dti/test-script\\n " +
+ "app_reconfig: /app-reconfig/test-script\\n env:\\n - name: DTI_DATA_DIR\\n value:" +
+ " /dtidata\\n - name: KUBE_CLUSTER_FQDN\\n value: {get_secret: " +
+ "kc-kubernetes_master_ip}\\n image:\\n get_input: image\\n location_id:\\n " +
+ "get_input: dcae_service_location\\n service_component_type: hello-buzzword\\n replicas:\\n " +
+ " get_input: replicas\\n service_component_name_override:\\n concat:\\n - " +
+ "get_secret: location_id\\n - '-'\\n - get_input: service_component_name_override\\n " +
+ "k8s_controller_type: statefulset\\n configuration:\\n file_content:\\n apiVersion: " +
+ "v1\\n clusters:\\n - name: default-cluster\\n cluster:\\n " +
+ "server:\\n concat:\\n - https://\\n - get_secret: " +
+ "kc-kubernetes_master_ip\\n - ':'\\n - get_secret: " +
+ "kc-kubernetes_master_port\\n insecure-skip-tls-verify: true\\n contexts:\\n " +
+ " - name: default-context\\n context:\\n cluster: default-cluster\\n " +
+ " namespace:\\n get_input: namespace\\n user: default-user\\n " +
+ "kind: Config\\n preferences: {}\\n users:\\n - name: default-user\\n " +
+ " user:\\n token:\\n get_secret:\\n concat:\\n " +
+ " - get_input: app_name\\n - -mechid-k8s-token\\n current-context: " +
+ "default-context\\n resource_config:\\n limits:\\n cpu:\\n get_input: " +
+ "hello-buzzword_cpu_limit\\n memory:\\n get_input: hello-buzzword_memory_limit\\n " +
+ " requests:\\n cpu:\\n get_input: hello-buzzword_cpu_request\\n " +
+ "memory:\\n get_input: hello-buzzword_memory_request\\n aaf_tls_info:\\n " +
+ "use_aaf_tls:\\n get_input: use_aaf_tls\\n cert_directory:\\n get_input: " +
+ "aaf_cert_directory\\n image: dockercentral.it.att.com:5100/com.att.ecompcntr" +
+ ".public/ecompc-aaf-init-container:1.0.2\\n env:\\n - name: NAMESPACE\\n " +
+ "valueFrom:\\n fieldRef:\\n fieldPath: metadata.namespace\\n - name: " +
+ "deployer_id\\n valueFrom:\\n secretKeyRef:\\n name:\\n " +
+ "concat:\\n - get_input: namespace\\n - -cert-secret\\n key: " +
+ "deployerid\\n - name: deployer_pass\\n valueFrom:\\n secretKeyRef:\\n " +
+ " name:\\n concat:\\n - get_input: namespace\\n - " +
+ "-cert-secret\\n key: deployerpass\\n - name: cert_id\\n valueFrom:\\n " +
+ " secretKeyRef:\\n name:\\n concat:\\n - get_input: " +
+ "namespace\\n - -cert-secret\\n key: certid\\n - name: cm_url\\n " +
+ " valueFrom:\\n secretKeyRef:\\n name:\\n concat:\\n " +
+ " - get_input: namespace\\n - -cert-secret\\n key: cmurl\\n - " +
+ "name: idns_fqdn\\n value:\\n get_input: idns_fqdn\\n - name: " +
+ "app_service_names\\n value:\\n concat:\\n - get_secret: location_id\\n " +
+ " - '-'\\n - get_input: service_component_name_override\\n args:\\n - " +
+ "place\\n - cmtemplate\\n - -idnsfqdn=$(idns_fqdn)\\n - -cmurl=$(cm_url)\\n -" +
+ " -deployerid=$(deployer_id)\\n - -deployerpass=$(deployer_pass)\\n - -certid=$(cert_id)\\n" +
+ " - -namespace=$(NAMESPACE)\\n - -services=$(app_service_names)\\n - concat:\\n " +
+ " - -additionalsans=\\n - get_input: additionalsans\\n use_aaf_tls_renewal: true\\n " +
+ " renewal_args:\\n - renew\\n - -idnsfqdn=$(idns_fqdn)\\n - -cmurl=$(cm_url)\\n" +
+ " resource_config:\\n limits:\\n cpu: 250m\\n memory: 256Mi\\n " +
+ " requests:\\n cpu: 100m\\n memory: 256Mi\\n annotations:\\n " +
+ "get_input: annotations\\n dti_info:\\n image:\\n get_input: dti_sidecar_image\\n " +
+ " use_dti_info:\\n get_input: use_dti_info\\n healthcheck:\\n interval: " +
+ "90s\\n timeout: 60s\\n type: https\\n endpoint: /healthcheck\\n " +
+ "livehealthcheck:\\n interval: 90s\\n timeout: 60s\\n type: https\\n " +
+ "endpoint: /healthcheck\\n dtidata_directory: /dtidata\\n resource_config:\\n " +
+ "limits:\\n cpu:\\n get_input: dti_sidecar_cpu_limit\\n memory:\\n " +
+ " get_input: dti_sidecar_memory_limit\\n requests:\\n cpu:\\n " +
+ "get_input: dti_sidecar_cpu_request\\n memory:\\n get_input: " +
+ "dti_sidecar_memory_request\\n env:\\n - name: DTI_DATA_DIR\\n value: /dtidata\\n " +
+ " - name: KUBE_CLUSTER_FQDN\\n value: {get_secret: kc-kubernetes_master_ip}\\n - " +
+ "name: KUBE_PROXY_FQDN\\n value: {get_secret: kube_proxy_fqdn}\\n - name: POD_SVC_PORT\\n" +
+ " value: '9999'\\n ports:\\n - concat:\\n - '9999:'\\n - " +
+ "get_input: dti_sidecar_port\\n relationships: []";
+
+ public static final String SPEC_FILE_AS_STRING = String.format("{\r\n\t\"self\": {\r\n\t\t\"component_type\": " +
+ "\"docker\",\r\n\t\t\"description\": \"Basic java app to print out at&t buzzwords\",\r\n\t\t\"name\": " +
+ "\"hello-buzzword\",\r\n\t\t\"version\": \"1.0.0\"\r\n\t},\r\n\t\r\n\t\"services\": {\r\n\t\t\"calls\": " +
+ "[],\r\n\t\t\"provides\": []\r\n\t},\r\n\t\"streams\": {\r\n\t\t\"publishes\": [],\r\n\t\t\"subscribes\":" +
+ " []\r\n\t},\r\n\t\"parameters\": [\r\n\t\t{\r\n \"name\": \"ConsulTest1\",\r\n " +
+ "\"value\": \"TEST1\",\r\n \"description\": \"Test consul output\"," +
+ "\r\n\t\t\t\"sourced_at_deployment\": true,\r\n\t\t\t\"designer_editable\": true," +
+ "\r\n\t\t\t\"policy_editable\": false,\r\n\t\t\t\"type\": \"string\" ,\r\n\t\t\t\"description\": \"test " +
+ "description\" \r\n },\r\n {\r\n \"name\": \"ConsulTest2\",\r\n " +
+ " \"value\": \"TEST2\",\r\n\t\t\t\"sourced_at_deployment\": true,\r\n\t\t\t\"designer_editable\": true," +
+ "\r\n\t\t\t\"policy_editable\": false,\r\n\t\t\t\"type\": \"string\",\r\n\t\t\t\"description\": \"test " +
+ "description\" \r\n }\r\n \r\n\t],\r\n\r\n\t\"auxilary\": {\r\n\t\t\"healthcheck\": " +
+ "{\r\n\t\t\t\"type\": \"docker\",\r\n \t\"script\": \"true\",\r\n \t\"timeout\": \"30s\"," +
+ "\r\n \t\"interval\": \"180s\"\r\n\t\t},\r\n\t\t\"livehealthcheck\": {\r\n\t\t\t\"type\": " +
+ "\"docker\",\r\n \t\"script\": \"true\",\r\n \t\"timeout\": \"30s\",\r\n " +
+ "\t\"interval\": \"180s\"\r\n\t\t},\r\n\t\t\"reconfigs\": {\r\n\t\t\t\"app_reconfig\" : " +
+ "\"/app-reconfig/test-script\",\r\n\t\t\t\"dti\" : \"dti/test-script\"}}," +
+ "\r\n\t\"artifacts\": [{\r\n\t\t\"type\": \"docker image\",\r\n\t\t\"uri\": " +
+ "\"test-image-uri\"\r\n\t}]\r\n}");
+
+ public static DeploymentArtifact createDeploymentArtifactDAO(DeploymentArtifactStatus status) {
+ DeploymentArtifact artifact = new DeploymentArtifact();
+ artifact.setId("id-123");
+ artifact.setFileName("helloworld-k8s-blueprint.yaml");
+ artifact.setContent("some " + "yaml content");
+ artifact.setStatus(status);
+ artifact.setVersion(1);
+ artifact.setMetadata(createMetaData());
+ artifact.setMsInstanceInfo(createMsInstanceInfo());
+ artifact.setSpecificationInfo(createSpecificationInfo());
+
+ return artifact;
+ }
+
+ private static Map<String, Object> createSpecificationInfo() {
+ Map<String, Object> msInstanceInfo = new HashMap<>();
+ msInstanceInfo.put("id", "id-123");
+ return msInstanceInfo;
+ }
+
+ private static MsInstanceInfo createMsInstanceInfo() {
+ MsInstanceInfo msInstanceInfo = new MsInstanceInfo();
+ msInstanceInfo.setId(MsInstanceObjectMother.MS_INSTANCE_ID);
+ msInstanceInfo.setName(MsInstanceObjectMother.MS_INSTANCE_NAME);
+ msInstanceInfo.setRelease(MsInstanceObjectMother.RELEASE);
+ return msInstanceInfo;
+ }
+
+ private static Map<String, Object> createMetaData() {
+ Map<String, Object> metadata = new HashMap<>();
+ metadata.put("createdBy", USER);
+ metadata.put("createdOn", "someDate");
+ metadata.put("notes", "This is a test Deployment Artifact");
+ metadata.put("labels", Arrays.asList("hello", "world"));
+ return metadata;
+ }
+
+ public static Map<String, Object> createBlueprintResponse() {
+ Map<String, Object> blueprintMap = new HashMap<>();
+ blueprintMap.put("fileName", BLUEPRINT_FILENAME);
+ blueprintMap.put("content", BLUEPRINT_CONTENT); return blueprintMap;
+ }
+
+ public static Map<String, Object> createToolboxBlueprintResponse() {
+ Map<String, Object> blueprintResponseMap = new HashMap<>();
+ blueprintResponseMap.put("blueprint_name", "hello-buzzword-eom-k8s");
+ blueprintResponseMap.put("blueprint_content", BLUEPRINT_CONTENT);
+ blueprintResponseMap.put("componentSpecValidated", true);
+ return blueprintResponseMap;
+ }
+
+ public static List<DeploymentArtifact> createMockDeploymentArtifactsWithDifferentStatuses
+ (boolean devCompleteRequire) {
+ DeploymentArtifact d1;
+ if(devCompleteRequire){
+ d1 = createDeploymentArtifactDAO(DeploymentArtifactStatus.DEV_COMPLETE);
+ }else {
+ d1 = createDeploymentArtifactDAO(DeploymentArtifactStatus.NOT_NEEDED);
+ }
+ DeploymentArtifact d2 = createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+ return new ArrayList<>(Arrays.asList(d1, d2));
+ }
+
+}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/MsInstanceObjectMother.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/MsInstanceObjectMother.java
new file mode 100644
index 0000000..976e31c
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/MsInstanceObjectMother.java
@@ -0,0 +1,112 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.objectmothers;
+
+import org.onap.dcaegen2.platform.mod.model.specification.DeploymentType;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.DeploymentArtifactsRef;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstanceStatus;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceRequest;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class MsInstanceObjectMother {
+
+ public static final String MS_INSTANCE_NAME = "ms-instance-1";
+ public static final String MS_INSTANCE_ID = "id-123";
+ public static final String RELEASE = "2002";
+ public static final String VERSION = "1.1";
+ public static final String USER = "user-1";
+ public static final String BASE_MS_TAG = "ms-instance-1-tag";
+ public static final String SCRUMLEAD = "Sam";
+ public static final String SYSTEMSENGINEER = "John";
+
+ public static MsInstanceRequest getMsInstanceMockRequest() {
+ Map<String, Object> metadataFromRequest = buildMockMetadataForRequest();
+
+ MsInstanceRequest request = MsInstanceRequest.builder()
+ .name(MS_INSTANCE_NAME)
+ .release(RELEASE)
+ .version(VERSION)
+ .user(USER)
+ .metadata(metadataFromRequest)
+ .build();
+
+ return request;
+ }
+
+ private static Map<String, Object> buildMockMetadataForRequest() {
+ Map<String, Object> metadataFromRequest = new HashMap<>();
+ metadataFromRequest.put("pstDueDate", "14-04-2020");
+ metadataFromRequest.put("pstDueIteration", "1.2");
+ metadataFromRequest.put("eteDueDate", "21-05-2020");
+ metadataFromRequest.put("eteDueIteration", "1.3");
+ metadataFromRequest.put("scrumLead", SCRUMLEAD);
+ metadataFromRequest.put("systemsEngineer", SYSTEMSENGINEER);
+ return metadataFromRequest;
+ }
+
+
+ public static MsInstance createMsInstance() {
+ Map<String, Object> metadataFromResponse = buildMockMetadataForRequest().entrySet()
+ .stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ metadataFromResponse.put("createdOn", "currentDate");
+ metadataFromResponse.put("createdBy", USER);
+ metadataFromResponse.put("scrumLead", SCRUMLEAD);
+ metadataFromResponse.put("systemsEngineer", SYSTEMSENGINEER);
+
+ Map<String, Object> msInfo = new HashMap<>();
+ msInfo.put("id", BaseMsObjectMother.BASE_MS_ID);
+ msInfo.put("name", BaseMsObjectMother.BASE_MS_NAME);
+ msInfo.put("tag", BASE_MS_TAG);
+
+ MsInstance msInstance = MsInstance.builder()
+ .id(MS_INSTANCE_ID)
+ .name(MS_INSTANCE_NAME)
+ .release(RELEASE)
+ .version(VERSION)
+ .status(MsInstanceStatus.NEW)
+ .metadata(metadataFromResponse)
+ .msInfo(msInfo)
+ .activeSpec(SpecificationObjectMother.getMockSpecification(DeploymentType.DOCKER))
+ .build();
+
+ return msInstance;
+ }
+
+ public static MsInstance getMsInstanceWithExistingDeploymentArtifactRef() {
+ MsInstance msInstance = createMsInstance();
+
+ DeploymentArtifactsRef deploymentArtifactRef = new DeploymentArtifactsRef();
+ deploymentArtifactRef.setMostRecentVersion(1);
+
+ ArrayList<String> deploymentArtifactList = new ArrayList<>();
+ deploymentArtifactList.add("id-456");
+ deploymentArtifactRef.setDeploymentArtifacts(deploymentArtifactList);
+
+ msInstance.setDeploymentArtifactsInfo(deploymentArtifactRef);
+
+ return msInstance;
+ }
+}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/SpecificationObjectMother.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/SpecificationObjectMother.java
new file mode 100644
index 0000000..3390998
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/objectmothers/SpecificationObjectMother.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.objectmothers;
+
+import org.onap.dcaegen2.platform.mod.model.specification.DeploymentType;
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.onap.dcaegen2.platform.mod.util.TestUtil;
+
+public class SpecificationObjectMother {
+ public static final String SPEC_REQUEST = "src/test/resources/http/requests/CreateSpecificationRequest.json";
+ public static final String SPEC_RESPONSE = "src/test/resources/http/requests/CreateSpecificationResponse.json";
+
+ public static SpecificationRequest getSpecificationRequest() {
+ return TestUtil.deserializeJsonFileToModel(SPEC_REQUEST, SpecificationRequest.class);
+ }
+
+ public static Specification getMockSpecification(DeploymentType type) {
+ Specification specification = TestUtil.deserializeJsonFileToModel(SPEC_RESPONSE, Specification.class);
+ specification.setType(type);
+ return specification;
+ }
+}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/persistence/DeploymentArtifactGatewayTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/persistence/DeploymentArtifactGatewayTest.java
new file mode 100644
index 0000000..9bcd46c
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/persistence/DeploymentArtifactGatewayTest.java
@@ -0,0 +1,147 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.persistence;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactFilter;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactSearch;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.mongo.deploymentartifact.DeploymentArtifactMongoGateway;
+import org.onap.dcaegen2.platform.mod.mongo.deploymentartifact.DeploymentArtifactMongoRepo;
+import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactGateway;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.mongodb.core.MongoOperations;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import java.util.Arrays;
+import java.util.List;
+
+@Disabled("Embedded mongodb jar is not available in the maven repo.")
+@SpringBootTest
+@ExtendWith(SpringExtension.class)
+public class DeploymentArtifactGatewayTest {
+
+ DeploymentArtifactGateway gateway;
+
+ @Autowired
+ DeploymentArtifactMongoRepo repo;
+
+ @Autowired
+ MongoOperations operations;
+
+ @BeforeEach
+ public void setUp(){
+ gateway = new DeploymentArtifactMongoGateway(repo);
+
+ operations.dropCollection(DeploymentArtifact.class);
+
+ String r_2008 = "2008";
+ String r_2010 = "2010";
+
+ DeploymentArtifactStatus inDev = DeploymentArtifactStatus.IN_DEV;
+ DeploymentArtifactStatus devComplete = DeploymentArtifactStatus.DEV_COMPLETE;
+
+ String tag_1 = "hello-one";
+ String tag_2 = "hello-two";
+ String tag_3 = "hello-three";
+
+ DeploymentArtifact artifact_1 = getDeploymentArtifact(r_2008, inDev, tag_1);
+ DeploymentArtifact artifact_2 = getDeploymentArtifact(r_2010, devComplete, tag_2);
+ DeploymentArtifact artifact_3 = getDeploymentArtifact(r_2008, devComplete, tag_3);
+
+ operations.insertAll(Arrays.asList(artifact_1, artifact_2, artifact_3));
+ operations.findAll(DeploymentArtifact.class).forEach(System.out::println);
+
+ System.out.println();
+ }
+
+ private static DeploymentArtifact getDeploymentArtifact(String r_2008, DeploymentArtifactStatus inDev,
+ String tag) {
+ DeploymentArtifact artifact_1 = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(inDev);
+ artifact_1.getMsInstanceInfo().setRelease(r_2008);
+ //Currently searching tag in filename as it is not present in DeploymentArtifact record
+ artifact_1.setFileName(tag);
+ artifact_1.setId(null);
+
+ return artifact_1;
+ }
+
+ @Test
+ public void findByOnlyRelease() throws Exception {
+ DeploymentArtifactSearch search = new DeploymentArtifactSearch();
+ DeploymentArtifactFilter filter = new DeploymentArtifactFilter();
+ filter.setRelease("2008");
+ search.setFilter(filter);
+
+ List<DeploymentArtifact> artifacts = gateway.findAll(search);
+ Assertions.assertThat(artifacts.size()).isEqualTo(2);
+ }
+
+ @Test
+ public void findWithOnlyStatus() throws Exception {
+ DeploymentArtifactSearch search = new DeploymentArtifactSearch();
+ DeploymentArtifactFilter filter = new DeploymentArtifactFilter();
+ filter.setStatus(DeploymentArtifactStatus.IN_DEV);
+ search.setFilter(filter);
+
+ List<DeploymentArtifact> artifacts = gateway.findAll(search);
+
+ Assertions.assertThat(artifacts.size()).isEqualTo(1);
+ }
+
+ @Test
+ public void findWithStatusAndRelease() throws Exception {
+ DeploymentArtifactSearch search = new DeploymentArtifactSearch();
+ DeploymentArtifactFilter filter = new DeploymentArtifactFilter();
+ filter.setStatus(DeploymentArtifactStatus.DEV_COMPLETE);
+ filter.setRelease("2008");
+ search.setFilter(filter);
+
+ List<DeploymentArtifact> artifacts = gateway.findAll(search);
+
+ Assertions.assertThat(artifacts.size()).isEqualTo(3);
+ }
+
+ @Test
+ public void findWithTag() throws Exception {
+ DeploymentArtifactSearch search = new DeploymentArtifactSearch();
+ DeploymentArtifactFilter filter = new DeploymentArtifactFilter();
+ filter.setTag("hello-one");
+ search.setFilter(filter);
+
+ List<DeploymentArtifact> artifacts = gateway.findAll(search);
+
+ Assertions.assertThat(artifacts.size()).isEqualTo(1);
+ }
+
+ @Test
+ public void findWithNoQuery() throws Exception {
+ List<DeploymentArtifact> artifacts = gateway.findAll(new DeploymentArtifactSearch());
+ Assertions.assertThat(artifacts.size()).isEqualTo(0);
+ }
+}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/util/TestUtil.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/util/TestUtil.java
new file mode 100644
index 0000000..f9a45da
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/util/TestUtil.java
@@ -0,0 +1,53 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.util;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+public class TestUtil {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ private TestUtil() {}
+
+ public static Map<String, Object> readJsonFileAsObjectMap(String filePath) {
+ try {
+ return MAPPER.readValue(new File(filePath), new TypeReference<Map<String, Object>>() {});
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException();
+ }
+ }
+
+ public static <T> T deserializeJsonFileToModel(String filePath, Class<T> modelClass) {
+ try {
+ return MAPPER.readValue(new File(filePath), modelClass);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException();
+ }
+ }
+}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/BaseMicroserviceControllerTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/BaseMicroserviceControllerTest.java
new file mode 100644
index 0000000..c89b4dc
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/BaseMicroserviceControllerTest.java
@@ -0,0 +1,165 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.exceptions.OperationNotAllowedException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.ResourceConflictException;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceCreateRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceUpdateRequest;
+import org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother;
+import org.onap.dcaegen2.platform.mod.web.controller.BaseMicroserviceController;
+import org.onap.dcaegen2.platform.mod.web.service.basemicroservice.MsService;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mockito;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+
+import java.util.Arrays;
+
+import static org.onap.dcaegen2.platform.mod.model.exceptions.ErrorMessages.MICROSERVICE_NAME_CONFLICT_MESSAGE;
+
+@ExtendWith(SpringExtension.class)
+@WebMvcTest(BaseMicroserviceController.class)
+class BaseMicroserviceControllerTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @MockBean
+ private MsService mockBaseMsService;
+
+ @BeforeEach
+ void setUp() {
+ }
+
+ @Test
+ void test_GetAllBaseMicroservices_returnsListOfDTOs() throws Exception {
+ //arrange
+ BaseMicroservice ms1 = new BaseMicroservice();
+ ms1.setName("HelloWorld1");
+ BaseMicroservice ms2 = new BaseMicroservice();
+ ms2.setName("HelloWorld2");
+
+ Mockito.when(mockBaseMsService.getAllMicroservices()).thenReturn(Arrays.asList(ms1, ms2));
+
+ //act/assert
+ mockMvc.perform(MockMvcRequestBuilders.get("/api/base-microservice")
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(MockMvcResultMatchers.status().isOk())
+ .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(2)));
+ }
+
+ @Test
+ void test_addBaseMicroservice_returnsMicroservice() throws Exception {
+ //arrange
+ MicroserviceCreateRequest microserviceRequest = BaseMsObjectMother.createMockMsRequest();
+
+ //response
+ BaseMicroservice microserviceDao = BaseMsObjectMother.createMockMsObject();
+
+ Mockito.when(mockBaseMsService.createMicroservice(microserviceRequest)).thenReturn(microserviceDao);
+
+ //act/assert
+ mockMvc.perform(MockMvcRequestBuilders.post("/api/base-microservice")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(microserviceRequest))
+ .characterEncoding("utf-8"))
+ .andExpect(MockMvcResultMatchers.status().isCreated())
+ .andExpect((MockMvcResultMatchers.jsonPath("$.id", Matchers.equalTo(BaseMsObjectMother.BASE_MS_ID))))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.name", Matchers.equalTo(BaseMsObjectMother.BASE_MS_NAME)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.metadata.createdBy", Matchers.equalTo(BaseMsObjectMother.USER)));
+ }
+
+ @Test
+ void test_addBaseMicroserviceWithDuplicateName_shouldThrowConflictError() throws Exception{
+ //arrange
+ MicroserviceCreateRequest microserviceRequest = BaseMsObjectMother.createMockMsRequest();
+ Mockito.when(mockBaseMsService.createMicroservice(ArgumentMatchers.any())).thenThrow(new ResourceConflictException(MICROSERVICE_NAME_CONFLICT_MESSAGE));
+
+ //act/assert
+ mockMvc.perform(MockMvcRequestBuilders.post("/api/base-microservice")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(microserviceRequest)))
+ .andExpect(MockMvcResultMatchers.status().isConflict());
+ }
+
+ @Test
+ void test_updateBaseMicroserviceEndpoint() throws Exception{
+ MicroserviceUpdateRequest microserviceRequest = BaseMsObjectMother.createUpdateMsRequest();
+ String requestedMsId = "id-123";
+
+ mockMvc.perform(MockMvcRequestBuilders.patch(String.format(BaseMicroserviceController.API_BASE_MICROSERVICE + "/%s", requestedMsId))
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(microserviceRequest))
+ .characterEncoding("utf-8"))
+ .andExpect(MockMvcResultMatchers.status().isNoContent());
+ Mockito.verify(mockBaseMsService, Mockito.times(1)).updateMicroservice(requestedMsId, microserviceRequest);
+ }
+
+ @Test
+ void test_OperationNotAllowedExceptionThrows409() throws Exception{
+ MicroserviceUpdateRequest microserviceRequest = BaseMsObjectMother.createUpdateMsRequest();
+ String requestedMsId = "id-123";
+ Mockito.doThrow(new OperationNotAllowedException("")).
+ when(mockBaseMsService).updateMicroservice(requestedMsId, microserviceRequest);
+
+ mockMvc.perform(MockMvcRequestBuilders.patch(String.format(BaseMicroserviceController.API_BASE_MICROSERVICE + "/%s", requestedMsId))
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(microserviceRequest)))
+ .andExpect(MockMvcResultMatchers.status().isConflict());
+ }
+
+ @Test
+ void test_validateMsRequestShouldThrowCorrectResponse() throws Exception {
+ //arrange
+ MicroserviceCreateRequest microserviceRequest = BaseMsObjectMother.createMockMsRequest();
+ microserviceRequest.setName(" ");
+ microserviceRequest.setTag("123");
+ microserviceRequest.setServiceName("123");
+ microserviceRequest.setUser(" ");
+
+ //response
+ BaseMicroservice microserviceDao = BaseMsObjectMother.createMockMsObject();
+
+ Mockito.when(mockBaseMsService.createMicroservice(microserviceRequest)).thenReturn(microserviceDao);
+
+ //act/assert
+ mockMvc.perform(MockMvcRequestBuilders.post("/api/base-microservice")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(microserviceRequest))
+ .characterEncoding("utf-8"))
+ .andExpect(MockMvcResultMatchers.status().isBadRequest())
+ .andExpect(MockMvcResultMatchers.jsonPath("$.message", Matchers.equalTo("Validation failed.")))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.errors", Matchers.hasSize(4)))
+ ;
+ }
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/DeploymentArtifactControllerTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/DeploymentArtifactControllerTest.java
new file mode 100644
index 0000000..c8942b1
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/DeploymentArtifactControllerTest.java
@@ -0,0 +1,170 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.BlueprintFileNameCreateException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.DeploymentArtifactNotFound;
+import org.onap.dcaegen2.platform.mod.model.restapi.DeploymentArtifactPatchRequest;
+import org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother;
+import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother;
+import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother;
+import org.onap.dcaegen2.platform.mod.web.controller.DeploymentArtifactController;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactService;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+
+@WebMvcTest(DeploymentArtifactController.class)
+class DeploymentArtifactControllerTest {
+
+ @Autowired
+ MockMvc mockMvc;
+
+ @MockBean
+ DeploymentArtifactService service;
+
+ @BeforeEach
+ void setUp() {
+ }
+
+ @Test
+ void test_GenerateDeploymentArtifactEndpoint_returnsBlueprint() throws Exception{
+ String url = String.format("/api/deployment-artifact/%s?user=%s", MsInstanceObjectMother.MS_INSTANCE_ID, MsInstanceObjectMother.USER);
+ DeploymentArtifact response = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+
+ Mockito.when(service.generateDeploymentArtifact(MsInstanceObjectMother.MS_INSTANCE_ID, MsInstanceObjectMother.USER)).thenReturn(response);
+
+ mockMvc.perform(post(url))
+ .andExpect(MockMvcResultMatchers.status().isCreated())
+ .andExpect(MockMvcResultMatchers.jsonPath("$.fileName").exists())
+ .andExpect(MockMvcResultMatchers.jsonPath("$.content").exists());
+
+ Mockito.verify(service, Mockito.times(1)).generateDeploymentArtifact(MsInstanceObjectMother.MS_INSTANCE_ID, MsInstanceObjectMother.USER);
+ }
+
+ @Test
+ void test_RaiseExceptionIfBlueprintNameCanNotBeCreated() throws Exception{
+ String url = String.format("/api/deployment-artifact/%s?user=%s", MsInstanceObjectMother.MS_INSTANCE_ID,
+ MsInstanceObjectMother.USER);
+ DeploymentArtifact response = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+
+ Mockito.when(service.generateDeploymentArtifact(MsInstanceObjectMother.MS_INSTANCE_ID, MsInstanceObjectMother.USER)).thenThrow(new BlueprintFileNameCreateException(""));
+
+ mockMvc.perform(post(url))
+ .andExpect(MockMvcResultMatchers.status().is4xxClientError());
+ }
+
+ @Test
+ void test_GetAllDeploymentArtifactsShouldReturnList() throws Exception{
+ List<DeploymentArtifact> daos = createDaos();
+ Mockito.when(service.getAllDeploymentArtifacts()).thenReturn(daos);
+
+ mockMvc.perform(get("/api/deployment-artifact"))
+ .andExpect(MockMvcResultMatchers.status().isOk())
+ .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(2)));
+
+ }
+
+ private List<DeploymentArtifact> createDaos() {
+ DeploymentArtifact dao1 = new DeploymentArtifact();
+ dao1.setId("123");
+ DeploymentArtifact dao2 = new DeploymentArtifact();
+ dao2.setId("456");
+
+ return Arrays.asList(dao1, dao2);
+ }
+
+ @Test
+ void test_GetAllDeploymentArtifactTestShouldReturnAList() throws Exception{
+
+ mockMvc.perform(get(DeploymentArtifactController.DEPLOYMENT_ARTIFACTS_BASE_URL + DeploymentArtifactController.GET_STATUSES))
+ .andExpect(MockMvcResultMatchers.status().isOk())
+ .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(DeploymentArtifactStatus.values().length)));
+ }
+
+ @Test
+ void test_ifUserIsNullRaiseException() throws Exception{
+ String id = "id-123";
+ String user = "";
+
+ mockMvc.perform(patch(DeploymentArtifactController.DEPLOYMENT_ARTIFACTS_BASE_URL + "/" + id + "?user=" + user)
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(new DeploymentArtifactPatchRequest())))
+ .andExpect(MockMvcResultMatchers.status().isBadRequest());
+ }
+
+ @Test
+ void test_ChangeStatusOfDeploymentArtifact() throws Exception{
+
+ String id = "id-123";
+ String user = "user1";
+ DeploymentArtifactPatchRequest partialDto = new DeploymentArtifactPatchRequest();
+ partialDto.setStatus(DeploymentArtifactStatus.DEV_COMPLETE);
+
+ mockMvc.perform(patch(DeploymentArtifactController.DEPLOYMENT_ARTIFACTS_BASE_URL + "/" + id + "?user=" + user)
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(partialDto)))
+ .andExpect(MockMvcResultMatchers.status().isOk())
+ .andExpect(MockMvcResultMatchers.jsonPath("$.message").exists());
+
+ Mockito.verify(service, Mockito.times(1)).updateDeploymentArtifact(id, partialDto, user);
+
+ }
+
+ @Test
+ void test_deploymentArtifactIdNotFound() throws Exception{
+ String wrongId = "wrong-id";
+ DeploymentArtifactPatchRequest partialDto = new DeploymentArtifactPatchRequest();
+ partialDto.setStatus(DeploymentArtifactStatus.DEV_COMPLETE);
+
+ Mockito.doThrow(new DeploymentArtifactNotFound("")).when(service).
+ updateDeploymentArtifact(wrongId, partialDto, "user-1");
+
+ mockMvc.perform(patch(DeploymentArtifactController.DEPLOYMENT_ARTIFACTS_BASE_URL + "/" + wrongId + "?user=" + "user-1")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(partialDto)))
+ .andExpect(MockMvcResultMatchers.status().isBadRequest());
+ }
+
+ @Test
+ void test_deleteDeploymentArtifactEndpoint() throws Exception{
+ String deploymentArtifactId = "id-123";
+ String user = "user-1";
+ mockMvc.perform(delete(DeploymentArtifactController.DEPLOYMENT_ARTIFACTS_BASE_URL + "/" + deploymentArtifactId + "?user=" + user))
+ .andExpect(MockMvcResultMatchers.status().isOk())
+ .andExpect(MockMvcResultMatchers.jsonPath("$.message").exists());
+ Mockito.verify(service, Mockito.times(1)).deleteDeploymentArtifact(deploymentArtifactId);
+ }
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/MicroserviceInstanceControllerTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/MicroserviceInstanceControllerTest.java
new file mode 100644
index 0000000..852fb10
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/MicroserviceInstanceControllerTest.java
@@ -0,0 +1,145 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web;
+
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceUpdateRequest;
+import org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother;
+import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother;
+import org.onap.dcaegen2.platform.mod.web.controller.MicroserviceInstanceController;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother.*;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.mockito.Mockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@ExtendWith(SpringExtension.class)
+@WebMvcTest(MicroserviceInstanceController.class)
+class MicroserviceInstanceControllerTest {
+
+ @MockBean
+ MsInstanceService service;
+
+ @Autowired
+ MockMvc mockMvc;
+
+ @BeforeEach
+ void setUp() {
+ }
+
+ @Test
+ void getAll() throws Exception {
+ MsInstance instance_1 = MsInstance.builder().id("123").build();
+ MsInstance instance_2 = MsInstance.builder().id("345").build();
+
+ when(service.getAll()).thenReturn(Arrays.asList(instance_1,instance_2));
+
+ mockMvc.perform(get("/api/microservice-instance")
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$",hasSize(2)));
+ verify(service, times(1)).getAll();
+ }
+
+ @Test
+ void createMsInstance_shouldReturn201AndResponseBody() throws Exception {
+
+ MsInstanceRequest request = getMsInstanceMockRequest();
+ MsInstance msInstance = createMsInstance();
+
+ when(service.createMicroserviceInstance(BaseMsObjectMother.BASE_MS_NAME, request)).thenReturn(msInstance);
+
+ mockMvc.perform(MockMvcRequestBuilders.post("/api/microservice-instance/"+ BaseMsObjectMother.BASE_MS_NAME)
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(request)).accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated())
+ .andExpect(jsonPath("$.name",equalTo(MS_INSTANCE_NAME)));
+
+ verify(service, times(1)).createMicroserviceInstance(BaseMsObjectMother.BASE_MS_NAME,request);
+ }
+
+ @Test
+ void patchMsInstance_shouldReturn204NoContent() throws Exception{
+ //given
+ String updatedVersion = "updatedVersion";
+ String updatedRelease = "updatedRelease";
+
+ MsInstance mockedMsInstance = prepareMockMsInstance(updatedVersion, updatedRelease);
+ String msInstanceId = mockedMsInstance.getId();
+
+ MsInstanceUpdateRequest updateRequest = prepareMsInstanceUpdateRequest(updatedVersion, updatedRelease);
+
+ when(service.updateMsInstance(updateRequest, msInstanceId)).thenReturn(mockedMsInstance);
+
+ mockMvc.perform(patch("/api/microservice-instance/" + msInstanceId)
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(BaseMsObjectMother.asJsonString(updateRequest)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.release", equalTo(updatedRelease)))
+ .andExpect(jsonPath("$.version", equalTo(updatedVersion)))
+ .andExpect(jsonPath("$.metadata.scrumLead", equalTo("updatedScrumLead")));
+
+ verify(service, times(1)).updateMsInstance(updateRequest, msInstanceId);
+ }
+
+ private MsInstanceUpdateRequest prepareMsInstanceUpdateRequest(String updatedVersion, String updatedRelease) {
+ MsInstanceUpdateRequest updateRequest = new MsInstanceUpdateRequest();
+ updateRequest.setRelease(updatedRelease);
+ updateRequest.setVersion(updatedVersion);
+ updateRequest.setMetadata(prepareMetadataToBeUpdated());
+ return updateRequest;
+ }
+
+ private Map<String, Object> prepareMetadataToBeUpdated() {
+ Map<String, Object> metadata = new HashMap<>();
+ metadata.put("scrumLead", "updatedScrumLead");
+ return metadata;
+ }
+
+ private MsInstance prepareMockMsInstance(String updatedVersion, String updatedRelease) {
+ MsInstance msInstanceToBeUpdated = MsInstanceObjectMother.createMsInstance();
+ msInstanceToBeUpdated.setVersion(updatedVersion);
+ msInstanceToBeUpdated.setRelease(updatedRelease);
+ msInstanceToBeUpdated.getMetadata().put("scrumLead", "updatedScrumLead");
+ return msInstanceToBeUpdated;
+ }
+
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/MsRequestValidationTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/MsRequestValidationTest.java
new file mode 100644
index 0000000..d71f8dd
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/MsRequestValidationTest.java
@@ -0,0 +1,87 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web;
+
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceCreateRequest;
+import org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import java.util.Set;
+
+public class MsRequestValidationTest {
+
+ public Validator validator;
+ private MicroserviceCreateRequest request;
+
+ @BeforeEach
+ public void setup(){
+ validator = Validation.buildDefaultValidatorFactory().getValidator();
+ request = BaseMsObjectMother.createMockMsRequest();
+ }
+
+ @Test
+ void test_msNameShouldNotBeBlank(){
+ request.setName(" ");
+ Set<ConstraintViolation<MicroserviceCreateRequest>> violations = validator.validate(request);
+ Assertions.assertThat(violations.size()).isEqualTo(1);
+ }
+
+ @Test
+ void test_msTagShouldNotBeNull(){
+ request.setTag(null);
+ Set<ConstraintViolation<MicroserviceCreateRequest>> violations = validator.validate(request);
+ Assertions.assertThat(violations.size()).isEqualTo(1);
+
+ }
+
+ @Test
+ void test_msTagShouldFollowRegex() throws Exception{
+ request.setTag("ms-1");
+ Set<ConstraintViolation<MicroserviceCreateRequest>> violations = validator.validate(request);
+ Assertions.assertThat(violations.size()).isEqualTo(1);
+ }
+
+ @Test
+ void test_msTagSizeValidation() throws Exception {
+ request.setTag("core-name-should-not-exceed-fifty-chars-core-name-should-not-exceed-fifty-chars");
+ Set<ConstraintViolation<MicroserviceCreateRequest>> violations = validator.validate(request);
+ Assertions.assertThat(violations.size()).isEqualTo(1);
+ }
+
+ @Test
+ void test_msServiceNameShouldFollowRegex() throws Exception{
+ request.setServiceName("ms-1");
+ Set<ConstraintViolation<MicroserviceCreateRequest>> violations = validator.validate(request);
+ Assertions.assertThat(violations.size()).isEqualTo(1);
+ }
+
+ @Test
+ void test_userShouldNotBeBlank(){
+ request.setUser(" ");
+ Set<ConstraintViolation<MicroserviceCreateRequest>> violations = validator.validate(request);
+ Assertions.assertThat(violations.size()).isEqualTo(1);
+ }
+}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/SpecificationControllerTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/SpecificationControllerTest.java
new file mode 100644
index 0000000..64f9c00
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/SpecificationControllerTest.java
@@ -0,0 +1,79 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web;
+
+import org.onap.dcaegen2.platform.mod.model.specification.DeploymentType;
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.onap.dcaegen2.platform.mod.web.controller.SpecificationController;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.springframework.test.web.servlet.MockMvc;
+
+import static org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother.asJsonString;
+import static org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother.MS_INSTANCE_ID;
+import static org.onap.dcaegen2.platform.mod.objectmothers.SpecificationObjectMother.getMockSpecification;
+import static org.onap.dcaegen2.platform.mod.objectmothers.SpecificationObjectMother.getSpecificationRequest;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.Mockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@ExtendWith(SpringExtension.class)
+@WebMvcTest(SpecificationController.class)
+public class SpecificationControllerTest {
+
+ @Autowired
+ MockMvc mockMvc;
+
+ @MockBean
+ private SpecificationService mockSpecificationService;
+
+ @BeforeEach
+ void setup() {
+ }
+
+ @Test
+ void test_addSpecification_returnsSpecification() throws Exception {
+ //arrange
+ SpecificationRequest specificationRequest = getSpecificationRequest();
+ Specification specification = getMockSpecification(DeploymentType.DOCKER);
+
+ when(mockSpecificationService.createSpecification(MS_INSTANCE_ID, specificationRequest)).thenReturn(specification);
+
+ //act/assert
+ mockMvc.perform(post("/api/specification/" + MS_INSTANCE_ID)
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(asJsonString(specificationRequest)).accept(MediaType.APPLICATION_JSON))
+ .andExpect(jsonPath("$.id", notNullValue()))
+ .andExpect(status().isCreated());
+ verify(mockSpecificationService, times(1)).createSpecification(MS_INSTANCE_ID, specificationRequest);
+ }
+
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsInstanceServiceImplTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsInstanceServiceImplTest.java
new file mode 100644
index 0000000..1d84b60
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsInstanceServiceImplTest.java
@@ -0,0 +1,209 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.MsInstanceInfo;
+import org.onap.dcaegen2.platform.mod.model.exceptions.msinstance.MsInstanceNotFoundException;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.MsInstanceRequest;
+import org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother;
+import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother;
+import org.onap.dcaegen2.platform.mod.web.service.basemicroservice.MsService;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactService;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceGateway;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceServiceImpl;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceStatusChangeHandler;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+
+import static org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class MsInstanceServiceImplTest {
+
+ @Spy
+ private MsInstanceServiceImpl service = new MsInstanceServiceImpl();
+
+ @Mock
+ private MsInstanceGateway msInstanceRepository;
+
+ @Mock
+ private MsService msService;
+
+ @Mock
+ private SpecificationService specificationService;
+
+ @Mock
+ private DeploymentArtifactService deploymentArtifactService;
+
+ @Mock
+ private MsInstanceStatusChangeHandler msInstanceStatusChangeHandler;
+
+
+ @BeforeEach
+ void setUp() {
+ service.setMsService(msService);
+ service.setSpecificationService(specificationService);
+ service.setDeploymentArtifactService(deploymentArtifactService);
+ service.setMsInstanceRepository(msInstanceRepository);
+ service.setMsInstanceStatusChangeHandler(msInstanceStatusChangeHandler);
+ }
+
+ @Test
+ void getAll() {
+ MsInstance instance_1 = MsInstance.builder().id("123").build();
+ MsInstance instance_2 = MsInstance.builder().id("345").build();
+
+ when(msInstanceRepository.findAll()).thenReturn(Arrays.asList(instance_1, instance_2));
+
+ List<MsInstance> instances = service.getAll();
+
+ assertThat(instances.size()).isEqualTo(2);
+ verify(msInstanceRepository, times(1)).findAll();
+ }
+
+ @Test
+ void test_getMsInstanceById() throws Exception{
+ MsInstance expected = MsInstanceObjectMother.createMsInstance();
+
+ when(msInstanceRepository.findById(MS_INSTANCE_ID)).thenReturn(Optional.of(expected));
+
+ MsInstance original = service.getMsInstanceById(MS_INSTANCE_ID);
+
+ assertThat(original.getId()).isEqualTo(expected.getId());
+ }
+
+ @Test
+ void test_msIntanceNotFound_willRaiseException() throws Exception{
+ when(msInstanceRepository.findById(MS_INSTANCE_ID)).thenReturn(Optional.empty());
+ assertThatExceptionOfType(MsInstanceNotFoundException.class).isThrownBy(
+ () -> service.getMsInstanceById(MS_INSTANCE_ID));
+ }
+
+ //TODO require cleaning and more assertions
+ @Test
+ void createMicroserviceInstance() {
+
+ BaseMicroservice microservice = BaseMsObjectMother.createMockMsObject();
+ MsInstanceRequest request = getMsInstanceMockRequest();
+ MsInstance msInstanceMockDao = createMsInstance();
+
+ when(msService.getMicroserviceByName(BaseMsObjectMother.BASE_MS_NAME)).thenReturn(microservice);
+ when(msInstanceRepository.findByNameAndRelease(request.getName(), request.getRelease()))
+ .thenReturn(Optional.empty());
+ when(msInstanceRepository.save(any())).thenReturn(msInstanceMockDao);
+
+ MsInstance msInstance = service.createMicroserviceInstance(BaseMsObjectMother.BASE_MS_NAME,request);
+
+ assertThat(msInstance.getId()).isEqualTo(msInstance.getId());
+ assertThat(msInstance.getName()).isEqualTo(msInstance.getName());
+ assertThat(msInstance.getMsInfo().keySet()).isEqualTo(msInstanceMockDao.getMsInfo().keySet());
+
+ verify(msService, times(1)).getMicroserviceByName(BaseMsObjectMother.BASE_MS_NAME);
+ verify(msInstanceRepository, times(1)).save(any(MsInstance.class));
+ verify(msService, times(1)).
+ saveMsInstanceReferenceToMs(microservice, msInstance);
+
+ }
+
+ @Test
+ void test_updateMsInstance() {
+
+ }
+
+ @Test
+ void updateStatusBasedOnDeploymentArtifactsStatuses() {
+ MsInstance msInstance = MsInstanceObjectMother.getMsInstanceWithExistingDeploymentArtifactRef();
+ when(msInstanceRepository.findById(msInstance.getId())).thenReturn(Optional.of(msInstance));
+
+ service.updateStatusBasedOnDeploymentArtifactsStatuses(msInstance.getId());
+
+ verify(msInstanceStatusChangeHandler, times(1)).updateStatusBasedOnDeploymentArtifactsStatuses(msInstance);
+ verify(service, times(1)).updateMsInstance(msInstance);
+
+ }
+
+ @Test
+ void test_removeDeploymentArtifactFromMsInstance() {
+ MsInstance msInstance = MsInstanceObjectMother.getMsInstanceWithExistingDeploymentArtifactRef();
+ DeploymentArtifact deploymentArtifact = createDeploymentArtifact(msInstance);
+
+ when(msInstanceRepository.findById(msInstance.getId())).thenReturn(Optional.of(msInstance));
+ //when(msInstanceStatusChangeHandler.updateStatusBasedOnDeploymentArtifactsStatuses(any())).thenReturn(msInstance);
+
+ service.removeDeploymentArtifactFromMsInstance(deploymentArtifact);
+
+ assertThat(msInstance.getDeploymentArtifactsInfo().getDeploymentArtifacts().contains(deploymentArtifact.getId())).isFalse();
+ verify(msInstanceStatusChangeHandler, times(1)).updateStatusBasedOnDeploymentArtifactsStatuses(msInstance);
+ verify(service, times(1)).updateMsInstance(msInstance);
+
+ }
+
+ @Test
+ void updateMicroserviceReference() throws Exception{
+ BaseMicroservice microservice = BaseMsObjectMother.createMockMsObject();
+ MsInstance msInstance_1 = MsInstanceObjectMother.getMsInstanceWithExistingDeploymentArtifactRef();
+ msInstance_1.setId("instance-1");
+ msInstance_1.getMsInfo().put("name", "old-ms");
+ MsInstance msInstance_2 = MsInstanceObjectMother.getMsInstanceWithExistingDeploymentArtifactRef();
+ msInstance_2.setId("instance-2");
+ msInstance_2.getMsInfo().put("name", "old-ms");
+
+ when(msInstanceRepository.findById("instance-1")).thenReturn(Optional.of(msInstance_1));
+ when(msInstanceRepository.findById("instance-2")).thenReturn(Optional.of(msInstance_2));
+
+ service.updateMicroserviceReference(microservice);
+
+ assertThat(msInstance_1.getName()).isEqualTo(microservice.getName());
+ assertThat(msInstance_2.getName()).isEqualTo(microservice.getName());
+
+ assertThat(msInstance_1.getMsInfo().get("name")).isEqualTo(microservice.getName());
+ assertThat(msInstance_2.getMsInfo().get("name")).isEqualTo(microservice.getName());
+
+ verify(service, times(2)).getMsInstanceById(anyString());
+ verify(msInstanceRepository, times(2)).save(any(MsInstance.class));
+ }
+
+ private DeploymentArtifact createDeploymentArtifact(MsInstance msInstance) {
+ DeploymentArtifact deploymentArtifact = new DeploymentArtifact();
+ deploymentArtifact.setId(msInstance.getDeploymentArtifactsInfo().getDeploymentArtifacts().get(0));
+
+ MsInstanceInfo msInstanceInfo = new MsInstanceInfo();
+ msInstanceInfo.setId(msInstance.getId());
+ deploymentArtifact.setMsInstanceInfo(msInstanceInfo);
+ return deploymentArtifact;
+ }
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsInstanceStatusChangeHandlerTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsInstanceStatusChangeHandlerTest.java
new file mode 100644
index 0000000..9339b26
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsInstanceStatusChangeHandlerTest.java
@@ -0,0 +1,92 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service;
+
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstanceStatus;
+import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother;
+import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother;
+import org.onap.dcaegen2.platform.mod.web.service.deploymentartifact.DeploymentArtifactService;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceStatusChangeHandler;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class MsInstanceStatusChangeHandlerTest {
+
+ MsInstanceStatusChangeHandler statusChangeHandler;
+
+ @Mock
+ MsInstanceService msInstanceService;
+
+ @Mock
+ DeploymentArtifactService deploymentArtifactService;
+
+ @BeforeEach
+ void setup() throws Exception{
+ statusChangeHandler = new MsInstanceStatusChangeHandler();
+ statusChangeHandler.setMsInstanceService(msInstanceService);
+ statusChangeHandler.setDeploymentArtifactService(deploymentArtifactService);
+ }
+
+ @Test
+ void handleStatusChangeFromDeploymentArtifactsWithDevComplete() {
+ //arrange
+ MsInstance msInstance = MsInstanceObjectMother.getMsInstanceWithExistingDeploymentArtifactRef();
+
+ when(deploymentArtifactService.findByMsInstanceId(msInstance.getId())).thenReturn(
+ DeploymentArtifactObjectMother.createMockDeploymentArtifactsWithDifferentStatuses(true)
+ );
+
+ //act
+ statusChangeHandler.updateStatusBasedOnDeploymentArtifactsStatuses(msInstance);
+
+ //assert
+ assertThat(msInstance.getStatus()).isEqualTo(MsInstanceStatus.DEV_COMPLETE);
+ verify(deploymentArtifactService, times(1)).findByMsInstanceId(msInstance.getId());
+ }
+
+ @Test
+ void handleStatusChangeFromDeploymentArtifactsWithoutDevComplete() {
+ //arrange
+ MsInstance msInstance = MsInstanceObjectMother.getMsInstanceWithExistingDeploymentArtifactRef();
+
+ //when(msInstanceService.getMsInstanceById(msInstance.getId())).thenReturn(msInstance);
+ when(deploymentArtifactService.findByMsInstanceId(msInstance.getId())).thenReturn(
+ DeploymentArtifactObjectMother.createMockDeploymentArtifactsWithDifferentStatuses(false)
+ );
+
+ //act
+ statusChangeHandler.updateStatusBasedOnDeploymentArtifactsStatuses(msInstance);
+
+ //assert
+ assertThat(msInstance.getStatus()).isEqualTo(MsInstanceStatus.IN_DEV);
+ verify(deploymentArtifactService, times(1)).findByMsInstanceId(msInstance.getId());
+ }
+
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsServiceImplTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsServiceImplTest.java
new file mode 100644
index 0000000..8604f1a
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/MsServiceImplTest.java
@@ -0,0 +1,217 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service;
+
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMicroservice;
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsLocation;
+import org.onap.dcaegen2.platform.mod.model.basemicroservice.BaseMsType;
+import org.onap.dcaegen2.platform.mod.model.exceptions.ResourceConflictException;
+import org.onap.dcaegen2.platform.mod.model.exceptions.basemicroservice.BaseMicroserviceNotFoundException;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceCreateRequest;
+import org.onap.dcaegen2.platform.mod.model.restapi.MicroserviceUpdateRequest;
+import org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother;
+import org.onap.dcaegen2.platform.mod.web.service.basemicroservice.BaseMicroserviceGateway;
+import org.onap.dcaegen2.platform.mod.web.service.basemicroservice.MsServiceImpl;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.*;
+
+import static org.onap.dcaegen2.platform.mod.model.exceptions.ErrorMessages.MICROSERVICE_NAME_CONFLICT_MESSAGE;
+import static org.onap.dcaegen2.platform.mod.model.exceptions.ErrorMessages.MICROSERVICE_TAG_CONFLICT_MESSAGE;
+import static org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother.createMockMsObject;
+import static org.onap.dcaegen2.platform.mod.objectmothers.BaseMsObjectMother.createMockMsRequest;
+import static org.assertj.core.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class MsServiceImplTest {
+
+ @Mock
+ private BaseMicroserviceGateway repository;
+
+ @Mock
+ private MsInstanceService msInstanceService;
+
+ @Spy
+ private MsServiceImpl baseMsService = new MsServiceImpl();
+
+ @BeforeEach
+ void setup() throws Exception{
+ baseMsService.setRepository(repository);
+ baseMsService.setMsInstanceService(msInstanceService);
+ }
+
+ /**GET MICROSERVICE TESTS*/
+ @Test
+ void getAll() {
+ //arrange
+ BaseMicroservice ms1 = new BaseMicroservice();
+ ms1.setName("HelloWorld1");
+ BaseMicroservice ms2 = new BaseMicroservice();
+ ms2.setName("HelloWorld2");
+
+ when(repository.findAll()).thenReturn(Arrays.asList(ms1, ms2));
+
+ //act
+ List<BaseMicroservice> microservices = baseMsService.getAllMicroservices();
+
+ //assert
+ assertThat(microservices).hasSizeGreaterThan(0);
+ }
+
+ @Test
+ void test_getMicroserviceById() throws Exception{
+ BaseMicroservice expectedMicroservice = BaseMsObjectMother.createMockMsObject();
+ String baseMsId = BaseMsObjectMother.BASE_MS_ID;
+
+ when(repository.findById(baseMsId)).thenReturn(Optional.of(expectedMicroservice));
+
+ BaseMicroservice resultMicroservice = baseMsService.getMicroserviceById(baseMsId);
+
+ assertThat(resultMicroservice).isEqualTo(expectedMicroservice);
+ verify(repository, times(1)).findById(baseMsId);
+ }
+
+ @Test
+ void test_ifMicroserviceNotFoundRaiseException() throws Exception{
+ BaseMicroservice expectedMicroservice = BaseMsObjectMother.createMockMsObject();
+ String baseMsId = BaseMsObjectMother.BASE_MS_ID;
+
+ when(repository.findById(baseMsId)).thenReturn(Optional.empty());
+
+ assertThatExceptionOfType(BaseMicroserviceNotFoundException.class).isThrownBy(
+ () -> baseMsService.getMicroserviceById(baseMsId)
+ );
+ }
+
+ /**CREATE MICROSERVICE TESTS*/
+ @Test
+ void createMicroservice() {
+ //arrange
+ MicroserviceCreateRequest microserviceRequest = createMockMsRequest();
+ BaseMicroservice expected = createMockMsObject();
+
+ when(repository.save(any())).thenReturn(expected);
+
+ //act
+ BaseMicroservice actual = baseMsService.createMicroservice(microserviceRequest);
+
+ //assert
+ assertThat(actual.getMetadata().getCreatedBy()).isEqualTo(microserviceRequest.getUser());
+ assertThat(actual.getMetadata().getUpdatedBy()).isEqualTo(microserviceRequest.getUser());
+ }
+
+ @Test
+ void AddingMsWithDuplicateName_shouldThrowException() throws Exception{
+ //arrange
+ MicroserviceCreateRequest microserviceRequest = createMockMsRequest();
+ BaseMicroservice existedMicroservice = createMockMsObject();
+
+ when(repository.findByName(any())).thenReturn(Optional.of(existedMicroservice));
+
+ //act/assert
+ assertThatThrownBy(() -> baseMsService.createMicroservice((microserviceRequest)))
+ .isInstanceOf(ResourceConflictException.class)
+ .hasMessage(MICROSERVICE_NAME_CONFLICT_MESSAGE);
+ }
+ @Test
+ void AddingMsWithDuplicateTag_shouldThrowException() throws Exception{
+ //arrange
+ MicroserviceCreateRequest microserviceRequest = createMockMsRequest();
+ BaseMicroservice existedMicroservice = createMockMsObject();
+
+ when(repository.findByTag(any())).thenReturn(Optional.of(existedMicroservice));
+
+ //act/assert
+ assertThatThrownBy(() -> baseMsService.createMicroservice((microserviceRequest)))
+ .isInstanceOf(ResourceConflictException.class)
+ .hasMessage(MICROSERVICE_TAG_CONFLICT_MESSAGE);
+ }
+
+ /**UPDATE MICROSERVICE TESTS*/
+ @Test
+ void test_updateMicroservice() throws Exception{
+ MicroserviceUpdateRequest updateRequest = createUpdateMsRequest();
+
+ BaseMicroservice msToBeUpdated = BaseMsObjectMother.createMockMsObject();
+ Date updateTimeBefore = new Date(msToBeUpdated.getMetadata().getUpdatedOn().getTime());
+
+ String baseMsId = BaseMsObjectMother.BASE_MS_ID;
+
+ when(repository.findById(baseMsId)).thenReturn(Optional.of(msToBeUpdated));
+
+ baseMsService.updateMicroservice(baseMsId, updateRequest);
+
+ //assert
+ assertUpdatedMsFileds(updateRequest, msToBeUpdated, updateTimeBefore);
+ verify(baseMsService, times(1)).getMicroserviceById(baseMsId);
+ verify(msInstanceService, times(1)).updateMicroserviceReference(msToBeUpdated);
+ verify(repository, times(1)).save(msToBeUpdated);
+ }
+
+/* @Test
+ void test_msTagChangeShouldNotBeAllowed() throws Exception{
+ MicroserviceCreateRequest updateRequest = new MicroserviceCreateRequest();
+ updateRequest.setTag("updateTag");
+ String baseMsId = BaseMsObjectMother.BASE_MS_ID;
+
+ assertThatExceptionOfType(OperationNotAllowedException.class).isThrownBy(
+ () -> baseMsService.updateMicroservice(baseMsId, updateRequest)
+ );
+ }*/
+
+ private void assertUpdatedMsFileds(MicroserviceUpdateRequest updateRequest, BaseMicroservice msToBeUpdated,
+ Date updateTimeBefore) {
+ assertThat(msToBeUpdated.getName()).isEqualTo(updateRequest.getName());
+ assertThat(msToBeUpdated.getLocation()).isEqualTo(updateRequest.getLocation());
+ assertThat(msToBeUpdated.getServiceName()).isEqualTo(updateRequest.getServiceName());
+ assertThat(msToBeUpdated.getNamespace()).isEqualTo(updateRequest.getNamespace());
+ assertThat(msToBeUpdated.getType()).isEqualTo(updateRequest.getType());
+
+ assertThat(msToBeUpdated.getMetadata().getUpdatedBy()).isEqualTo(updateRequest.getUser());
+ assertThat(msToBeUpdated.getMetadata().getUpdatedOn()).isNotEqualTo(updateTimeBefore);
+
+ assertThat(msToBeUpdated.getMetadata().getNotes()).isEqualTo(updateRequest.getMetadata().get("notes"));
+ assertThat(msToBeUpdated.getMetadata().getLabels()).isEqualTo(updateRequest.getMetadata().get("labels"));
+ }
+
+ private MicroserviceUpdateRequest createUpdateMsRequest() {
+ MicroserviceUpdateRequest updateRequest = new MicroserviceUpdateRequest();
+ updateRequest.setName("updatedName");
+ updateRequest.setLocation(BaseMsLocation.EDGE);
+ updateRequest.setServiceName("updatedServiceName");
+ updateRequest.setNamespace("updatedNameSpace");
+ updateRequest.setType(BaseMsType.ANALYTIC);
+ updateRequest.setUser("updater");
+
+ Map<String, Object> metadata = new HashMap();
+ metadata.put("notes", "updatedNote");
+ metadata.put("labels", Arrays.asList("updatedLabel1", "updatedLabel2"));
+ updateRequest.setMetadata(metadata);
+ return updateRequest;
+ }
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/SpecificationServiceTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/SpecificationServiceTest.java
new file mode 100644
index 0000000..dff0727
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/SpecificationServiceTest.java
@@ -0,0 +1,103 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service;
+
+import org.onap.dcaegen2.platform.mod.model.specification.DeploymentType;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.SpecificationRequest;
+import org.onap.dcaegen2.platform.mod.model.specification.Specification;
+import org.onap.dcaegen2.platform.mod.model.specification.SpecificationStatus;
+import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationGateway;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationServiceImpl;
+import org.onap.dcaegen2.platform.mod.web.service.specification.SpecificationValidatorService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother.MS_INSTANCE_ID;
+import static org.onap.dcaegen2.platform.mod.objectmothers.SpecificationObjectMother.getMockSpecification;
+import static org.onap.dcaegen2.platform.mod.objectmothers.SpecificationObjectMother.getSpecificationRequest;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+@ExtendWith({MockitoExtension.class})
+public class SpecificationServiceTest {
+
+ private SpecificationServiceImpl service;
+
+ @Mock
+ private SpecificationGateway specRepo;
+
+ @Mock
+ private MsInstanceService msInstanceService;
+
+ @Mock
+ private SpecificationValidatorService validatorService;
+
+ @BeforeEach
+ void setUp() {
+ service = new SpecificationServiceImpl();
+ service.setMsInstanceService(msInstanceService);
+ service.setSpecificationValidatorService(validatorService);
+ service.setSpecificationGateway(specRepo);
+ }
+
+ @Test
+ void createSpecificationTest() throws Exception {
+ //given
+ SpecificationRequest request = getSpecificationRequest();
+ Specification specFromRepo = getMockSpecification(DeploymentType.K8S);
+ MsInstance msInstance = MsInstanceObjectMother.createMsInstance();
+
+ when(msInstanceService.getMsInstanceById(MS_INSTANCE_ID)).thenReturn(msInstance);
+ when(specRepo.save(any(Specification.class))).thenReturn(specFromRepo);
+
+ //when
+ Specification spec = service.createSpecification(MS_INSTANCE_ID, request);
+
+ //then
+ assertThatFieldsAreCorrect(request, spec);
+ verifyCalls(request, msInstance);
+
+ }
+
+ private void assertThatFieldsAreCorrect(SpecificationRequest request, Specification spec) {
+ assertThat(spec.getStatus()).isEqualTo(SpecificationStatus.ACTIVE);
+ assertThat(spec.getSpecContent()).isEqualTo(request.getSpecContent());
+ assertThat(spec.getPolicyJson()).isEqualTo(request.getPolicyJson());
+ assertThat(spec.getType()).isEqualTo(request.getType());
+ assertThat(spec.getMetadata().get("createdBy")).isEqualTo(request.getUser());
+ assertThat(spec.getMetadata().get("createdOn")).isNotNull();
+ assertThat(spec.getMsInstanceInfo()).isNotNull();
+ }
+
+ private void verifyCalls(SpecificationRequest request, MsInstance msInstance) {
+ verify(msInstanceService, times(1)).getMsInstanceById(MS_INSTANCE_ID);
+ verify(validatorService, times(1)).validateSpecForRelease(request, msInstance.getRelease());
+ verify(specRepo, times(2)).save(any(Specification.class));
+ verify(msInstanceService, times(1)).updateMsInstance(msInstance);
+ }
+}
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/ArtifactFileNameCreatorTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/ArtifactFileNameCreatorTest.java
new file mode 100644
index 0000000..12a7dd2
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/ArtifactFileNameCreatorTest.java
@@ -0,0 +1,89 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.specification.DeploymentType;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.BlueprintFileNameCreateException;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+
+class ArtifactFileNameCreatorTest {
+
+ private ArtifactFileNameCreator fileNameCreator;
+
+ @BeforeEach
+ void setUp() {
+ fileNameCreator = new ArtifactFileNameCreator();
+ }
+
+ @Test
+ void test_createCorrectBlueprintFileName() throws Exception{
+ //arrange
+ MsInstance msInstance = MsInstanceObjectMother.createMsInstance();
+ String expectedName = createExpectedName(msInstance);
+
+ //act
+ String fileName = fileNameCreator.createFileName(msInstance, 1);
+
+ //assert
+ Assertions.assertThat(fileName).isEqualTo(expectedName);
+ }
+
+ @Test
+ void test_missingTagForFileNameCreation_ShouldRaiseException() throws Exception{
+
+ //arrange
+ MsInstance msInstance = MsInstanceObjectMother.createMsInstance();
+ msInstance.setMsInfo(new HashMap<>());
+
+ Assertions.assertThatExceptionOfType(BlueprintFileNameCreateException.class).isThrownBy(
+ () -> fileNameCreator.createFileName(msInstance, 1)
+ );
+ }
+
+ @Test
+ void test_missingSpecForFileNameCreation_ShouldRaiseException() throws Exception{
+
+ //arrange
+ MsInstance msInstance = MsInstanceObjectMother.createMsInstance();
+ msInstance.setActiveSpec(null);
+
+ Assertions.assertThatExceptionOfType(BlueprintFileNameCreateException.class).isThrownBy(
+ () -> fileNameCreator.createFileName(msInstance, 1)
+ );
+ }
+
+
+ private String createExpectedName(MsInstance msInstance) {
+ String fileName = MsInstanceObjectMother.BASE_MS_TAG + "_"
+ + DeploymentType.DOCKER.toString().toLowerCase() + "_"
+ + msInstance.getRelease() + "_"
+ + "1"
+ + ".yaml";
+
+ return fileName;
+ }
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java
new file mode 100644
index 0000000..749d8b1
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java
@@ -0,0 +1,250 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.DeploymentArtifactNotFound;
+import org.onap.dcaegen2.platform.mod.model.microserviceinstance.MsInstance;
+import org.onap.dcaegen2.platform.mod.model.restapi.DeploymentArtifactPatchRequest;
+import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother;
+import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother;
+import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+
+import static org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class DeploymentArtifactServiceImplTest {
+
+ private DeploymentArtifactServiceImpl deploymentArtifactService;
+
+ @Mock
+ private MsInstanceService msInstanceService;
+
+ @Mock
+ private DeploymentArtifactGeneratorStrategy deploymentArtifactGeneratorStrategy;
+
+ @Mock
+ private DeploymentArtifactGateway repository;
+
+ @Mock
+ private ArtifactFileNameCreator fileNameCreator;
+
+ @Mock
+ private DeploymentArtifactStatusChangeHandler deploymentArtifactStatusChangeHandler;
+
+ private MsInstance msInstance;
+
+ DeploymentArtifact deploymentArtifact;
+
+ @BeforeEach
+ void setUp() {
+ //Initiated the deployment artifact core with mocks
+ deploymentArtifactService = new DeploymentArtifactServiceImpl();
+ deploymentArtifactService.setDeploymentArtifactGeneratorStrategy(deploymentArtifactGeneratorStrategy);
+ deploymentArtifactService.setDeploymentArtifactGateway(repository);
+ deploymentArtifactService.setMsInstanceService(msInstanceService);
+ deploymentArtifactService.setFileNameCreator(fileNameCreator);
+ deploymentArtifactService.setStatusChangeHandler(deploymentArtifactStatusChangeHandler);
+ }
+
+ private void setupMockBehaviours() {
+ //Mock methods
+ deploymentArtifact = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+ msInstance = MsInstanceObjectMother.createMsInstance();
+
+ when(deploymentArtifactGeneratorStrategy.generateForRelease(msInstance.getActiveSpec(), msInstance.getRelease()))
+ .thenReturn(DeploymentArtifactObjectMother.createBlueprintResponse());
+ when(repository.save(any())).thenReturn(deploymentArtifact);
+ when(fileNameCreator.createFileName(any(MsInstance.class), any(Integer.class))).thenReturn(BASE_MS_TAG + "_" +
+ msInstance.getActiveSpec().getType().toString().toLowerCase() + "_" + msInstance.getRelease() + "_1.yaml");
+ }
+
+ @Test
+ void test_getAllDeploymentArtifactInstance() throws Exception{
+ when(repository.findAll()).thenReturn(Arrays.asList(deploymentArtifact));
+ List<DeploymentArtifact> deployments = deploymentArtifactService.getAllDeploymentArtifacts();
+ assertThat(deployments.size()).isEqualTo(1);
+ }
+
+ @Test
+ void test_GenerateBlueprint_shouldReturnCorrectBlueprint() throws Exception{
+
+ setupMockBehaviours();
+ when(msInstanceService.getMsInstanceById(MS_INSTANCE_ID)).thenReturn(msInstance);
+
+ //act
+ DeploymentArtifact resultDAO = deploymentArtifactService.generateDeploymentArtifact(MS_INSTANCE_ID, USER);
+
+ //assert
+ verify(msInstanceService, atLeastOnce()).getMsInstanceById(MS_INSTANCE_ID);
+ verify(repository, times(1)).save(any());
+ assertThat(resultDAO.getContent()).contains("tosca_definitions_version");
+ assertThat(resultDAO.getId()).isNotEmpty();
+ assertThat(resultDAO.getVersion()).isEqualTo(1);
+ assertThat(resultDAO.getStatus()).isEqualTo(DeploymentArtifactStatus.IN_DEV);
+ assertThat(resultDAO.getMsInstanceInfo().getId()).isEqualTo(MS_INSTANCE_ID);
+ assertThat(resultDAO.getMsInstanceInfo().getName()).isEqualTo(msInstance.getName());
+ assertThat(resultDAO.getMsInstanceInfo().getRelease()).isEqualTo(msInstance.getRelease());
+ assertThat(resultDAO.getSpecificationInfo().get("id")).isNotNull();
+ assertThat(resultDAO.getMetadata().get("createdBy")).isEqualTo(USER);
+
+ }
+
+ @Test
+ void test_deploymentVersionIsInitatedWith1() throws Exception{
+ setupMockBehaviours();
+ when(msInstanceService.getMsInstanceById(MS_INSTANCE_ID)).thenReturn(msInstance);
+ DeploymentArtifact resultDAO = deploymentArtifactService.generateDeploymentArtifact(MS_INSTANCE_ID, USER);
+ assertThat(resultDAO.getVersion()).isEqualTo(1);
+ }
+
+ @Test
+ void test_deploymentVersionIncrementsForEachAddForAnInstance() throws Exception{
+ setupMockBehaviours();
+ MsInstance msInstanceWithRef = MsInstanceObjectMother.getMsInstanceWithExistingDeploymentArtifactRef();
+ when(msInstanceService.getMsInstanceById(MS_INSTANCE_ID)).thenReturn(msInstanceWithRef);
+
+ DeploymentArtifact resultDAO = deploymentArtifactService.generateDeploymentArtifact(MS_INSTANCE_ID, USER);
+
+ assertThat(resultDAO.getVersion()).isEqualTo(2);
+ }
+
+ @Test
+ void test_deploymentArtifactRefAddedToMsInstanceForFirstTime() throws Exception{
+ setupMockBehaviours();
+ when(msInstanceService.getMsInstanceById(MS_INSTANCE_ID)).thenReturn(msInstance);
+
+ DeploymentArtifact resultDAO = deploymentArtifactService.generateDeploymentArtifact(MS_INSTANCE_ID, USER);
+ assertThat(msInstance.getDeploymentArtifactsInfo().getMostRecentVersion()).isEqualTo(1);
+
+ List<String> deploymentArtifactList = msInstance.getDeploymentArtifactsInfo().getDeploymentArtifacts();
+ assertThat(deploymentArtifactList.size()).isEqualTo(1);
+ assertThat(deploymentArtifactList.get(0)).isEqualTo(resultDAO.getId());
+ }
+
+ @Test
+ void test_deploymentArtifactRefAddedToMsInstanceForSecondTime() throws Exception{
+ setupMockBehaviours();
+ MsInstance msInstanceWithRef = MsInstanceObjectMother.getMsInstanceWithExistingDeploymentArtifactRef();
+ when(msInstanceService.getMsInstanceById(MS_INSTANCE_ID)).thenReturn(msInstanceWithRef);
+
+ DeploymentArtifact resultDAO = deploymentArtifactService.generateDeploymentArtifact(MS_INSTANCE_ID, USER);
+ assertThat(msInstanceWithRef.getDeploymentArtifactsInfo().getMostRecentVersion()).isEqualTo(2);
+
+ List<String> deploymentArtifactList = msInstanceWithRef.getDeploymentArtifactsInfo().getDeploymentArtifacts();
+ assertThat(deploymentArtifactList.size()).isEqualTo(2);
+ assertThat(deploymentArtifactList.get(1)).isEqualTo(resultDAO.getId());
+ }
+
+ @Test
+ void test_ifMsInstanceIsPersistedAfterDeploymentArtifactCreation() throws Exception{
+ setupMockBehaviours();
+ when(msInstanceService.getMsInstanceById(MS_INSTANCE_ID)).thenReturn(msInstance);
+ deploymentArtifactService.generateDeploymentArtifact(MS_INSTANCE_ID, USER);
+ verify(msInstanceService, times(1)).updateMsInstance(msInstance);
+ }
+
+ @Test
+ void test_blueprintFileNameValidation() throws Exception{
+ setupMockBehaviours();
+ when(msInstanceService.getMsInstanceById(MS_INSTANCE_ID)).thenReturn(msInstance);
+ DeploymentArtifact resultDAO = deploymentArtifactService.generateDeploymentArtifact(MS_INSTANCE_ID, USER);
+ System.out.println(resultDAO.getFileName());
+ assertThat(resultDAO.getFileName().contains(BASE_MS_TAG)).isTrue();
+ }
+
+ @Test
+ void test_updateStatusForDeploymentArtifact() throws Exception{
+ //arrange
+ deploymentArtifact = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+
+ DeploymentArtifactPatchRequest dtoWithStatus = new DeploymentArtifactPatchRequest();
+ dtoWithStatus.setStatus(DeploymentArtifactStatus.NOT_NEEDED);
+
+ when(repository.findById("id-123")).thenReturn(Optional.of(deploymentArtifact));
+
+ //Mocking void method from DeploymentArtifactStatusChangeHandler
+ doAnswer(invocation -> {
+ deploymentArtifact.setStatus(DeploymentArtifactStatus.NOT_NEEDED);
+ return null;
+ }).when(deploymentArtifactStatusChangeHandler).handleStatusChange(dtoWithStatus.getStatus(), deploymentArtifact);
+
+ //act
+ deploymentArtifactService.updateDeploymentArtifact("id-123", dtoWithStatus, "user1");
+
+ //assert
+ assertThat(deploymentArtifact.getStatus()).isEqualTo(DeploymentArtifactStatus.NOT_NEEDED);
+ assertThat(deploymentArtifact.getMetadata().get("updatedBy")).isEqualTo("user1");
+ assertThat(deploymentArtifact.getMetadata().get("updatedOn")).isNotNull();
+
+ verify(deploymentArtifactStatusChangeHandler, times(1)).handleStatusChange(dtoWithStatus.getStatus(),
+ deploymentArtifact);
+ verify(msInstanceService, times(1)).
+ updateStatusBasedOnDeploymentArtifactsStatuses(deploymentArtifact.getMsInstanceInfo().getId());
+ verify(repository, times(1)).save(deploymentArtifact);
+ }
+
+ @Test
+ void test_findDeploymentArtifactById() throws Exception{
+ //arrange
+ deploymentArtifact = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+ when(repository.findById("id-123")).thenReturn(Optional.of(deploymentArtifact));
+
+ DeploymentArtifact result = deploymentArtifactService.findDeploymentArtifactById("id-123");
+
+ assertThat(result).isEqualTo(deploymentArtifact);
+ }
+
+ @Test
+ void test_findByIdWithInvalidId() throws Exception{
+ when(repository.findById("invalid-id")).thenReturn(Optional.empty());
+ assertThatExceptionOfType(DeploymentArtifactNotFound.class).isThrownBy(
+ () -> deploymentArtifactService.findDeploymentArtifactById("invalid-id"));
+ }
+
+ @Test
+ void test_deleteDeploymentArtifact() throws Exception{
+ DeploymentArtifact deploymentArtifact =
+ DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+ String id = deploymentArtifact.getId();
+
+ when(repository.findById(id)).thenReturn(Optional.of(deploymentArtifact));
+
+ deploymentArtifactService.deleteDeploymentArtifact(id);
+ verify(msInstanceService, times(1))
+ .removeDeploymentArtifactFromMsInstance(deploymentArtifact);
+ verify(repository, times(1)).deleteById(id);
+ }
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactStatusChangeHandlerTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactStatusChangeHandlerTest.java
new file mode 100644
index 0000000..5e9acfa
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactStatusChangeHandlerTest.java
@@ -0,0 +1,106 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.model.exceptions.deploymentartifact.StatusChangeNotValidException;
+import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class DeploymentArtifactStatusChangeHandlerTest {
+
+ DeploymentArtifactStatusChangeHandler artifactStatusChangeHandler;
+
+ @Mock
+ DeploymentArtifactService deploymentArtifactService;
+
+ @BeforeEach
+ void setUp() {
+ artifactStatusChangeHandler = new DeploymentArtifactStatusChangeHandler();
+ artifactStatusChangeHandler.setDeploymentArtifactService(deploymentArtifactService);
+ }
+
+ @Test
+ void test_DevCompleteToNotNeeded() throws Exception{
+ //arrange
+ List<DeploymentArtifact> mockDeploymentArticats = DeploymentArtifactObjectMother.createMockDeploymentArtifactsWithDifferentStatuses(true);
+ DeploymentArtifact givenDAO = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.DEV_COMPLETE);
+ String msInstaneId = givenDAO.getMsInstanceInfo().getId();
+
+ when(deploymentArtifactService.findByMsInstanceId(msInstaneId)).thenReturn(mockDeploymentArticats);
+
+ //act
+ artifactStatusChangeHandler.handleStatusChange(DeploymentArtifactStatus.NOT_NEEDED, givenDAO);
+
+ assertThat(givenDAO.getStatus()).isEqualTo(DeploymentArtifactStatus.NOT_NEEDED);
+// verify(msInstanceStatusChangeHandler, times(1))
+// .updateStatusBasedOnDeploymentArtifactsStatuses(msInstaneId);
+
+ }
+
+ @Test
+ void test_ValidateIfArtifactWithDevCompleteStatusNotFoundForTheSameInstance() throws Exception{
+ //arrange
+ DeploymentArtifact givenDAO = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+ String msInstaneId = givenDAO.getMsInstanceInfo().getId();
+
+ List<DeploymentArtifact> mockDeploymentArticats = DeploymentArtifactObjectMother.createMockDeploymentArtifactsWithDifferentStatuses(false);
+ when(deploymentArtifactService.findByMsInstanceId(msInstaneId)).thenReturn(mockDeploymentArticats);
+
+ //act
+ artifactStatusChangeHandler.handleStatusChange(DeploymentArtifactStatus.DEV_COMPLETE, givenDAO);
+
+ //assert
+ assertThat(givenDAO.getStatus()).isEqualTo(DeploymentArtifactStatus.DEV_COMPLETE);
+ verify(deploymentArtifactService, times(1)).
+ findByMsInstanceId(givenDAO.getMsInstanceInfo().getId());
+// verify(msInstanceStatusChangeHandler, times(1))
+// .updateStatusBasedOnDeploymentArtifactsStatuses(msInstaneId);
+
+ }
+
+ @Test
+ void DoesntValidateIfArtifactWithDevCompleteStatusAlreadyExistsForTheSameInstance() throws Exception{
+ //arrange
+ DeploymentArtifact givenDAO = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+ List<DeploymentArtifact> mockDeploymentArticats = DeploymentArtifactObjectMother.createMockDeploymentArtifactsWithDifferentStatuses(true);
+ when(deploymentArtifactService.findByMsInstanceId("id-123")).thenReturn(mockDeploymentArticats);
+
+ //act/assert
+ assertThatExceptionOfType(StatusChangeNotValidException.class).isThrownBy(
+ () -> artifactStatusChangeHandler.handleStatusChange(DeploymentArtifactStatus.DEV_COMPLETE, givenDAO)
+ );
+
+ }
+
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/SearchDeploymentArtifactsTest.java b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/SearchDeploymentArtifactsTest.java
new file mode 100644
index 0000000..bc1a3a0
--- /dev/null
+++ b/mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/SearchDeploymentArtifactsTest.java
@@ -0,0 +1,90 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.platform.mod.web.service.deploymentartifact;
+
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifact;
+import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifactStatus;
+import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+@ExtendWith(MockitoExtension.class)
+public class SearchDeploymentArtifactsTest {
+
+ private DeploymentArtifactServiceImpl service;
+
+ @Mock
+ private DeploymentArtifactGateway repository;
+
+ private DeploymentArtifact artifact_1;
+ private DeploymentArtifact artifact_2;
+ private DeploymentArtifact artifact_3;
+
+ @BeforeEach
+ void setUp() {
+ service = new DeploymentArtifactServiceImpl();
+ service.setDeploymentArtifactGateway(repository);
+
+ //given
+ artifact_1 = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.IN_DEV);
+ artifact_1.getMsInstanceInfo().setRelease("2008");
+ artifact_2 = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.DEV_COMPLETE);
+ artifact_2.getMsInstanceInfo().setRelease("2010");
+ artifact_3 = DeploymentArtifactObjectMother.createDeploymentArtifactDAO(DeploymentArtifactStatus.DEV_COMPLETE);
+ artifact_3.getMsInstanceInfo().setRelease("2008");
+
+ }
+
+// @Test
+// void findArtifacts_filteredWithRelease() throws Exception {
+// List<DeploymentArtifact> artifacts = Arrays.asList(artifact_1, artifact_3);
+// when(repository.findByReleaseOrStatusOfMsInstance("2008", null)).thenReturn(artifacts);
+//
+// //when
+// DeploymentArtifactSearch search = new DeploymentArtifactSearch();
+// DeploymentArtifactFilter filter = new DeploymentArtifactFilter();
+// filter.setRelease("2008");
+// search.setFilter(filter);
+//
+// List<DeploymentArtifact> result = core.searchDeploymentArtifacts(search);
+//
+// //assert
+// assertThat(result.size()).isEqualTo(2);
+// }
+//
+// @Test
+// void findArtifacts_filteredWithStatus() throws Exception{
+// List<DeploymentArtifact> artifacts = Arrays.asList(artifact_2, artifact_3);
+// when(repository.findByReleaseOrStatusOfMsInstance(null, DeploymentArtifactStatus.DEV_COMPLETE))
+// .thenReturn(artifacts);
+//
+// DeploymentArtifactSearch search = new DeploymentArtifactSearch();
+// DeploymentArtifactFilter filter = new DeploymentArtifactFilter();
+// filter.setStatus(DeploymentArtifactStatus.DEV_COMPLETE);
+// search.setFilter(filter);
+//
+// List<DeploymentArtifact> result = core.searchDeploymentArtifacts(search);
+// assertThat(result.size()).isEqualTo(2);
+//
+// }
+}
diff --git a/mod2/catalog-service/src/test/resources/application.properties b/mod2/catalog-service/src/test/resources/application.properties
new file mode 100644
index 0000000..d6a913c
--- /dev/null
+++ b/mod2/catalog-service/src/test/resources/application.properties
@@ -0,0 +1 @@
+#spring.data.mongodb.port=0 \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/resources/http/requests/CreateSpecificationRequest.json b/mod2/catalog-service/src/test/resources/http/requests/CreateSpecificationRequest.json
new file mode 100644
index 0000000..a0465d8
--- /dev/null
+++ b/mod2/catalog-service/src/test/resources/http/requests/CreateSpecificationRequest.json
@@ -0,0 +1,180 @@
+{
+ "specContent": {
+ "self": {
+ "component_type": "docker",
+ "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR",
+ "name": "dcae-collectors-vcc-helloworld-pm",
+ "version": "1.0.1"
+ },
+ "services": {
+ "calls": [],
+ "provides": []
+ },
+ "streams": {
+ "publishes": [
+ {
+ "config_key": "DCAE-HELLO-WORLD-PUB-DR",
+ "format": "dataformat_Hello_World_PM",
+ "type": "data_router",
+ "version": "1.0.0"
+ },
+ {
+ "config_key": "DCAE-HELLO-WORLD-PUB-MR",
+ "format": "dataformat_Hello_World_PM",
+ "type": "message_router",
+ "version": "1.0.0"
+ }
+ ],
+ "subscribes": [
+ {
+ "config_key": "DCAE-HELLO-WORLD-SUB-MR",
+ "format": "dataformat_Hello_World_PM",
+ "route": "/DCAE_HELLO_WORLD_SUB_MR",
+ "type": "message_router",
+ "version": "1.0.0"
+ },
+ {
+ "config_key": "DCAE-HELLO-WORLD-SUB-DR",
+ "format": "dataformat_Hello_World_PM",
+ "route": "/DCAE-HELLO-WORLD-SUB-DR",
+ "type": "data_router",
+ "version": "1.0.0"
+ }
+ ]
+ },
+ "parameters": [
+ {
+ "name": "vcc_hello_name",
+ "value": "120",
+ "type": "integer",
+ "description": "the name entered for specific person",
+ "sourced_at_deployment": false,
+ "designer_editable": false,
+ "policy_editable": false
+ },
+ {
+ "name": "useDtiConfig",
+ "value": false,
+ "type": "boolean",
+ "description": "component depends on configuration from dti.",
+ "sourced_at_deployment": false,
+ "designer_editable": true,
+ "policy_editable": false,
+ "required": true
+ },
+ {
+ "name": "isSelfServeComponent",
+ "value": false,
+ "type": "boolean",
+ "description": "Is this used as self serve component.",
+ "sourced_at_deployment": false,
+ "designer_editable": true,
+ "policy_editable": false,
+ "required": true
+ }
+ ],
+ "auxilary": {
+ "healthcheck": {
+ "interval": "60s",
+ "initialDelaySeconds": "120s",
+ "timeout": "20s",
+ "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh",
+ "type": "docker"
+ },
+ "livehealthcheck": {
+ "interval": "60s",
+ "initialDelaySeconds": "120s",
+ "timeout": "20s",
+ "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh",
+ "type": "docker"
+ },
+ "reconfigs": {
+ "app_reconfig": "abc"
+ },
+ "volumes": [
+ {
+ "container": {
+ "bind": "/opt/app/dcae-certificate"
+ },
+ "host": {
+ "path": "/opt/app/dcae-certificate"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/logs/DCAE/dmd/AGENT"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/dmd/AGENT"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/logs/DCAE/dmd/WATCHER"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/dmd/WATCHER"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/app/vcc/logs/DCAE"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/vcc-logs"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/app/vcc/archive/data"
+ },
+ "host": {
+ "path": "/opt/data/DCAE/helloworldpm/vcc-archive"
+ }
+ }
+ ]
+ },
+ "artifacts": [
+ {
+ "type": "docker image",
+ "uri": "dockercentral.it.att.com:5100/com.att.sample/dcae-controller-vcc-helloworld-pm:18.02-001"
+ }
+ ]
+ },
+ "policyJson": {
+ "policies": [
+ {
+ "configAttributes": "",
+ "configName": "",
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_",
+ "unique": false
+ },
+ {
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_",
+ "unique": true
+ },
+ {
+ "configAttributes": "",
+ "configName": "",
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_*",
+ "unique": false
+ }
+ ],
+ "policy": [
+ {
+ "policy_id": "id_0"
+ }
+ ]
+ },
+ "type": "K8S",
+ "user": "abc123",
+ "metadata": {
+ "notes": "Sample 812-1",
+ "labels": [
+ "LATEST"
+ ]
+ }
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/resources/http/requests/CreateSpecificationResponse.json b/mod2/catalog-service/src/test/resources/http/requests/CreateSpecificationResponse.json
new file mode 100644
index 0000000..3cb6dcf
--- /dev/null
+++ b/mod2/catalog-service/src/test/resources/http/requests/CreateSpecificationResponse.json
@@ -0,0 +1,188 @@
+{
+ "id": "5f3417a26aef7f07bc91350a",
+ "status": "ACTIVE",
+ "specContent": {
+ "self": {
+ "component_type": "docker",
+ "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR",
+ "name": "dcae-collectors-vcc-helloworld-pm",
+ "version": "1.0.1"
+ },
+ "services": {
+ "calls": [],
+ "provides": []
+ },
+ "streams": {
+ "publishes": [
+ {
+ "config_key": "DCAE-HELLO-WORLD-PUB-DR",
+ "format": "dataformat_Hello_World_PM",
+ "type": "data_router",
+ "version": "1.0.0"
+ },
+ {
+ "config_key": "DCAE-HELLO-WORLD-PUB-MR",
+ "format": "dataformat_Hello_World_PM",
+ "type": "message_router",
+ "version": "1.0.0"
+ }
+ ],
+ "subscribes": [
+ {
+ "config_key": "DCAE-HELLO-WORLD-SUB-MR",
+ "format": "dataformat_Hello_World_PM",
+ "route": "/DCAE_HELLO_WORLD_SUB_MR",
+ "type": "message_router",
+ "version": "1.0.0"
+ },
+ {
+ "config_key": "DCAE-HELLO-WORLD-SUB-DR",
+ "format": "dataformat_Hello_World_PM",
+ "route": "/DCAE-HELLO-WORLD-SUB-DR",
+ "type": "data_router",
+ "version": "1.0.0"
+ }
+ ]
+ },
+ "parameters": [
+ {
+ "name": "vcc_hello_name",
+ "value": "120",
+ "type": "integer",
+ "description": "the name entered for specific person",
+ "sourced_at_deployment": false,
+ "designer_editable": false,
+ "policy_editable": false
+ },
+ {
+ "name": "useDtiConfig",
+ "value": false,
+ "type": "boolean",
+ "description": "component depends on configuration from dti.",
+ "sourced_at_deployment": false,
+ "designer_editable": true,
+ "policy_editable": false,
+ "required": true
+ },
+ {
+ "name": "isSelfServeComponent",
+ "value": false,
+ "type": "boolean",
+ "description": "Is this used as self serve component.",
+ "sourced_at_deployment": false,
+ "designer_editable": true,
+ "policy_editable": false,
+ "required": true
+ }
+ ],
+ "auxilary": {
+ "healthcheck": {
+ "interval": "60s",
+ "initialDelaySeconds": "120s",
+ "timeout": "20s",
+ "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh",
+ "type": "docker"
+ },
+ "livehealthcheck": {
+ "interval": "60s",
+ "initialDelaySeconds": "120s",
+ "timeout": "20s",
+ "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh",
+ "type": "docker"
+ },
+ "reconfigs": {
+ "app_reconfig": "abc"
+ },
+ "volumes": [
+ {
+ "container": {
+ "bind": "/opt/app/dcae-certificate"
+ },
+ "host": {
+ "path": "/opt/app/dcae-certificate"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/logs/DCAE/dmd/AGENT"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/dmd/AGENT"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/logs/DCAE/dmd/WATCHER"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/dmd/WATCHER"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/app/vcc/logs/DCAE"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/vcc-logs"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/app/vcc/archive/data"
+ },
+ "host": {
+ "path": "/opt/data/DCAE/helloworldpm/vcc-archive"
+ }
+ }
+ ]
+ },
+ "artifacts": [
+ {
+ "type": "docker image",
+ "uri": "dockercentral.it.att.com:5100/com.att.sample/dcae-controller-vcc-helloworld-pm:18.02-001"
+ }
+ ]
+ },
+ "policyJson": {
+ "policies": [
+ {
+ "configAttributes": "",
+ "configName": "",
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_",
+ "unique": false
+ },
+ {
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_",
+ "unique": true
+ },
+ {
+ "configAttributes": "",
+ "configName": "",
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_*",
+ "unique": false
+ }
+ ],
+ "policy": [
+ {
+ "policy_id": "id_0"
+ }
+ ]
+ },
+ "type": "K8S",
+ "metadata": {
+ "notes": "Sample 812-1",
+ "labels": [
+ "LATEST"
+ ],
+ "createdBy": "abc123",
+ "createdOn": "2020-08-12T16:24:02.621+0000"
+ },
+ "msInstanceInfo": {
+ "release": "2006",
+ "name": "hello-804",
+ "id": "5f1592ffb551b604628316b0"
+ }
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/resources/specification/componentSpec_hello_world-with-dmaap.json b/mod2/catalog-service/src/test/resources/specification/componentSpec_hello_world-with-dmaap.json
new file mode 100644
index 0000000..0ad6b6e
--- /dev/null
+++ b/mod2/catalog-service/src/test/resources/specification/componentSpec_hello_world-with-dmaap.json
@@ -0,0 +1,149 @@
+{
+ "self": {
+ "component_type": "docker",
+ "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR",
+ "name": "dcae-collectors-vcc-helloworld-pm",
+ "version": "1.0.1"
+ },
+
+ "services": {
+ "calls": [],
+ "provides": []
+ },
+
+ "streams": {
+ "publishes": [{
+ "config_key": "DCAE-HELLO-WORLD-PUB-DR",
+ "format": "dataformat_Hello_World_PM",
+ "type": "data_router",
+ "version": "1.0.0"
+ },
+ {
+ "config_key": "DCAE-HELLO-WORLD-PUB-MR",
+ "format": "dataformat_Hello_World_PM",
+ "type": "message_router",
+ "version": "1.0.0"
+ }
+ ],
+
+ "subscribes": [{
+ "config_key": "DCAE-HELLO-WORLD-SUB-MR",
+ "format": "dataformat_Hello_World_PM",
+ "route": "/DCAE_HELLO_WORLD_SUB_MR",
+ "type": "message_router",
+ "version": "1.0.0"
+ },
+ {
+ "config_key": "DCAE-HELLO-WORLD-SUB-DR",
+ "format": "dataformat_Hello_World_PM",
+ "route": "/DCAE-HELLO-WORLD-SUB-DR",
+ "type": "data_router",
+ "version": "1.0.0"
+ }
+ ]
+ },
+
+ "parameters":
+ [
+ {
+ "name": "vcc_hello_name",
+ "value": "120",
+ "type": "integer",
+ "description": "the name entered for specific person",
+ "sourced_at_deployment": false,
+ "designer_editable": false,
+ "policy_editable": false
+ },
+
+ {
+ "name": "useDtiConfig",
+ "value": false,
+ "type" : "boolean",
+ "description": "component depends on configuration from dti.",
+ "sourced_at_deployment": false,
+ "designer_editable": true,
+ "policy_editable": false,
+ "required" : true
+ },
+
+ {
+ "name": "isSelfServeComponent",
+ "value": false,
+ "type": "boolean",
+ "description": "Is this used as self serve component.",
+ "sourced_at_deployment": false,
+ "designer_editable": true,
+ "policy_editable": false,
+ "required" : true
+ }
+ ],
+
+ "auxilary": {
+ "healthcheck": {
+ "interval": "60s",
+ "initialDelaySeconds": "120s",
+ "timeout": "20s",
+ "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh",
+ "type": "docker"
+ },
+ "livehealthcheck": {
+ "interval": "60s",
+ "initialDelaySeconds": "120s",
+ "timeout": "20s",
+ "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh",
+ "type": "docker"
+ },
+ "reconfigs":{
+ "app_reconfig" : "abc"
+ },
+
+ "volumes": [
+ {
+ "container": {
+ "bind": "/opt/app/dcae-certificate"
+ },
+ "host": {
+ "path": "/opt/app/dcae-certificate"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/logs/DCAE/dmd/AGENT"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/dmd/AGENT"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/logs/DCAE/dmd/WATCHER"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/dmd/WATCHER"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/app/vcc/logs/DCAE"
+ },
+ "host": {
+ "path": "/opt/logs/DCAE/helloworldpm/vcc-logs"
+ }
+ },
+ {
+ "container": {
+ "bind": "/opt/app/vcc/archive/data"
+ },
+ "host": {
+ "path": "/opt/data/DCAE/helloworldpm/vcc-archive"
+ }
+ }
+
+ ]
+
+ },
+ "artifacts": [{
+ "type": "docker image",
+ "uri": "dockercentral.it.att.com:5100/com.att.sample/dcae-controller-vcc-helloworld-pm:18.02-001"
+ }]
+} \ No newline at end of file
diff --git a/mod2/catalog-service/src/test/resources/specification/policy_json_sample_3.json b/mod2/catalog-service/src/test/resources/specification/policy_json_sample_3.json
new file mode 100644
index 0000000..4a8c76f
--- /dev/null
+++ b/mod2/catalog-service/src/test/resources/specification/policy_json_sample_3.json
@@ -0,0 +1,28 @@
+{
+ "policies": [
+ {
+ "configAttributes": "",
+ "configName": "",
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_",
+ "unique": false
+ },
+ {
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_",
+ "unique": true
+ },
+ {
+ "configAttributes": "",
+ "configName": "",
+ "onapName": "DCAE",
+ "policyName": "DCAE.Config_*",
+ "unique": false
+ }
+ ],
+ "policy": [
+ {
+ "policy_id" : "id_0"
+ }
+ ]
+} \ No newline at end of file
diff --git a/releases/1.1.0-distributorapi-container.yaml b/releases/1.1.0-distributorapi-container.yaml
new file mode 100644
index 0000000..f80e5d1
--- /dev/null
+++ b/releases/1.1.0-distributorapi-container.yaml
@@ -0,0 +1,9 @@
+distribution_type: 'container'
+container_release_tag: '1.1.0'
+project: 'dcaegen2-platform'
+log_dir: 'dcaegen2-platform-mod-distributorapi-docker-merge-master/30'
+ref: 66ae1f86dd66a064c6095fce19bc7dd6dd072473
+containers:
+ - name: 'org.onap.dcaegen2.platform.mod.distributorapi'
+ version: '1.1.0-SNAPSHOT-20200908T140636Z'
+git_tag: '1.1.0-mod-distributorapi'
diff --git a/releases/1.1.0-runtimeapi-container.yaml b/releases/1.1.0-runtimeapi-container.yaml
new file mode 100644
index 0000000..2a164a3
--- /dev/null
+++ b/releases/1.1.0-runtimeapi-container.yaml
@@ -0,0 +1,9 @@
+distribution_type: 'container'
+container_release_tag: '1.1.0'
+project: 'dcaegen2-platform'
+log_dir: 'dcaegen2-platform-mod-master-runtimeapi-merge-java/21'
+ref: 35e1b8356e120ef8283081fefe8c99173aad4a18
+containers:
+ - name: 'org.onap.dcaegen2.platform.mod.runtime-web'
+ version: '1.1.0-SNAPSHOT-20200924T182845Z'
+git_tag: '1.1.0-mod-runtimeapi'
diff --git a/releases/1.5.0-blueprint-generator.yaml b/releases/1.5.0-blueprint-generator.yaml
new file mode 100644
index 0000000..928096d
--- /dev/null
+++ b/releases/1.5.0-blueprint-generator.yaml
@@ -0,0 +1,4 @@
+distribution_type: 'maven'
+version: '1.5.0'
+project: 'dcaegen2/platform'
+log_dir: 'dcaegen2-platform-mod-bpgenerator-maven-stage-master/225'
diff --git a/releases/1.5.1-blueprint-generator.yaml b/releases/1.5.1-blueprint-generator.yaml
new file mode 100644
index 0000000..ce7fa45
--- /dev/null
+++ b/releases/1.5.1-blueprint-generator.yaml
@@ -0,0 +1,4 @@
+distribution_type: 'maven'
+version: '1.5.1'
+project: 'dcaegen2/platform'
+log_dir: 'dcaegen2-platform-mod-bpgenerator-maven-stage-master/229'
diff --git a/releases/2.12.3-onboardingapi-container.yaml b/releases/2.12.3-onboardingapi-container.yaml
new file mode 100644
index 0000000..1b0dfb9
--- /dev/null
+++ b/releases/2.12.3-onboardingapi-container.yaml
@@ -0,0 +1,9 @@
+distribution_type: 'container'
+container_release_tag: '2.12.3'
+project: 'dcaegen2-platform'
+log_dir: 'dcaegen2-platform-mod-onboardingapi-docker-merge-master/30'
+ref: b4287ad1fab97142df4d5260ec94d41bb782992a
+containers:
+ - name: 'org.onap.dcaegen2.platform.mod.onboardingapi'
+ version: '2.12.3-SNAPSHOT-20200908T020337Z'
+git_tag: '2.12.3-mod-onboardingapi'