diff options
Diffstat (limited to 'mod2/catalog-service/src')
-rw-r--r-- | mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/blueprintgenerator/DeploymentArtifactGenerator.java (renamed from mod2/catalog-service/src/main/java/org/onap/dcaegen2/platform/mod/mock/MockDeploymentArtifactGenerator.java) | 24 | ||||
-rw-r--r-- | mod2/catalog-service/src/test/java/org/onap/dcaegen2/platform/mod/web/service/deploymentartifact/DeploymentArtifactServiceImplTest.java | 17 |
2 files changed, 37 insertions, 4 deletions
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/blueprintgenerator/DeploymentArtifactGenerator.java index 24c31ed..5d7668d 100644 --- 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/blueprintgenerator/DeploymentArtifactGenerator.java @@ -18,19 +18,24 @@ * ============LICENSE_END========================================================= */ -package org.onap.dcaegen2.platform.mod.mock; +package org.onap.dcaegen2.platform.mod.blueprintgenerator; +import com.google.gson.Gson; +import org.onap.blueprintgenerator.models.blueprint.Blueprint; +import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; 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.HashMap; import java.util.Map; /** * Mock implementation for DeploymentArtifactGenerator */ @Component -public class MockDeploymentArtifactGenerator implements DeploymentArtifactGeneratorStrategy { +public class DeploymentArtifactGenerator implements DeploymentArtifactGeneratorStrategy { /** * null implementation. @@ -38,8 +43,19 @@ public class MockDeploymentArtifactGenerator implements DeploymentArtifactGenera * @param release * @return */ - @Override + + @Override public Map<String, Object> generateForRelease(Specification activeSpec, String release) { - return null; + + ComponentSpec inboundComponentSpec = new ComponentSpec(); + inboundComponentSpec.createComponentSpecFromString(new Gson().toJson(activeSpec.getSpecContent())); + + Blueprint blueprint = new Blueprint().createBlueprint(inboundComponentSpec,"",'d',"",""); + + Map<String, Object> modifiedResponse = new HashMap<>(); + modifiedResponse.put("content", blueprint.blueprintToString()); + modifiedResponse.put("fileName", "filenamePlaceholder" + ".yaml"); + return modifiedResponse; } + } 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 index 749d8b1..9074650 100644 --- 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 @@ -25,8 +25,11 @@ import org.onap.dcaegen2.platform.mod.model.deploymentartifact.DeploymentArtifac 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.model.specification.DeploymentType; +import org.onap.dcaegen2.platform.mod.model.specification.Specification; import org.onap.dcaegen2.platform.mod.objectmothers.DeploymentArtifactObjectMother; import org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother; +import org.onap.dcaegen2.platform.mod.objectmothers.SpecificationObjectMother; import org.onap.dcaegen2.platform.mod.web.service.microserviceinstance.MsInstanceService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -36,6 +39,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.Optional; import static org.onap.dcaegen2.platform.mod.objectmothers.MsInstanceObjectMother.*; @@ -99,6 +103,19 @@ class DeploymentArtifactServiceImplTest { } @Test + void test_GenerateForRelease_shouldReturnCorrectBlueprint(){ + Specification specification = SpecificationObjectMother.getMockSpecification(DeploymentType.K8S); + when(deploymentArtifactGeneratorStrategy.generateForRelease(specification, "")).thenReturn(DeploymentArtifactObjectMother.createBlueprintResponse()); + Map<String, Object> response = deploymentArtifactGeneratorStrategy.generateForRelease(specification, ""); + verify(deploymentArtifactGeneratorStrategy, atLeastOnce()).generateForRelease(specification,""); + assertThat(response).isNotNull(); + assertThat(response.get("content")).isNotNull(); + assertThat(response.get("fileName")).isNotNull(); + assertThat((String)response.get("content")).contains("tosca_definitions_version"); + + } + + @Test void test_GenerateBlueprint_shouldReturnCorrectBlueprint() throws Exception{ setupMockBehaviours(); |