diff options
Diffstat (limited to 'heat-model/src/test/java')
10 files changed, 185 insertions, 341 deletions
diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/CreateStackParamTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/CreateStackParamTest.java index a57eced..d740a15 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/CreateStackParamTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/CreateStackParamTest.java @@ -24,9 +24,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - import java.util.Map; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -36,28 +34,16 @@ public class CreateStackParamTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"template\" : \"template\"," + EOL - + " \"parameters\" : {" + EOL - + " \"parameters-k1\" : \"parameters-v1\"," + EOL - + " \"parameters-k2\" : \"parameters-v2\"" + EOL - + " }," + EOL - + " \"environment\" : \"environment\"," + EOL - + " \"files\" : {" + EOL - + " \"files-k1\" : \"files-v1\"," + EOL - + " \"files-k2\" : \"files-v2\"" + EOL - + " }," + EOL - + " \"stack_name\" : \"stackname\"," + EOL - + " \"template_url\" : \"templateurl\"," + EOL - + " \"timeout_mins\" : 79," + EOL - + " \"disable_rollback\" : true" + EOL - + "}"; - - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private static final String JSON_FULL = "{" + EOL + " \"template\" : \"template\"," + EOL + " \"parameters\" : {" + + EOL + " \"parameters-k1\" : \"parameters-v1\"," + EOL + " \"parameters-k2\" : \"parameters-v2\"" + + EOL + " }," + EOL + " \"environment\" : \"environment\"," + EOL + " \"files\" : {" + EOL + + " \"files-k1\" : \"files-v1\"," + EOL + " \"files-k2\" : \"files-v2\"" + EOL + " }," + EOL + + " \"stack_name\" : \"stackname\"," + EOL + " \"template_url\" : \"templateurl\"," + EOL + + " \"timeout_mins\" : 79," + EOL + " \"disable_rollback\" : true" + EOL + "}"; + + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -73,37 +59,37 @@ public class CreateStackParamTest { public void testMethods() throws Exception { CreateStackParam createstackparam = objectMapper.readValue(JSON_FULL, CreateStackParam.class); createstackparam.toString(); - + String template = createstackparam.getTemplate(); Assert.assertNotNull(template); createstackparam.setTemplate(template); - + String environment = createstackparam.getEnvironment(); Assert.assertNotNull(environment); createstackparam.setEnvironment(environment); - + int timeoutMinutes = createstackparam.getTimeoutMinutes(); Assert.assertNotNull(timeoutMinutes); createstackparam.setTimeoutMinutes(timeoutMinutes); - + boolean disableRollback = createstackparam.getDisableRollback(); Assert.assertNotNull(disableRollback); createstackparam.setDisableRollback(disableRollback); - - Map<String,Object> files = createstackparam.getFiles(); + + Map<String, Object> files = createstackparam.getFiles(); Assert.assertNotNull(files); Assert.assertEquals(2, files.size()); createstackparam.setFiles(files); - + String stackName = createstackparam.getStackName(); Assert.assertNotNull(stackName); createstackparam.setStackName(stackName); - - Map<String,Object> parameters = createstackparam.getParameters(); + + Map<String, Object> parameters = createstackparam.getParameters(); Assert.assertNotNull(parameters); Assert.assertEquals(2, parameters.size()); createstackparam.setParameters(parameters); - + String templateUrl = createstackparam.getTemplateUrl(); Assert.assertNotNull(templateUrl); createstackparam.setTemplateUrl(templateUrl); diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/ErrorTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/ErrorTest.java index 084fd26..cd3aeaa 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/ErrorTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/ErrorTest.java @@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.woorea.openstack.heat.model.Explanation.Error; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -35,21 +34,13 @@ public class ErrorTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"error\" : {" + EOL - + " \"message\" : \"message\"," + EOL - + " \"traceback\" : \"traceback\"," + EOL - + " \"type\" : \"type\"" + EOL - + " }" + EOL - + "}"; + private static final String JSON_FULL = "{" + EOL + " \"error\" : {" + EOL + " \"message\" : \"message\"," + EOL + + " \"traceback\" : \"traceback\"," + EOL + " \"type\" : \"type\"" + EOL + " }" + EOL + "}"; - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.WRAP_ROOT_VALUE) - .enable(DeserializationFeature.UNWRAP_ROOT_VALUE) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(SerializationFeature.WRAP_ROOT_VALUE) + .enable(DeserializationFeature.UNWRAP_ROOT_VALUE).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -65,13 +56,13 @@ public class ErrorTest { public void testMethods() throws Exception { Error error = objectMapper.readValue(JSON_FULL, Error.class); error.toString(); - + String type = error.getType(); Assert.assertNotNull(type); - + String message = error.getMessage(); Assert.assertNotNull(message); - + String traceback = error.getTraceback(); Assert.assertNotNull(traceback); } diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/ExplanationTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/ExplanationTest.java index ff8ebb2..0fc507f 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/ExplanationTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/ExplanationTest.java @@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.woorea.openstack.heat.model.Explanation.Error; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -35,22 +34,14 @@ public class ExplanationTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"explanation\" : \"explanation\"," + EOL - + " \"code\" : 42," + EOL - + " \"title\" : \"title\"," + EOL - + " \"error\" : {" + EOL - + " \"message\" : \"message\"," + EOL - + " \"traceback\" : \"traceback\"," + EOL - + " \"type\" : \"type\"" + EOL - + " }" + EOL - + "}"; + private static final String JSON_FULL = "{" + EOL + " \"explanation\" : \"explanation\"," + EOL + + " \"code\" : 42," + EOL + " \"title\" : \"title\"," + EOL + " \"error\" : {" + EOL + + " \"message\" : \"message\"," + EOL + " \"traceback\" : \"traceback\"," + EOL + + " \"type\" : \"type\"" + EOL + " }" + EOL + "}"; - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -66,16 +57,16 @@ public class ExplanationTest { public void testMethods() throws Exception { Explanation explanation = objectMapper.readValue(JSON_FULL, Explanation.class); explanation.toString(); - + int code = explanation.getCode(); Assert.assertNotNull(code); - + String explanationProperty = explanation.getExplanation(); Assert.assertNotNull(explanationProperty); - + String title = explanation.getTitle(); Assert.assertNotNull(title); - + Error error = explanation.getError(); Assert.assertNotNull(error); } diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/LinkTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/LinkTest.java index 4565fe8..27f1226 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/LinkTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/LinkTest.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -34,16 +33,12 @@ public class LinkTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + "}"; + private static final String JSON_FULL = + "{" + EOL + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + "}"; - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -59,11 +54,11 @@ public class LinkTest { public void testMethods() throws Exception { Link link = objectMapper.readValue(JSON_FULL, Link.class); link.toString(); - + String rel = link.getRel(); Assert.assertNotNull(rel); link.setRel(rel); - + String href = link.getHref(); Assert.assertNotNull(href); link.setHref(href); diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/OutputTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/OutputTest.java index a91eeff..a001548 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/OutputTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/OutputTest.java @@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.woorea.openstack.heat.model.Stack.Output; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -35,17 +34,12 @@ public class OutputTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"description\" : \"description\"," + EOL - + " \"output_value\" : \"outputvalue\"," + EOL - + " \"output_key\" : \"outputkey\"" + EOL - + "}"; + private static final String JSON_FULL = "{" + EOL + " \"description\" : \"description\"," + EOL + + " \"output_value\" : \"outputvalue\"," + EOL + " \"output_key\" : \"outputkey\"" + EOL + "}"; - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -61,13 +55,13 @@ public class OutputTest { public void testMethods() throws Exception { Output output = objectMapper.readValue(JSON_FULL, Output.class); output.toString(); - + String outputKey = output.getOutputKey(); Assert.assertNotNull(outputKey); - + Object outputValue = output.getOutputValue(); Assert.assertNotNull(outputValue); - + String description = output.getDescription(); Assert.assertNotNull(description); } diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/ResourceTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/ResourceTest.java index 0079ef3..07b8c73 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/ResourceTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/ResourceTest.java @@ -24,10 +24,8 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - import java.util.Date; import java.util.List; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -37,29 +35,18 @@ public class ResourceTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"links\" : [ {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " }, {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " } ]," + EOL - + " \"resource_name\" : \"name\"," + EOL - + " \"resource_status\" : \"status\"," + EOL - + " \"physical_resource_id\" : \"physicalresourceid\"," + EOL - + " \"logical_resource_id\" : \"logicalresourceid\"," + EOL - + " \"required_by\" : [ \"requiredby-v1\", \"requiredby-v2\" ]," + EOL - + " \"updated_time\" : 1488110400000," + EOL - + " \"resource_type\" : \"type\"," + EOL - + " \"resource_status_reason\" : \"statusreason\"" + EOL - + "}"; - - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private static final String JSON_FULL = "{" + EOL + " \"links\" : [ {" + EOL + " \"href\" : \"href\"," + EOL + + " \"rel\" : \"rel\"" + EOL + " }, {" + EOL + " \"href\" : \"href\"," + EOL + + " \"rel\" : \"rel\"" + EOL + " } ]," + EOL + " \"resource_name\" : \"name\"," + EOL + + " \"resource_status\" : \"status\"," + EOL + " \"physical_resource_id\" : \"physicalresourceid\"," + EOL + + " \"logical_resource_id\" : \"logicalresourceid\"," + EOL + + " \"required_by\" : [ \"requiredby-v1\", \"requiredby-v2\" ]," + EOL + + " \"updated_time\" : 1488110400000," + EOL + " \"resource_type\" : \"type\"," + EOL + + " \"resource_status_reason\" : \"statusreason\"" + EOL + "}"; + + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -75,41 +62,41 @@ public class ResourceTest { public void testMethods() throws Exception { Resource resource = objectMapper.readValue(JSON_FULL, Resource.class); resource.toString(); - + Date updatedTime = resource.getUpdatedTime(); Assert.assertNotNull(updatedTime); resource.setUpdatedTime(updatedTime); - + String physicalResourceId = resource.getPhysicalResourceId(); Assert.assertNotNull(physicalResourceId); resource.setPhysicalResourceId(physicalResourceId); - + List<String> requiredBy = resource.getRequiredBy(); Assert.assertNotNull(requiredBy); Assert.assertEquals(2, requiredBy.size()); resource.setRequiredBy(requiredBy); - + String statusReason = resource.getStatusReason(); Assert.assertNotNull(statusReason); resource.setStatusReason(statusReason); - + String name = resource.getName(); Assert.assertNotNull(name); resource.setName(name); - + List<Link> links = resource.getLinks(); Assert.assertNotNull(links); Assert.assertEquals(2, links.size()); resource.setLinks(links); - + String logicalResourceId = resource.getLogicalResourceId(); Assert.assertNotNull(logicalResourceId); resource.setLogicalResourceId(logicalResourceId); - + String type = resource.getType(); Assert.assertNotNull(type); resource.setType(type); - + String status = resource.getStatus(); Assert.assertNotNull(status); resource.setStatus(status); diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/ResourcesTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/ResourcesTest.java index 37c5e72..6845ee8 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/ResourcesTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/ResourcesTest.java @@ -24,9 +24,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - import java.util.List; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -36,47 +34,27 @@ public class ResourcesTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"resources\" : [ {" + EOL - + " \"links\" : [ {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " }, {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " } ]," + EOL - + " \"resource_name\" : \"name\"," + EOL - + " \"resource_status\" : \"status\"," + EOL - + " \"physical_resource_id\" : \"physicalresourceid\"," + EOL - + " \"logical_resource_id\" : \"logicalresourceid\"," + EOL - + " \"required_by\" : [ \"requiredby-v1\", \"requiredby-v2\" ]," + EOL - + " \"updated_time\" : 1488110400000," + EOL - + " \"resource_type\" : \"type\"," + EOL - + " \"resource_status_reason\" : \"statusreason\"" + EOL - + " }, {" + EOL - + " \"links\" : [ {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " }, {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " } ]," + EOL - + " \"resource_name\" : \"name\"," + EOL - + " \"resource_status\" : \"status\"," + EOL - + " \"physical_resource_id\" : \"physicalresourceid\"," + EOL - + " \"logical_resource_id\" : \"logicalresourceid\"," + EOL - + " \"required_by\" : [ \"requiredby-v1\", \"requiredby-v2\" ]," + EOL - + " \"updated_time\" : 1488110400000," + EOL - + " \"resource_type\" : \"type\"," + EOL - + " \"resource_status_reason\" : \"statusreason\"" + EOL - + " } ]" + EOL - + "}"; + private static final String JSON_FULL = "{" + EOL + " \"resources\" : [ {" + EOL + " \"links\" : [ {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " }, {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " } ]," + EOL + + " \"resource_name\" : \"name\"," + EOL + " \"resource_status\" : \"status\"," + EOL + + " \"physical_resource_id\" : \"physicalresourceid\"," + EOL + + " \"logical_resource_id\" : \"logicalresourceid\"," + EOL + + " \"required_by\" : [ \"requiredby-v1\", \"requiredby-v2\" ]," + EOL + + " \"updated_time\" : 1488110400000," + EOL + " \"resource_type\" : \"type\"," + EOL + + " \"resource_status_reason\" : \"statusreason\"" + EOL + " }, {" + EOL + " \"links\" : [ {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " }, {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " } ]," + EOL + + " \"resource_name\" : \"name\"," + EOL + " \"resource_status\" : \"status\"," + EOL + + " \"physical_resource_id\" : \"physicalresourceid\"," + EOL + + " \"logical_resource_id\" : \"logicalresourceid\"," + EOL + + " \"required_by\" : [ \"requiredby-v1\", \"requiredby-v2\" ]," + EOL + + " \"updated_time\" : 1488110400000," + EOL + " \"resource_type\" : \"type\"," + EOL + + " \"resource_status_reason\" : \"statusreason\"" + EOL + " } ]" + EOL + "}"; - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -92,13 +70,14 @@ public class ResourcesTest { public void testMethods() throws Exception { Resources resources = objectMapper.readValue(JSON_FULL, Resources.class); resources.toString(); - + List<Resource> list = resources.getList(); Assert.assertNotNull(list); Assert.assertEquals(2, list.size()); - + int cnt = 0; - for (@SuppressWarnings("unused") Resource x : resources) { + for (@SuppressWarnings("unused") + Resource x : resources) { ++cnt; } Assert.assertEquals(2, cnt); diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/StackTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/StackTest.java index ea38918..19d3373 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/StackTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/StackTest.java @@ -25,11 +25,9 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.woorea.openstack.heat.model.Stack.Output; - import java.util.Date; import java.util.List; import java.util.Map; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -39,49 +37,26 @@ public class StackTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"stack\" : {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"links\" : [ {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " }, {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " } ]," + EOL - + " \"id\" : \"id\"," + EOL - + " \"files\" : {" + EOL - + " \"files-k1\" : \"files-v1\"," + EOL - + " \"files-k2\" : \"files-v2\"" + EOL - + " }," + EOL - + " \"outputs\" : [ {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"output_value\" : \"outputvalue\"," + EOL - + " \"output_key\" : \"outputkey\"" + EOL - + " }, {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"output_value\" : \"outputvalue\"," + EOL - + " \"output_key\" : \"outputkey\"" + EOL - + " } ]," + EOL - + " \"parameters\" : {" + EOL - + " \"parameters-k1\" : \"parameters-v1\"," + EOL - + " \"parameters-k2\" : \"parameters-v2\"" + EOL - + " }," + EOL - + " \"stack_status_reason\" : \"stackstatusreason\"," + EOL - + " \"stack_name\" : \"stackname\"," + EOL - + " \"updated_time\" : 1488110400000," + EOL - + " \"creation_time\" : 1488974400000," + EOL - + " \"stack_status\" : \"stackstatus\"" + EOL - + " }" + EOL - + "}"; - - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.WRAP_ROOT_VALUE) - .enable(DeserializationFeature.UNWRAP_ROOT_VALUE) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private static final String JSON_FULL = "{" + EOL + " \"stack\" : {" + EOL + + " \"description\" : \"description\"," + EOL + " \"links\" : [ {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " }, {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " } ]," + EOL + + " \"id\" : \"id\"," + EOL + " \"files\" : {" + EOL + " \"files-k1\" : \"files-v1\"," + EOL + + " \"files-k2\" : \"files-v2\"" + EOL + " }," + EOL + " \"outputs\" : [ {" + EOL + + " \"description\" : \"description\"," + EOL + " \"output_value\" : \"outputvalue\"," + EOL + + " \"output_key\" : \"outputkey\"" + EOL + " }, {" + EOL + + " \"description\" : \"description\"," + EOL + " \"output_value\" : \"outputvalue\"," + EOL + + " \"output_key\" : \"outputkey\"" + EOL + " } ]," + EOL + " \"parameters\" : {" + EOL + + " \"parameters-k1\" : \"parameters-v1\"," + EOL + " \"parameters-k2\" : \"parameters-v2\"" + EOL + + " }," + EOL + " \"stack_status_reason\" : \"stackstatusreason\"," + EOL + + " \"stack_name\" : \"stackname\"," + EOL + " \"updated_time\" : 1488110400000," + EOL + + " \"creation_time\" : 1488974400000," + EOL + " \"stack_status\" : \"stackstatus\"" + EOL + " }" + + EOL + "}"; + + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(SerializationFeature.WRAP_ROOT_VALUE) + .enable(DeserializationFeature.UNWRAP_ROOT_VALUE).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -97,50 +72,50 @@ public class StackTest { public void testMethods() throws Exception { Stack stack = objectMapper.readValue(JSON_FULL, Stack.class); stack.toString(); - + Date updatedTime = stack.getUpdatedTime(); Assert.assertNotNull(updatedTime); stack.setUpdatedTime(updatedTime); - + List<Output> outputs = stack.getOutputs(); Assert.assertNotNull(outputs); Assert.assertEquals(2, outputs.size()); - + String stackStatus = stack.getStackStatus(); Assert.assertNotNull(stackStatus); stack.setStackStatus(stackStatus); - + String description = stack.getDescription(); Assert.assertNotNull(description); stack.setDescription(description); - - Map<String,Object> files = stack.getFiles(); + + Map<String, Object> files = stack.getFiles(); Assert.assertNotNull(files); Assert.assertEquals(2, files.size()); stack.setFiles(files); - + List<Link> links = stack.getLinks(); Assert.assertNotNull(links); Assert.assertEquals(2, links.size()); stack.setLinks(links); - + String stackName = stack.getStackName(); Assert.assertNotNull(stackName); stack.setStackName(stackName); - + String id = stack.getId(); Assert.assertNotNull(id); stack.setId(id); - + Date creationTime = stack.getCreationTime(); Assert.assertNotNull(creationTime); stack.setCreationTime(creationTime); - - Map<String,Object> parameters = stack.getParameters(); + + Map<String, Object> parameters = stack.getParameters(); Assert.assertNotNull(parameters); Assert.assertEquals(2, parameters.size()); stack.setParameters(parameters); - + String stackStatusReason = stack.getStackStatusReason(); Assert.assertNotNull(stackStatusReason); stack.setStackStatusReason(stackStatusReason); diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/StacksTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/StacksTest.java index 880c482..003ba17 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/StacksTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/StacksTest.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -34,79 +33,38 @@ public class StacksTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"stacks\" : [ {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"links\" : [ {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " }, {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " } ]," + EOL - + " \"id\" : \"id\"," + EOL - + " \"files\" : {" + EOL - + " \"files-k1\" : \"files-v1\"," + EOL - + " \"files-k2\" : \"files-v2\"" + EOL - + " }," + EOL - + " \"outputs\" : [ {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"output_value\" : \"outputvalue\"," + EOL - + " \"output_key\" : \"outputkey\"" + EOL - + " }, {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"output_value\" : \"outputvalue\"," + EOL - + " \"output_key\" : \"outputkey\"" + EOL - + " } ]," + EOL - + " \"parameters\" : {" + EOL - + " \"parameters-k1\" : \"parameters-v1\"," + EOL - + " \"parameters-k2\" : \"parameters-v2\"" + EOL - + " }," + EOL - + " \"stack_status_reason\" : \"stackstatusreason\"," + EOL - + " \"stack_name\" : \"stackname\"," + EOL - + " \"updated_time\" : 1488110400000," + EOL - + " \"creation_time\" : 1488974400000," + EOL - + " \"stack_status\" : \"stackstatus\"" + EOL - + " }, {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"links\" : [ {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " }, {" + EOL - + " \"href\" : \"href\"," + EOL - + " \"rel\" : \"rel\"" + EOL - + " } ]," + EOL - + " \"id\" : \"id\"," + EOL - + " \"files\" : {" + EOL - + " \"files-k1\" : \"files-v1\"," + EOL - + " \"files-k2\" : \"files-v2\"" + EOL - + " }," + EOL - + " \"outputs\" : [ {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"output_value\" : \"outputvalue\"," + EOL - + " \"output_key\" : \"outputkey\"" + EOL - + " }, {" + EOL - + " \"description\" : \"description\"," + EOL - + " \"output_value\" : \"outputvalue\"," + EOL - + " \"output_key\" : \"outputkey\"" + EOL - + " } ]," + EOL - + " \"parameters\" : {" + EOL - + " \"parameters-k1\" : \"parameters-v1\"," + EOL - + " \"parameters-k2\" : \"parameters-v2\"" + EOL - + " }," + EOL - + " \"stack_status_reason\" : \"stackstatusreason\"," + EOL - + " \"stack_name\" : \"stackname\"," + EOL - + " \"updated_time\" : 1488110400000," + EOL - + " \"creation_time\" : 1488974400000," + EOL - + " \"stack_status\" : \"stackstatus\"" + EOL - + " } ]" + EOL - + "}"; + private static final String JSON_FULL = "{" + EOL + " \"stacks\" : [ {" + EOL + + " \"description\" : \"description\"," + EOL + " \"links\" : [ {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " }, {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " } ]," + EOL + + " \"id\" : \"id\"," + EOL + " \"files\" : {" + EOL + " \"files-k1\" : \"files-v1\"," + EOL + + " \"files-k2\" : \"files-v2\"" + EOL + " }," + EOL + " \"outputs\" : [ {" + EOL + + " \"description\" : \"description\"," + EOL + " \"output_value\" : \"outputvalue\"," + EOL + + " \"output_key\" : \"outputkey\"" + EOL + " }, {" + EOL + + " \"description\" : \"description\"," + EOL + " \"output_value\" : \"outputvalue\"," + EOL + + " \"output_key\" : \"outputkey\"" + EOL + " } ]," + EOL + " \"parameters\" : {" + EOL + + " \"parameters-k1\" : \"parameters-v1\"," + EOL + " \"parameters-k2\" : \"parameters-v2\"" + EOL + + " }," + EOL + " \"stack_status_reason\" : \"stackstatusreason\"," + EOL + + " \"stack_name\" : \"stackname\"," + EOL + " \"updated_time\" : 1488110400000," + EOL + + " \"creation_time\" : 1488974400000," + EOL + " \"stack_status\" : \"stackstatus\"" + EOL + " }, {" + + EOL + " \"description\" : \"description\"," + EOL + " \"links\" : [ {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " }, {" + EOL + + " \"href\" : \"href\"," + EOL + " \"rel\" : \"rel\"" + EOL + " } ]," + EOL + + " \"id\" : \"id\"," + EOL + " \"files\" : {" + EOL + " \"files-k1\" : \"files-v1\"," + EOL + + " \"files-k2\" : \"files-v2\"" + EOL + " }," + EOL + " \"outputs\" : [ {" + EOL + + " \"description\" : \"description\"," + EOL + " \"output_value\" : \"outputvalue\"," + EOL + + " \"output_key\" : \"outputkey\"" + EOL + " }, {" + EOL + + " \"description\" : \"description\"," + EOL + " \"output_value\" : \"outputvalue\"," + EOL + + " \"output_key\" : \"outputkey\"" + EOL + " } ]," + EOL + " \"parameters\" : {" + EOL + + " \"parameters-k1\" : \"parameters-v1\"," + EOL + " \"parameters-k2\" : \"parameters-v2\"" + EOL + + " }," + EOL + " \"stack_status_reason\" : \"stackstatusreason\"," + EOL + + " \"stack_name\" : \"stackname\"," + EOL + " \"updated_time\" : 1488110400000," + EOL + + " \"creation_time\" : 1488974400000," + EOL + " \"stack_status\" : \"stackstatus\"" + EOL + " } ]" + + EOL + "}"; - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -122,9 +80,10 @@ public class StacksTest { public void testMethods() throws Exception { Stacks stacks = objectMapper.readValue(JSON_FULL, Stacks.class); stacks.toString(); - + int cnt = 0; - for (@SuppressWarnings("unused") Stack x : stacks) { + for (@SuppressWarnings("unused") + Stack x : stacks) { ++cnt; } Assert.assertEquals(2, cnt); diff --git a/heat-model/src/test/java/com/woorea/openstack/heat/model/UpdateStackParamTest.java b/heat-model/src/test/java/com/woorea/openstack/heat/model/UpdateStackParamTest.java index 5eb99c3..33daa6c 100644 --- a/heat-model/src/test/java/com/woorea/openstack/heat/model/UpdateStackParamTest.java +++ b/heat-model/src/test/java/com/woorea/openstack/heat/model/UpdateStackParamTest.java @@ -24,9 +24,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - import java.util.Map; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -36,27 +34,16 @@ public class UpdateStackParamTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"template\" : \"template\"," + EOL - + " \"parameters\" : {" + EOL - + " \"parameters-k1\" : \"parameters-v1\"," + EOL - + " \"parameters-k2\" : \"parameters-v2\"" + EOL - + " }," + EOL - + " \"environment\" : \"environment\"," + EOL - + " \"files\" : {" + EOL - + " \"files-k1\" : \"files-v1\"," + EOL - + " \"files-k2\" : \"files-v2\"" + EOL - + " }," + EOL - + " \"template_url\" : \"templateurl\"," + EOL - + " \"timeout_mins\" : 79," + EOL - + " \"disable_rollback\" : true" + EOL - + "}"; + private static final String JSON_FULL = "{" + EOL + " \"template\" : \"template\"," + EOL + " \"parameters\" : {" + + EOL + " \"parameters-k1\" : \"parameters-v1\"," + EOL + " \"parameters-k2\" : \"parameters-v2\"" + + EOL + " }," + EOL + " \"environment\" : \"environment\"," + EOL + " \"files\" : {" + EOL + + " \"files-k1\" : \"files-v1\"," + EOL + " \"files-k2\" : \"files-v2\"" + EOL + " }," + EOL + + " \"template_url\" : \"templateurl\"," + EOL + " \"timeout_mins\" : 79," + EOL + + " \"disable_rollback\" : true" + EOL + "}"; - private ObjectMapper objectMapper = new ObjectMapper() - .setSerializationInclusion(Include.NON_NULL) - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT).enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); @Test public void testSerialization() throws Exception { @@ -72,33 +59,33 @@ public class UpdateStackParamTest { public void testMethods() throws Exception { UpdateStackParam updatestackparam = objectMapper.readValue(JSON_FULL, UpdateStackParam.class); updatestackparam.toString(); - + String template = updatestackparam.getTemplate(); Assert.assertNotNull(template); updatestackparam.setTemplate(template); - + String environment = updatestackparam.getEnvironment(); Assert.assertNotNull(environment); updatestackparam.setEnvironment(environment); - + int timeoutMinutes = updatestackparam.getTimeoutMinutes(); Assert.assertNotNull(timeoutMinutes); updatestackparam.setTimeoutMinutes(timeoutMinutes); - + boolean disableRollback = updatestackparam.getDisableRollback(); Assert.assertNotNull(disableRollback); updatestackparam.setDisableRollback(disableRollback); - - Map<String,Object> files = updatestackparam.getFiles(); + + Map<String, Object> files = updatestackparam.getFiles(); Assert.assertNotNull(files); Assert.assertEquals(2, files.size()); updatestackparam.setFiles(files); - - Map<String,Object> parameters = updatestackparam.getParameters(); + + Map<String, Object> parameters = updatestackparam.getParameters(); Assert.assertNotNull(parameters); Assert.assertEquals(2, parameters.size()); updatestackparam.setParameters(parameters); - + String templateUrl = updatestackparam.getTemplateUrl(); Assert.assertNotNull(templateUrl); updatestackparam.setTemplateUrl(templateUrl); |