From 2e7b15f6a71764e2dba81b70187b17f1fbbb32ab Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 16 Jan 2020 14:35:57 +0100 Subject: Fix checkstyle issue Fix checkstyle issues and remove useless files Issue-ID: CLAMP-555 Change-Id: I02382ed48d7321b0a6b8650efbf7663f943f17ba Signed-off-by: sebdet --- .../clds/tosca/ToscaYamlToJsonConvertorTest.java | 28 ++++--- .../org/onap/clamp/clds/util/JsonUtilsTest.java | 92 +--------------------- 2 files changed, 17 insertions(+), 103 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java index 18f77cba0..a9e279de4 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java @@ -38,7 +38,8 @@ public class ToscaYamlToJsonConvertorTest { * This Test validates TOSCA yaml to JSON Schema conversion based on JSON Editor * Schema. * - * @throws IOException In case of issue when opening the tosca yaml file and converted json file + * @throws IOException In case of issue when opening the tosca yaml file and + * converted json file */ @Test public final void testParseToscaYaml() throws IOException { @@ -53,37 +54,38 @@ public class ToscaYamlToJsonConvertorTest { } /** - * This Test validates TOSCA yaml with constraints to JSON Schema conversion based on JSON Editor - * Schema. + * This Test validates TOSCA yaml with constraints to JSON Schema conversion + * based on JSON Editor Schema. * - * @throws IOException In case of issue when opening the tosca yaml file and converted json file + * @throws IOException In case of issue when opening the tosca yaml file and + * converted json file */ @Test public final void testParseToscaYamlWithConstraints() throws IOException { String toscaModelYaml = ResourceFileUtil.getResourceAsString("tosca/tosca-with-constraints.yaml"); ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(); - String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml,"onap.policies.monitoring.example.app"); + String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.example.app"); assertNotNull(parsedJsonSchema); - JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-constraints" + - ".json"), - parsedJsonSchema, true); + JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-constraints.json"), + parsedJsonSchema, true); } /** - * This Test validates TOSCA yaml with different datatypes to JSON Schema conversion based on JSON Editor - * Schema. + * This Test validates TOSCA yaml with different datatypes to JSON Schema + * conversion based on JSON Editor Schema. * - * @throws IOException In case of issue when opening the tosca yaml file and converted json file + * @throws IOException In case of issue when opening the tosca yaml file and + * converted json file */ @Test public final void testParseToscaYamlWithTypes() throws IOException { String toscaModelYaml = ResourceFileUtil.getResourceAsString("tosca/tosca-with-datatypes.yaml"); ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(); - String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml,"onap.policies.monitoring.example.app"); + String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.example.app"); assertNotNull(parsedJsonSchema); JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-datatypes.json"), - parsedJsonSchema, true); + parsedJsonSchema, true); } } diff --git a/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java index d1adc166f..926ed66b6 100644 --- a/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java +++ b/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java @@ -26,16 +26,10 @@ package org.onap.clamp.clds.util; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - import java.io.IOException; -import java.util.List; import org.junit.Test; @@ -56,26 +50,6 @@ public class JsonUtilsTest { } } - private static final JsonObject DEPLOY_PARAMETERS = JsonUtils.GSON.fromJson( - "{\n" - + " \"aaiEnrichmentHost\": \"aai.onap.svc.cluster.local\",\n" - + " \"aaiEnrichmentPort\": \"8443\",\n" - + " \"enableAAIEnrichment\": true,\n" - + " \"dmaap_host\": \"message-router\",\n" - + " \"dmaap_port\": \"3904\",\n" - + " \"enableRedisCaching\": false,\n" - + " \"redisHosts\": \"dcae-redis:6379\",\n" - + " \"tag_version\": \"nexus3.onap.org:10001/onap/org.onap.dcaegen2." - + "deployments.tca-cdap-container:1.1.0\",\n" - + " \"consul_host\": \"consul-server\",\n" - + " \"consul_port\": \"8500\",\n" - + " \"cbs_host\": \"config-binding-service\",\n" - + " \"cbs_port\": \"10000\",\n" - + " \"external_port\": \"32010\",\n" - + " \"policy_id\": \"AUTO_GENERATED_POLICY_ID_AT_SUBMIT\"\n" - + " }", JsonObject.class); - - @Test public void testGetObjectMapperInstance() { assertNotNull(JsonUtils.GSON); @@ -90,74 +64,12 @@ public class JsonUtilsTest { TestClass test = new TestClass("value1", "value2"); test.setObject2(new TestObject2("test3")); Object testObject = JsonUtils.GSON.fromJson("[\"org.onap.clamp.clds.util.JsonUtilsTest$TestClass\"" - + ",{\"test\":\"value1\",\"test2\":\"value2\",\"object2\":[\"org.onap.clamp.clds.util.TestObject2\"," - + "{\"test3\":\"test3\"}]}]", Object.class); + + ",{\"test\":\"value1\",\"test2\":\"value2\",\"object2\":[\"org.onap.clamp.clds.util.TestObject2\"," + + "{\"test3\":\"test3\"}]}]", Object.class); assertNotNull(testObject); assertFalse(testObject instanceof TestObject); } - @Test - public void shouldReturnJsonValueByName() throws IOException { - // given - String modelProperties = ResourceFileUtil - .getResourceAsString("example/model-properties/custom/modelBpmnPropertiesMultiVF.json"); - JsonElement globalElement = JsonUtils.GSON.fromJson(modelProperties, JsonObject.class).get("global"); - - // when - String locationName = JsonUtils.getStringValueByName(globalElement, "location"); - String timeoutValue = JsonUtils.getStringValueByName(globalElement, "timeout"); - - // then - assertThat(locationName).isEqualTo("SNDGCA64"); - assertThat(timeoutValue).isEqualTo("500"); - } - - @Test - public void shouldReturnJsonObjectByPropertyName() throws IOException { - // given - String modelProperties = ResourceFileUtil - .getResourceAsString("example/model-properties/custom/modelBpmnPropertiesMultiVF.json"); - JsonElement globalElement = JsonUtils.GSON.fromJson(modelProperties, JsonObject.class).get("global"); - - // when - JsonObject deployParameters = JsonUtils.getJsonObjectByName(globalElement, "deployParameters"); - - // then - assertThat(deployParameters).isEqualToComparingFieldByField(DEPLOY_PARAMETERS); - } - - @Test - public void shouldReturnJsonValuesByPropertyName() throws IOException { - // given - String modelProperties = ResourceFileUtil - .getResourceAsString("example/model-properties/custom/modelBpmnPropertiesMultiVF.json"); - JsonElement globalElement = JsonUtils.GSON.fromJson(modelProperties, JsonObject.class).get("global"); - - // when - List vfs = JsonUtils.getStringValuesByName(globalElement, "vf"); - - // then - assertThat(vfs).containsExactly( - "6c7aaec2-59eb-41d9-8681-b7f976ab668d", - "8sadsad0-a98s-6a7s-fd12-sadji9sa8d12", - "8sfd71ad-a90d-asd9-as87-8a7sd81adsaa" - ); - } - - @Test - public void shouldReturnJsonValueAsInteger() throws IOException { - // given - String modelProperties = ResourceFileUtil - .getResourceAsString("example/model-properties/custom/modelBpmnPropertiesMultiVF.json"); - JsonElement globalElement = JsonUtils.GSON.fromJson(modelProperties, JsonObject.class).get("global"); - - // when - Integer timeoutValue = JsonUtils.getIntValueByName(globalElement, "timeout"); - - // then - assertThat(timeoutValue).isEqualTo(500); - } - @Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionFileNotExists() throws IOException { ResourceFileUtil.getResourceAsString("example/notExist.json"); -- cgit 1.2.3-korg