From 341db21b2ac0a14a1ed2b8bf7930914dda054bfe Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Fri, 22 Nov 2019 18:06:08 -0500 Subject: Formatting Code base with ktlint No Business logic change, just the code format. Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3 To format run: mvn process-sources -P format Issue-ID: CCSDK-1947 Signed-off-by: Singal, Kapil (ks220y) Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331 --- .../api/BluePrintManagementGRPCHandlerTest.kt | 142 ++++++++++++--------- .../designer/api/BlueprintModelControllerTest.kt | 136 +++++++++++--------- .../designer/api/DesignerApiTestConfiguration.kt | 6 +- .../designer/api/ModelTypeControllerTest.kt | 23 ++-- .../api/ResourceDictionaryControllerTest.kt | 9 +- .../enhancer/BluePrintEnhancerServiceImplTest.kt | 16 +-- .../designer/api/handler/ModelTypeServiceTest.kt | 29 +++-- .../designer/api/mock/MockFilePart.kt | 8 +- .../api/repository/ModelTypeReactRepositoryTest.kt | 26 ++-- .../ResourceDictionaryReactRepositoryTest.kt | 103 +++++++++++++++ .../repository/ResourceDictionaryRepositoryTest.kt | 99 -------------- .../api/utils/BluePrintEnhancerUtilsTest.kt | 11 +- 12 files changed, 336 insertions(+), 272 deletions(-) create mode 100644 ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryReactRepositoryTest.kt delete mode 100644 ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt (limited to 'ms/blueprintsprocessor/modules/inbounds/designer-api/src/test') diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt index 61f515017..0938431d6 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt @@ -32,20 +32,34 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile -import org.onap.ccsdk.cds.controllerblueprints.management.api.* +import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintBootstrapInput +import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintDownloadInput +import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc +import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintRemoveInput +import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput +import org.onap.ccsdk.cds.controllerblueprints.management.api.DownloadAction +import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk +import org.onap.ccsdk.cds.controllerblueprints.management.api.RemoveAction +import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.context.annotation.ComponentScan import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner -import kotlin.test.* +import kotlin.test.AfterTest +import kotlin.test.BeforeTest +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertTrue @RunWith(SpringRunner::class) @EnableAutoConfiguration @DirtiesContext -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", - "org.onap.ccsdk.cds.controllerblueprints"]) +@ComponentScan( + basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", + "org.onap.ccsdk.cds.controllerblueprints"] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BluePrintManagementGRPCHandlerTest { @@ -74,8 +88,10 @@ class BluePrintManagementGRPCHandlerTest { val req = createBootstrapInputRequest(id) val bootstrapOutput = blockingStub.bootstrapBlueprint(req) assertEquals(200, bootstrapOutput.status.code) - assertTrue(bootstrapOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), - "failed to get success status") + assertTrue( + bootstrapOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), + "failed to get success status" + ) assertEquals(id, bootstrapOutput.commonHeader.requestId) } @@ -87,8 +103,10 @@ class BluePrintManagementGRPCHandlerTest { val output = blockingStub.uploadBlueprint(req) assertEquals(200, output.status.code) - assertTrue(output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), - "failed to get success status") + assertTrue( + output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), + "failed to get success status" + ) assertEquals(id, output.commonHeader.requestId) val downloadId = "123_download" @@ -96,8 +114,10 @@ class BluePrintManagementGRPCHandlerTest { val downloadOutput = blockingStub.downloadBlueprint(downloadReq) assertEquals(200, downloadOutput.status.code) - assertTrue(downloadOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), - "failed to get success status") + assertTrue( + downloadOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), + "failed to get success status" + ) assertNotNull(downloadOutput.fileChunk?.chunk, "failed to get cba file chunks") assertEquals(downloadId, downloadOutput.commonHeader.requestId) } @@ -110,8 +130,10 @@ class BluePrintManagementGRPCHandlerTest { var output = blockingStub.uploadBlueprint(req) assertEquals(200, output.status.code) - assertTrue(output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), - "failed to get success status") + assertTrue( + output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), + "failed to get success status" + ) assertEquals(id, output.commonHeader.requestId) val removeReq = createRemoveInputRequest(id) @@ -142,18 +164,18 @@ class BluePrintManagementGRPCHandlerTest { private fun createBootstrapInputRequest(id: String): BluePrintBootstrapInput { val commonHeader = CommonHeader - .newBuilder() - .setTimestamp("2012-04-23T18:25:43.511Z") - .setOriginatorId("System") - .setRequestId(id) - .setSubRequestId("1234-56").build() + .newBuilder() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId(id) + .setSubRequestId("1234-56").build() return BluePrintBootstrapInput.newBuilder() - .setCommonHeader(commonHeader) - .setLoadModelType(false) - .setLoadResourceDictionary(false) - .setLoadCBA(false) - .build() + .setCommonHeader(commonHeader) + .setLoadModelType(false) + .setLoadResourceDictionary(false) + .setLoadCBA(false) + .build() } private fun createUploadInputRequest(id: String, action: String): BluePrintUploadInput { @@ -161,59 +183,63 @@ class BluePrintManagementGRPCHandlerTest { assertTrue(file.exists(), "couldnt get file ${file.absolutePath}") val commonHeader = CommonHeader - .newBuilder() - .setTimestamp("2012-04-23T18:25:43.511Z") - .setOriginatorId("System") - .setRequestId(id) - .setSubRequestId("1234-56").build() + .newBuilder() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId(id) + .setSubRequestId("1234-56").build() val actionIdentifier = ActionIdentifiers.newBuilder() - .setActionName(action) - .setBlueprintName("sample") - .setBlueprintVersion("1.0.0") - .build() + .setActionName(action) + .setBlueprintName("sample") + .setBlueprintVersion("1.0.0") + .build() val fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(file.inputStream().readBytes())) - .build() + .build() return BluePrintUploadInput.newBuilder() - .setCommonHeader(commonHeader) - .setActionIdentifiers(actionIdentifier) - .setFileChunk(fileChunk) - .build() + .setCommonHeader(commonHeader) + .setActionIdentifiers(actionIdentifier) + .setFileChunk(fileChunk) + .build() } private fun createDownloadInputRequest(id: String, action: String): BluePrintDownloadInput { val commonHeader = CommonHeader - .newBuilder() - .setTimestamp("2012-04-23T18:25:43.511Z") - .setOriginatorId("System") - .setRequestId(id) - .setSubRequestId("1234-56").build() + .newBuilder() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId(id) + .setSubRequestId("1234-56").build() return BluePrintDownloadInput.newBuilder() - .setCommonHeader(commonHeader) - .setActionIdentifiers(ActionIdentifiers.newBuilder() - .setBlueprintName("baseconfiguration") - .setBlueprintVersion("1.0.0") - .setActionName(action).build()) - .build() + .setCommonHeader(commonHeader) + .setActionIdentifiers( + ActionIdentifiers.newBuilder() + .setBlueprintName("baseconfiguration") + .setBlueprintVersion("1.0.0") + .setActionName(action).build() + ) + .build() } private fun createRemoveInputRequest(id: String): BluePrintRemoveInput { val commonHeader = CommonHeader - .newBuilder() - .setTimestamp("2012-04-23T18:25:43.511Z") - .setOriginatorId("System") - .setRequestId(id) - .setSubRequestId("1234-56").build() + .newBuilder() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId(id) + .setSubRequestId("1234-56").build() return BluePrintRemoveInput.newBuilder() - .setCommonHeader(commonHeader) - .setActionIdentifiers(ActionIdentifiers.newBuilder() - .setBlueprintName("sample") - .setBlueprintVersion("1.0.0") - .setActionName(RemoveAction.DEFAULT.toString()).build()) - .build() + .setCommonHeader(commonHeader) + .setActionIdentifiers( + ActionIdentifiers.newBuilder() + .setBlueprintName("sample") + .setBlueprintVersion("1.0.0") + .setActionName(RemoveAction.DEFAULT.toString()).build() + ) + .build() } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt index 149acb03c..50eafd12c 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt @@ -30,8 +30,13 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch -import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.compress import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration +import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName +import org.onap.ccsdk.cds.controllerblueprints.core.reCreateDirs import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.core.io.ByteArrayResource @@ -60,8 +65,10 @@ import kotlin.test.assertTrue @RunWith(SpringRunner::class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = [DesignerApiTestConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]) +@ContextConfiguration( + classes = [DesignerApiTestConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) @FixMethodOrder(MethodSorters.NAME_ASCENDING) class BlueprintModelControllerTest { @@ -82,7 +89,6 @@ class BlueprintModelControllerTest { private var testZipFile: File? = null - @Before fun setUp() { assertNotNull(webTestClient, " Failed to create WebTestClient") @@ -121,14 +127,14 @@ class BlueprintModelControllerTest { }.build() val saveBP = webTestClient - .post() - .uri("/api/v1/blueprint-model") - .body(BodyInserters.fromMultipartData(body)) - .exchange() - .expectStatus().isOk - .returnResult() - .responseBody - .awaitSingle() + .post() + .uri("/api/v1/blueprint-model") + .body(BodyInserters.fromMultipartData(body)) + .exchange() + .expectStatus().isOk + .returnResult() + .responseBody + .awaitSingle() assertNotNull(saveBP, "failed to get response") assertEquals("baseconfiguration", saveBP.artifactName, "mismatch artifact name") @@ -141,18 +147,21 @@ class BlueprintModelControllerTest { @Test @Throws(JSONException::class) fun test02_getBluePrintByNameAndVersion() { - webTestClient(HttpMethod.GET, null, - "/api/v1/blueprint-model/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}", - HttpStatus.OK, false) + webTestClient( + HttpMethod.GET, null, + "/api/v1/blueprint-model/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}", + HttpStatus.OK, false + ) } - @Test @Throws(JSONException::class) fun test03_getBlueprintModel() { - webTestClient(HttpMethod.GET, null, - "/api/v1/blueprint-model/${bp!!.id}", - HttpStatus.OK, false) + webTestClient( + HttpMethod.GET, null, + "/api/v1/blueprint-model/${bp!!.id}", + HttpStatus.OK, false + ) } @Test @@ -164,9 +173,11 @@ class BlueprintModelControllerTest { @Test @Throws(JSONException::class) fun test05_downloadBluePrint() { - webTestClient(HttpMethod.GET, null, - "/api/v1/blueprint-model/download/${bp!!.id}", - HttpStatus.OK, false) + webTestClient( + HttpMethod.GET, null, + "/api/v1/blueprint-model/download/${bp!!.id}", + HttpStatus.OK, false + ) } @Test @@ -185,14 +196,14 @@ class BlueprintModelControllerTest { }.build() val publishBP = webTestClient - .post() - .uri("/api/v1/blueprint-model/publish") - .body(BodyInserters.fromMultipartData(body)) - .exchange() - .expectStatus().isOk - .returnResult() - .responseBody - .awaitSingle() + .post() + .uri("/api/v1/blueprint-model/publish") + .body(BodyInserters.fromMultipartData(body)) + .exchange() + .expectStatus().isOk + .returnResult() + .responseBody + .awaitSingle() assertNotNull(publishBP, "failed to get response") assertEquals("baseconfiguration", publishBP.artifactName, "mismatch artifact name") @@ -205,49 +216,60 @@ class BlueprintModelControllerTest { @Test @Throws(JSONException::class) fun test08_searchBlueprintModels() { - webTestClient(HttpMethod.GET, null, - "/api/v1/blueprint-model/search/${bp!!.artifactName}", - HttpStatus.OK, false) + webTestClient( + HttpMethod.GET, null, + "/api/v1/blueprint-model/search/${bp!!.artifactName}", + HttpStatus.OK, false + ) } @Test @Throws(JSONException::class) fun test09_downloadBlueprintByNameAndVersion() { - webTestClient(HttpMethod.GET, null, - "/api/v1/blueprint-model/download/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}", - HttpStatus.OK, false) + webTestClient( + HttpMethod.GET, null, + "/api/v1/blueprint-model/download/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}", + HttpStatus.OK, false + ) } @Test fun test10_deleteBluePrint() { -// webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}") -// .header("Authorization", "Basic " + Base64Utils -// .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))) -// .exchange() -// .expectStatus().is2xxSuccessful + // webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}") + // .header("Authorization", "Basic " + Base64Utils + // .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))) + // .exchange() + // .expectStatus().is2xxSuccessful webTestClient.delete().uri("/api/v1/blueprint-model/name/${bp!!.artifactName}/version/${bp!!.artifactVersion}") - .header("Authorization", "Basic " + Base64Utils - .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))) - .exchange() - .expectStatus().is2xxSuccessful + .header( + "Authorization", "Basic " + Base64Utils + .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)) + ) + .exchange() + .expectStatus().is2xxSuccessful } @Throws(JSONException::class) - private fun webTestClient(requestMethod: HttpMethod, body: BodyInserters.MultipartInserter?, uri: String, - expectedResponceStatus: HttpStatus, setParam: Boolean) { + private fun webTestClient( + requestMethod: HttpMethod, + body: BodyInserters.MultipartInserter?, + uri: String, + expectedResponceStatus: HttpStatus, + setParam: Boolean + ) { log.info("Requesting($uri): Method(${requestMethod.name})") webTestClient.method(requestMethod).uri(uri) - .header("Authorization", "Basic " + Base64Utils - .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))) - .body(body) - .exchange() - .expectStatus().isEqualTo(expectedResponceStatus) - .expectBody() - .returnResult().responseBody!! - + .header( + "Authorization", "Basic " + Base64Utils + .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)) + ) + .body(body) + .exchange() + .expectStatus().isEqualTo(expectedResponceStatus) + .expectBody() + .returnResult().responseBody!! } - -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt index 03e016b8e..4953d9cee 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt @@ -21,7 +21,9 @@ import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration @Configuration -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.controllerblueprints", - "org.onap.ccsdk.cds.blueprintsprocessor"]) +@ComponentScan( + basePackages = ["org.onap.ccsdk.cds.controllerblueprints", + "org.onap.ccsdk.cds.blueprintsprocessor"] +) @EnableAutoConfiguration open class DesignerApiTestConfiguration diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt index 8871676d2..fd51df482 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt @@ -24,9 +24,9 @@ import org.junit.runners.MethodSorters import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.annotation.Commit @@ -35,8 +35,10 @@ import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [DesignerApiTestConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]) +@ContextConfiguration( + classes = [DesignerApiTestConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) @FixMethodOrder(MethodSorters.NAME_ASCENDING) class ModelTypeControllerTest { @@ -62,8 +64,8 @@ class ModelTypeControllerTest { modelType.definition = JacksonUtils.jsonNode(content) modelType.modelName = modelName modelType.version = "1.0.0" - modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," - + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) modelType.updatedBy = "xxxxxx@xxx.com" modelType = modelTypeController!!.saveModelType(modelType) log.info("Saved Mode {}", modelType.toString()) @@ -71,15 +73,16 @@ class ModelTypeControllerTest { Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName) val dbModelType = modelTypeController!!.getModelTypeByName(modelType.modelName) - Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")", - dbModelType) + Assert.assertNotNull( + "Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")", + dbModelType + ) // Model Update modelType.updatedBy = "bs2796@xxx.com" modelType = modelTypeController!!.saveModelType(modelType) Assert.assertNotNull("Failed to get Saved ModelType", modelType) Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy) - } @Test @@ -92,7 +95,6 @@ class ModelTypeControllerTest { val dbModelTypes = modelTypeController!!.searchModelTypes(tags) Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes) Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.isNotEmpty()) - } @Test @@ -113,7 +115,8 @@ class ModelTypeControllerTest { @Throws(Exception::class) fun test04DeleteModelType() { log.info( - "************************ test03DeleteModelType ***********************") + "************************ test03DeleteModelType ***********************" + ) val dbResourceMapping = modelTypeController!!.getModelTypeByName(modelName) Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping) Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt index b13b1ac08..cfb16c786 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt @@ -32,8 +32,10 @@ import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = [DesignerApiTestConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]) +@ContextConfiguration( + classes = [DesignerApiTestConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) @FixMethodOrder(MethodSorters.NAME_ASCENDING) class ResourceDictionaryControllerTest { @@ -45,5 +47,4 @@ class ResourceDictionaryControllerTest { fun testResourceDictionaryControllerPresence() { assertNotNull(resourceDictionaryController, "failed to initialise ResourceDictionaryController") } - -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt index a5a0511f5..c8c2f0b9b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt @@ -37,8 +37,10 @@ import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [DesignerApiTestConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]) +@ContextConfiguration( + classes = [DesignerApiTestConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BluePrintEnhancerServiceImplTest { @@ -54,7 +56,6 @@ class BluePrintEnhancerServiceImplTest { @Autowired lateinit var bluePrintValidatorService: BluePrintValidatorService - @Test @Throws(Exception::class) fun testEnhancementAndValidation() { @@ -93,7 +94,6 @@ class BluePrintEnhancerServiceImplTest { fun testRemoteScriptsEnhancementAndValidation() { val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts" testComponentInvokeEnhancementAndValidation(basePath, "remote_scripts-enhance") - } fun testCapabilityCliEnhancementAndValidation() { @@ -115,12 +115,10 @@ class BluePrintEnhancerServiceImplTest { Assert.assertTrue("blueprint($basePath) validation failed ", valid) // Enable this to get the enhanced zip file -// val compressFile = normalizedFile("target/blueprints/enrichment", "$targetDirName.zip") -// normalizedFile(targetPath).compress(compressFile) + // val compressFile = normalizedFile("target/blueprints/enrichment", "$targetDirName.zip") + // normalizedFile(targetPath).compress(compressFile) deleteDir(targetPath) } } - - -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt index 7ea845dee..fe5cd4d3e 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt @@ -26,9 +26,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.annotation.Commit @@ -36,13 +36,15 @@ import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner - @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [DesignerApiTestConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]) +@ContextConfiguration( + classes = [DesignerApiTestConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) @FixMethodOrder(MethodSorters.NAME_ASCENDING) class ModelTypeServiceTest { + @Autowired private val modelTypeHandler: ModelTypeHandler? = null @@ -65,8 +67,8 @@ class ModelTypeServiceTest { modelType.definition = JacksonUtils.jsonNode(content) modelType.modelName = modelName modelType.version = "1.0.0" - modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," - + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) modelType.updatedBy = "xxxxxx@xxx.com" modelType = modelTypeHandler!!.saveModel(modelType) log.info("Saved Mode {}", modelType.toString()) @@ -74,8 +76,10 @@ class ModelTypeServiceTest { Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName) val dbModelType = modelTypeHandler.getModelTypeByName(modelType.modelName) - Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")", - dbModelType) + Assert.assertNotNull( + "Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")", + dbModelType + ) // Model Update modelType.updatedBy = "bs2796@xxx.com" @@ -83,7 +87,6 @@ class ModelTypeServiceTest { Assert.assertNotNull("Failed to get Saved ModelType", modelType) Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy) } - } @Test @@ -98,7 +101,6 @@ class ModelTypeServiceTest { Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes) Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size > 0) } - } @Test @@ -118,7 +120,6 @@ class ModelTypeServiceTest { Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms) Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size > 0) } - } @Test @@ -126,7 +127,8 @@ class ModelTypeServiceTest { fun test04DeleteModelType() { runBlocking { log.info( - "************************ test03DeleteModelType ***********************") + "************************ test03DeleteModelType ***********************" + ) val dbResourceMapping = modelTypeHandler!!.getModelTypeByName(modelName) Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping) Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName) @@ -134,5 +136,4 @@ class ModelTypeServiceTest { modelTypeHandler.deleteByModelName(dbResourceMapping.modelName) } } - -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt index 3165a6e2f..27949901c 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt @@ -30,11 +30,11 @@ import java.nio.file.Path class MockFilePart(private val fileName: String) : FilePart { val log = LoggerFactory.getLogger(MockFilePart::class.java)!! override fun content(): Flux { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + TODO("not implemented") // To change body of created functions use File | Settings | File Templates. } override fun headers(): HttpHeaders { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + TODO("not implemented") // To change body of created functions use File | Settings | File Templates. } override fun filename(): String { @@ -46,8 +46,8 @@ class MockFilePart(private val fileName: String) : FilePart { } override fun transferTo(path: Path): Mono { - log.info("Copying file($fileName to ${path}") + log.info("Copying file($fileName to $path") FileCopyUtils.copy(File(fileName), path.toFile()) return Mono.empty() } -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt index 3dfed1ccb..4b771c0a6 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt @@ -25,17 +25,17 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.annotation.Commit import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner import java.nio.charset.Charset -import java.util.* +import java.util.Arrays /** * ModelTypeReactRepositoryTest. @@ -44,8 +44,10 @@ import java.util.* */ @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [DesignerApiTestConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]) +@ContextConfiguration( + classes = [DesignerApiTestConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class] +) @TestPropertySource(locations = ["classpath:application-test.properties"]) @FixMethodOrder(MethodSorters.NAME_ASCENDING) class ModelTypeReactRepositoryTest { @@ -59,7 +61,7 @@ class ModelTypeReactRepositoryTest { @Commit fun test01Save() { val content = normalizedFile("./src/test/resources/model_type/data_type/datatype-property.json") - .readText(Charset.defaultCharset()) + .readText(Charset.defaultCharset()) val modelType = ModelType() modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT @@ -67,8 +69,8 @@ class ModelTypeReactRepositoryTest { modelType.definition = JacksonUtils.jsonNode(content) modelType.modelName = modelName modelType.version = "1.0.0" - modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," - + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) modelType.updatedBy = "xxxxxx@xxx.com" val dbModelType = modelTypeReactRepository!!.save(modelType).block() @@ -80,7 +82,8 @@ class ModelTypeReactRepositoryTest { val dbFindByModelName = modelTypeReactRepository!!.findByModelName(modelName).block() Assert.assertNotNull("Failed to findByModelName ", dbFindByModelName) - val dbFindByDefinitionType = modelTypeReactRepository.findByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE).collectList().block() + val dbFindByDefinitionType = + modelTypeReactRepository.findByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE).collectList().block() Assert.assertNotNull("Failed to findByDefinitionType ", dbFindByDefinitionType) Assert.assertTrue("Failed to findByDefinitionType count", dbFindByDefinitionType!!.size > 0) @@ -92,11 +95,13 @@ class ModelTypeReactRepositoryTest { Assert.assertNotNull("Failed to findByModelNameIn ", dbFindByModelNameIn) Assert.assertTrue("Failed to findByModelNameIn by count", dbFindByModelNameIn!!.size > 0) - val dbFindByDefinitionTypeIn = modelTypeReactRepository.findByDefinitionTypeIn(Arrays.asList(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)).collectList().block() + val dbFindByDefinitionTypeIn = + modelTypeReactRepository.findByDefinitionTypeIn(Arrays.asList(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)).collectList().block() Assert.assertNotNull("Failed to findByDefinitionTypeIn", dbFindByDefinitionTypeIn) Assert.assertTrue("Failed to findByDefinitionTypeIn by count", dbFindByDefinitionTypeIn!!.size > 0) - val dbFindByDerivedFromIn = modelTypeReactRepository.findByDerivedFromIn(Arrays.asList(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)).collectList().block() + val dbFindByDerivedFromIn = + modelTypeReactRepository.findByDerivedFromIn(Arrays.asList(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)).collectList().block() Assert.assertNotNull("Failed to find findByDerivedFromIn", dbFindByDerivedFromIn) Assert.assertTrue("Failed to find findByDerivedFromIn by count", dbFindByDerivedFromIn!!.size > 0) } @@ -106,5 +111,4 @@ class ModelTypeReactRepositoryTest { fun test03Delete() { modelTypeReactRepository!!.deleteByModelName(modelName).block() } - } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryReactRepositoryTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryReactRepositoryTest.kt new file mode 100644 index 000000000..0534afa2a --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryReactRepositoryTest.kt @@ -0,0 +1,103 @@ +/* + * Copyright © 2019 IBM. + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository + +import org.junit.Assert +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.annotation.Commit +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.junit4.SpringRunner +import org.springframework.transaction.annotation.Transactional + +@RunWith(SpringRunner::class) +@ContextConfiguration( + classes = [DesignerApiTestConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class] +) +@TestPropertySource(locations = ["classpath:application-test.properties"]) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class ResourceDictionaryReactRepositoryTest { + + private val sourceName = "test-source" + + @Autowired + lateinit var resourceDictionaryRepository: ResourceDictionaryRepository + + @Test + @Commit + fun test01Save() { + val resourceDefinition = JacksonUtils + .readValueFromFile( + "./../../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", + ResourceDefinition::class.java + ) + Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition) + resourceDefinition!!.name = sourceName + + val resourceDictionary = transformResourceDictionary(resourceDefinition) + val dbResourceDictionary = resourceDictionaryRepository.save(resourceDictionary) + Assert.assertNotNull("Failed to save ResourceDictionary", dbResourceDictionary) + } + + @Test + fun test02FindByNameReact() { + val dbResourceDictionary = resourceDictionaryRepository.findByName(sourceName) + Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary) + } + + @Test + fun test03FindByNameInReact() { + val dbResourceDictionaries = resourceDictionaryRepository.findByNameIn(arrayListOf(sourceName)) + Assert.assertNotNull("Failed to query React Resource Dictionary by Names", dbResourceDictionaries) + } + + @Test + fun test04FindByTagsContainingIgnoreCaseReact() { + val dbTagsResourceDictionaries = resourceDictionaryRepository.findByTagsContainingIgnoreCase(sourceName) + Assert.assertNotNull("Failed to query React Resource Dictionary by Tags", dbTagsResourceDictionaries) + } + + @Test + @Transactional + @Commit + fun test05Delete() { + resourceDictionaryRepository.deleteByName(sourceName) + } + + private fun transformResourceDictionary(resourceDefinition: ResourceDefinition): ResourceDictionary { + val resourceDictionary = ResourceDictionary() + resourceDictionary.name = resourceDefinition.name + resourceDictionary.dataType = resourceDefinition.property.type + resourceDictionary.description = resourceDefinition.property.description!! + resourceDictionary.tags = resourceDefinition.tags!! + resourceDictionary.updatedBy = resourceDefinition.updatedBy + resourceDictionary.definition = resourceDefinition + return resourceDictionary + } +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt deleted file mode 100644 index 6351f6aa0..000000000 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * 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. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository - -import org.junit.Assert -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.test.annotation.Commit -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.TestPropertySource -import org.springframework.test.context.junit4.SpringRunner -import org.springframework.transaction.annotation.Transactional - -@RunWith(SpringRunner::class) -@ContextConfiguration(classes = [DesignerApiTestConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDBLibConfiguration::class]) -@TestPropertySource(locations = ["classpath:application-test.properties"]) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ResourceDictionaryReactRepositoryTest { - - private val sourceName = "test-source" - - @Autowired - lateinit var resourceDictionaryRepository: ResourceDictionaryRepository - - @Test - @Commit - fun test01Save() { - val resourceDefinition = JacksonUtils - .readValueFromFile("./../../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", - ResourceDefinition::class.java) - Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition) - resourceDefinition!!.name = sourceName - - val resourceDictionary = transformResourceDictionary(resourceDefinition) - val dbResourceDictionary = resourceDictionaryRepository.save(resourceDictionary) - Assert.assertNotNull("Failed to save ResourceDictionary", dbResourceDictionary) - } - - @Test - fun test02FindByNameReact() { - val dbResourceDictionary = resourceDictionaryRepository.findByName(sourceName) - Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary) - } - - @Test - fun test03FindByNameInReact() { - val dbResourceDictionaries = resourceDictionaryRepository.findByNameIn(arrayListOf(sourceName)) - Assert.assertNotNull("Failed to query React Resource Dictionary by Names", dbResourceDictionaries) - } - - @Test - fun test04FindByTagsContainingIgnoreCaseReact() { - val dbTagsResourceDictionaries = resourceDictionaryRepository.findByTagsContainingIgnoreCase(sourceName) - Assert.assertNotNull("Failed to query React Resource Dictionary by Tags", dbTagsResourceDictionaries) - } - - @Test - @Transactional - @Commit - fun test05Delete() { - resourceDictionaryRepository.deleteByName(sourceName) - } - - private fun transformResourceDictionary(resourceDefinition: ResourceDefinition): ResourceDictionary { - val resourceDictionary = ResourceDictionary() - resourceDictionary.name = resourceDefinition.name - resourceDictionary.dataType = resourceDefinition.property.type - resourceDictionary.description = resourceDefinition.property.description!! - resourceDictionary.tags = resourceDefinition.tags!! - resourceDictionary.updatedBy = resourceDefinition.updatedBy - resourceDictionary.definition = resourceDefinition - return resourceDictionary - } -} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt index 10bf887f6..c644aeedd 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt @@ -21,8 +21,12 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.mock.MockFilePart -import org.onap.ccsdk.cds.controllerblueprints.core.* -import java.util.* +import org.onap.ccsdk.cds.controllerblueprints.core.compress +import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName +import org.onap.ccsdk.cds.controllerblueprints.core.reCreateDirs +import java.util.UUID import kotlin.test.assertTrue class BluePrintEnhancerUtilsTest { @@ -30,7 +34,7 @@ class BluePrintEnhancerUtilsTest { private val blueprintDir = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" private val blueprintArchivePath: String = "./target/blueprints/archive" private val blueprintEnrichmentPath: String = "./target/blueprints/enrichment" - private var zipBlueprintFileName = normalizedPathName(blueprintArchivePath, "test.zip") + private var zipBlueprintFileName = normalizedPathName(blueprintArchivePath, "test.zip") @Before fun setUp() { @@ -62,4 +66,3 @@ class BluePrintEnhancerUtilsTest { } } } - -- cgit 1.2.3-korg