From 7a58af870eb9934dfec4b5353672d7c428208116 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 6 Jun 2018 13:47:21 +0200 Subject: Minor Improvement Code rework postponed to Casablanca to not impact Bejing release + Update version to 3.0.0 Issue-ID: CLAMP-177 Change-Id: I3e2cb22c1158df0cf5d4cf8369f9c469004d68c0 Signed-off-by: Determe, Sebastien (sd378r) --- .../clds/it/CldsHealthcheckServiceItCase.java | 58 ++++++++++++++++++++++ .../clamp/clds/it/OperationPolicyReqItCase.java | 4 +- .../org/onap/clamp/clds/model/CldsModelTest.java | 17 ------- .../org/onap/clamp/clds/swagger/SwaggerConfig.java | 15 ++---- .../clamp/clds/swagger/SwaggerGenerationTest.java | 13 +++-- src/test/resources/clds/key.properties | 1 - 6 files changed, 73 insertions(+), 35 deletions(-) create mode 100644 src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java delete mode 100644 src/test/resources/clds/key.properties (limited to 'src/test') diff --git a/src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java new file mode 100644 index 000000000..40e876880 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 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.clamp.clds.it; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import javax.ws.rs.core.Response; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.clamp.clds.model.CldsHealthCheck; +import org.onap.clamp.clds.service.CldsHealthcheckService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Tests HealthCheck Service. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class CldsHealthcheckServiceItCase { + + @Autowired + private CldsHealthcheckService cldsHealthcheckService; + + @Test + public void testGetHealthCheck() { + Response response = cldsHealthcheckService.gethealthcheck(); + CldsHealthCheck cldsHealthCheck = (CldsHealthCheck) response.getEntity(); + assertNotNull(cldsHealthCheck); + assertEquals("UP", cldsHealthCheck.getHealthCheckStatus()); + assertEquals("CLDS-APP", cldsHealthCheck.getHealthCheckComponent()); + assertEquals("OK", cldsHealthCheck.getDescription()); + } +} diff --git a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java index ba3df843f..b6f3ef423 100644 --- a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java @@ -73,10 +73,10 @@ public class OperationPolicyReqItCase { assertTrue(attributes.size() == 2); // now validate the Yaml, to do so we replace the dynamic ID by a known // key so that we can compare it - String yaml = URLDecoder.decode(attributes.get(0).get(AttributeType.RULE).get("ControlLoopYaml"), "UTF-8"); + String yaml = URLDecoder.decode(attributes.get(0).get(AttributeType.RULE).get("controlLoopYaml"), "UTF-8"); yaml = replaceGeneratedValues(yaml); assertEquals(ResourceFileUtil.getResourceAsString("example/operational-policy/yaml-policy-chain-1.yaml"), yaml); - yaml = URLDecoder.decode(attributes.get(1).get(AttributeType.RULE).get("ControlLoopYaml"), "UTF-8"); + yaml = URLDecoder.decode(attributes.get(1).get(AttributeType.RULE).get("controlLoopYaml"), "UTF-8"); yaml = replaceGeneratedValues(yaml); assertEquals(ResourceFileUtil.getResourceAsString("example/operational-policy/yaml-policy-chain-2.yaml"), yaml); } diff --git a/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java b/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java index 82c668c2a..6ebdc4bbf 100644 --- a/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java +++ b/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java @@ -145,23 +145,6 @@ public class CldsModelTest { fail("Exception should have been sent"); } - @Test(expected = IllegalArgumentException.class) - public void testValidateActionFromDelete() { - CldsModel cldsModel = new CldsModel(); - cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DELETE); - cldsModel.validateAction(CldsEvent.ACTION_SUBMIT); - try { - cldsModel.validateAction(CldsEvent.ACTION_CREATE); - fail("Exception should have been sent"); - } catch (IllegalArgumentException e) { - System.out.println("Exception caught IllegalArgumentException as expected"); - } - cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DELETE); - cldsModel.getEvent().setActionStateCd(CldsEvent.ACTION_STATE_SENT); - cldsModel.validateAction(CldsEvent.ACTION_SUBMIT); - fail("Exception should have been sent"); - } - @Test(expected = IllegalArgumentException.class) public void testValidateActionFromStop() { CldsModel cldsModel = new CldsModel(); diff --git a/src/test/java/org/onap/clamp/clds/swagger/SwaggerConfig.java b/src/test/java/org/onap/clamp/clds/swagger/SwaggerConfig.java index 87409644d..96784dd64 100644 --- a/src/test/java/org/onap/clamp/clds/swagger/SwaggerConfig.java +++ b/src/test/java/org/onap/clamp/clds/swagger/SwaggerConfig.java @@ -23,24 +23,17 @@ package org.onap.clamp.clds.swagger; import org.springframework.context.annotation.Configuration; + import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.service.*; -import springfox.documentation.spi.DocumentationType; +import springfox.documentation.service.ApiInfo; import springfox.documentation.swagger2.annotations.EnableSwagger2; - - - @EnableSwagger2 @Configuration public class SwaggerConfig { private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("Clamp") - .description("Clamp API Description") - .license("Apache 2.0") - .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0") - .build(); + return new ApiInfoBuilder().title("Clamp").description("Clamp API Description").license("Apache 2.0") + .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0").build(); } } diff --git a/src/test/java/org/onap/clamp/clds/swagger/SwaggerGenerationTest.java b/src/test/java/org/onap/clamp/clds/swagger/SwaggerGenerationTest.java index a4691b164..363d12d40 100644 --- a/src/test/java/org/onap/clamp/clds/swagger/SwaggerGenerationTest.java +++ b/src/test/java/org/onap/clamp/clds/swagger/SwaggerGenerationTest.java @@ -19,19 +19,24 @@ * ============LICENSE_END============================================ * =================================================================== */ + package org.onap.clamp.clds.swagger; +import java.nio.file.Path; +import java.nio.file.Paths; + import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.clamp.clds.Application; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.nio.file.Path; -import java.nio.file.Paths; + import io.github.swagger2markup.Swagger2MarkupConverter; -import org.onap.clamp.clds.Application; @RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = {Application.class, SwaggerConfig.class}) +@SpringBootTest(classes = { + Application.class, SwaggerConfig.class +}) public class SwaggerGenerationTest { @Test diff --git a/src/test/resources/clds/key.properties b/src/test/resources/clds/key.properties deleted file mode 100644 index dda811040..000000000 --- a/src/test/resources/clds/key.properties +++ /dev/null @@ -1 +0,0 @@ -org.onap.clamp.encryption.aes.key=aa3871669d893c7fb8abbcda31b88b4f \ No newline at end of file -- cgit 1.2.3-korg