diff options
Diffstat (limited to 'heat-model/src')
20 files changed, 449 insertions, 571 deletions
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java index 09bb14c..9781184 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java @@ -21,7 +21,6 @@ package com.woorea.openstack.heat.model; */ import java.util.Map; - import com.fasterxml.jackson.annotation.JsonProperty; public class CreateStackParam { @@ -131,23 +130,9 @@ public class CreateStackParam { @Override public String toString() { - return String.format("CreateStackParam{" - + "stackName='%s'," - + " templateUrl='%s'," - + " template='%s'," - + " parameters=%s," - + " timeoutMinutes=%d," - + " environment='%s'," - + " disableRollback='%s'," - + " files=%s" - + "}", - stackName, - templateUrl, - template, - parameters, - timeoutMinutes, - environment, - disableRollback, - files); + return String.format( + "CreateStackParam{" + "stackName='%s'," + " templateUrl='%s'," + " template='%s'," + " parameters=%s," + + " timeoutMinutes=%d," + " environment='%s'," + " disableRollback='%s'," + " files=%s" + "}", + stackName, templateUrl, template, parameters, timeoutMinutes, environment, disableRollback, files); } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Event.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Event.java index 8abcdd5..c346ce3 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Event.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Event.java @@ -17,111 +17,110 @@ import java.util.List; * limitations under the License. * ============LICENSE_END========================================================= */ - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "event_time", "id", "links", "logical_resource_id", "physical_resource_id", "resource_name", - "resource_status", "resource_status_reason" }) +@JsonPropertyOrder({"event_time", "id", "links", "logical_resource_id", "physical_resource_id", "resource_name", + "resource_status", "resource_status_reason"}) public class Event { - @JsonProperty("event_time") - private String eventTime; - @JsonProperty("id") - private String id; - @JsonProperty("links") - private List<Link> links = null; - @JsonProperty("logical_resource_id") - private String logicalResourceId; - @JsonProperty("physical_resource_id") - private Object physicalResourceId; - @JsonProperty("resource_name") - private String resourceName; - @JsonProperty("resource_status") - private String resourceStatus; - @JsonProperty("resource_status_reason") - private String resourceStatusReason; - - @JsonProperty("event_time") - public String getEventTime() { - return eventTime; - } - - @JsonProperty("event_time") - public void setEventTime(String eventTime) { - this.eventTime = eventTime; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @JsonProperty("id") - public void setId(String id) { - this.id = id; - } - - @JsonProperty("links") - public List<Link> getLinks() { - return links; - } - - @JsonProperty("links") - public void setLinks(List<Link> links) { - this.links = links; - } - - @JsonProperty("logical_resource_id") - public String getLogicalResourceId() { - return logicalResourceId; - } - - @JsonProperty("logical_resource_id") - public void setLogicalResourceId(String logicalResourceId) { - this.logicalResourceId = logicalResourceId; - } - - @JsonProperty("physical_resource_id") - public Object getPhysicalResourceId() { - return physicalResourceId; - } - - @JsonProperty("physical_resource_id") - public void setPhysicalResourceId(Object physicalResourceId) { - this.physicalResourceId = physicalResourceId; - } - - @JsonProperty("resource_name") - public String getResourceName() { - return resourceName; - } - - @JsonProperty("resource_name") - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - @JsonProperty("resource_status") - public String getResourceStatus() { - return resourceStatus; - } - - @JsonProperty("resource_status") - public void setResourceStatus(String resourceStatus) { - this.resourceStatus = resourceStatus; - } - - @JsonProperty("resource_status_reason") - public String getResourceStatusReason() { - return resourceStatusReason; - } - - @JsonProperty("resource_status_reason") - public void setResourceStatusReason(String resourceStatusReason) { - this.resourceStatusReason = resourceStatusReason; - } + @JsonProperty("event_time") + private String eventTime; + @JsonProperty("id") + private String id; + @JsonProperty("links") + private List<Link> links = null; + @JsonProperty("logical_resource_id") + private String logicalResourceId; + @JsonProperty("physical_resource_id") + private Object physicalResourceId; + @JsonProperty("resource_name") + private String resourceName; + @JsonProperty("resource_status") + private String resourceStatus; + @JsonProperty("resource_status_reason") + private String resourceStatusReason; + + @JsonProperty("event_time") + public String getEventTime() { + return eventTime; + } + + @JsonProperty("event_time") + public void setEventTime(String eventTime) { + this.eventTime = eventTime; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("id") + public void setId(String id) { + this.id = id; + } + + @JsonProperty("links") + public List<Link> getLinks() { + return links; + } + + @JsonProperty("links") + public void setLinks(List<Link> links) { + this.links = links; + } + + @JsonProperty("logical_resource_id") + public String getLogicalResourceId() { + return logicalResourceId; + } + + @JsonProperty("logical_resource_id") + public void setLogicalResourceId(String logicalResourceId) { + this.logicalResourceId = logicalResourceId; + } + + @JsonProperty("physical_resource_id") + public Object getPhysicalResourceId() { + return physicalResourceId; + } + + @JsonProperty("physical_resource_id") + public void setPhysicalResourceId(Object physicalResourceId) { + this.physicalResourceId = physicalResourceId; + } + + @JsonProperty("resource_name") + public String getResourceName() { + return resourceName; + } + + @JsonProperty("resource_name") + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + @JsonProperty("resource_status") + public String getResourceStatus() { + return resourceStatus; + } + + @JsonProperty("resource_status") + public void setResourceStatus(String resourceStatus) { + this.resourceStatus = resourceStatus; + } + + @JsonProperty("resource_status_reason") + public String getResourceStatusReason() { + return resourceStatusReason; + } + + @JsonProperty("resource_status_reason") + public void setResourceStatusReason(String resourceStatusReason) { + this.resourceStatusReason = resourceStatusReason; + } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Events.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Events.java index ca4fdff..4363129 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Events.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Events.java @@ -20,25 +20,24 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; public class Events implements Iterable<Event>, Serializable { - /** - * - */ - private static final long serialVersionUID = 3598543745379474704L; - - @JsonProperty("events") - private List<Event> events = new ArrayList<>(); + /** + * + */ + private static final long serialVersionUID = 3598543745379474704L; + + @JsonProperty("events") + private List<Event> events = new ArrayList<>(); public List<Event> getEvents() { return events; } - + @Override public Iterator<Event> iterator() { return events.iterator(); diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java index 2b1628b..178ae0e 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; */ // There is no Root element for the Explanation return -//@JsonRootName("error") +// @JsonRootName("error") public class Explanation { @JsonProperty("explanation") private String explanation; @@ -34,7 +34,7 @@ public class Explanation { @JsonProperty("title") private String title; - + @JsonRootName("error") public static class Error { @JsonProperty("message") @@ -49,45 +49,43 @@ public class Explanation { public String getMessage() { return message; } - + public String getTraceback() { return traceback; } - + public String getType() { return type; } } - + private Error error; - + public String getExplanation() { return explanation; } - + public int getCode() { return code; } - + public String getTitle() { return title; } - + public Error getError() { return error; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { - return "Explanation [ " + - "code='" + code + - "', title='" + title + - "', explanation='" + explanation + - "', Error [type='" + error.type + - "', message='" + error.message + "' ] ]"; + return "Explanation [ " + "code='" + code + "', title='" + title + "', explanation='" + explanation + + "', Error [type='" + error.type + "', message='" + error.message + "' ] ]"; } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java index f70229e..d326e72 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java @@ -43,9 +43,6 @@ public class Link { @Override public String toString() { - return "Link{" + - "href='" + href + '\'' + - ", rel='" + rel + '\'' + - '}'; + return "Link{" + "href='" + href + '\'' + ", rel='" + rel + '\'' + '}'; } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java index df8ef01..5f2468d 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java @@ -18,7 +18,6 @@ package com.woorea.openstack.heat.model; import java.util.Date; import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; public class Resource { @@ -43,6 +42,9 @@ public class Resource { @JsonProperty("updated_time") private Date updatedTime; + @JsonProperty("creation_time") + private Date creationTime; + @JsonProperty("resource_type") private String type; @@ -53,6 +55,14 @@ public class Resource { return statusReason; } + public Date getCreationTime() { + return creationTime; + } + + public void setCreationTime(Date creationTime) { + this.creationTime = creationTime; + } + public void setStatusReason(String statusReason) { this.statusReason = statusReason; } @@ -123,16 +133,9 @@ public class Resource { @Override public String toString() { - return "Resource{" + - "name='" + name + '\'' + - ", links=" + links + - ", status='" + status + '\'' + - ", physicalResourceId='" + physicalResourceId + '\'' + - ", logicalResourceId='" + logicalResourceId + '\'' + - ", requiredBy=" + requiredBy + - ", updatedTime=" + updatedTime + - ", type='" + type + '\'' + - ", statusReason='" + statusReason + '\'' + - '}'; + return "Resource{" + "name='" + name + '\'' + ", links=" + links + ", status='" + status + '\'' + + ", physicalResourceId='" + physicalResourceId + '\'' + ", logicalResourceId='" + logicalResourceId + + '\'' + ", requiredBy=" + requiredBy + ", updatedTime=" + updatedTime + ", type='" + type + '\'' + + ", statusReason='" + statusReason + '\'' + '}'; } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java index db99f04..80069d5 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java @@ -19,7 +19,6 @@ package com.woorea.openstack.heat.model; import java.io.Serializable; import java.util.Iterator; import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; @@ -39,8 +38,6 @@ public class Resources implements Iterable<Resource>, Serializable { @Override public String toString() { - return "Resources{" + - "list=" + list + - '}'; + return "Resources{" + "list=" + list + '}'; } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java index 340f3d1..cb2d254 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @@ -42,6 +41,7 @@ public class Stack { @JsonProperty("links") private List<Link> links; + @JsonProperty("stack_status_reason") private String stackStatusReason; @@ -59,10 +59,76 @@ public class Stack { @JsonProperty("id") private String id; - + + @JsonProperty("template_description") + private String templateDescription; + + @JsonProperty("stack_owner") + private String stackOwner; + + @JsonProperty("disable_rollback") + private boolean disableRollback; + + @JsonProperty("stack_user_project_id") + private String userProjectId; + + @JsonProperty("timeout_mins") + private int timeouteMinutes; + + public String getTemplateDescription() { + return templateDescription; + } + + public void setTemplateDescription(String templateDescription) { + this.templateDescription = templateDescription; + } + + public String getStackOwner() { + return stackOwner; + } + + public void setStackOwner(String stackOwner) { + this.stackOwner = stackOwner; + } + + public boolean isDisableRollback() { + return disableRollback; + } + + public void setDisableRollback(boolean disableRollback) { + this.disableRollback = disableRollback; + } + + public String getUserProjectId() { + return userProjectId; + } + + public void setUserProjectId(String userProjectId) { + this.userProjectId = userProjectId; + } + + public int getTimeouteMinutes() { + return timeouteMinutes; + } + + public void setTimeouteMinutes(int timeouteMinutes) { + this.timeouteMinutes = timeouteMinutes; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + @JsonProperty("project") + private String project; + @JsonProperty("files") private Map<String, Object> files = null; - + // ObjectMapper instance to parse Json stack outputs @JsonIgnore private static ObjectMapper mapper = new ObjectMapper(); @@ -131,10 +197,11 @@ public class Stack { public void setDescription(String description) { this.description = description; } - + public Map<String, Object> getFiles() { return this.files; } + public void setFiles(Map<String, Object> files) { this.files = files; } @@ -142,31 +209,23 @@ public class Stack { @Override public String toString() { - return "Stack{" + - "description='" + description + '\'' + - ", links=" + links + - ", stackStatusReason='" + stackStatusReason + '\'' + - ", stackName='" + stackName + '\'' + - ", updatedTime=" + updatedTime + - ", creationTime=" + creationTime + - ", stackStatus='" + stackStatus + '\'' + - ", id='" + id + '\'' + - ", outputs='" + outputs + '\'' + - ", parameters='" + parameters + '\'' + - ", files='" + files + '\'' + - '}'; - } - - @JsonIgnoreProperties(ignoreUnknown=true) + return "Stack{" + "description='" + description + '\'' + ", links=" + links + ", stackStatusReason='" + + stackStatusReason + '\'' + ", stackName='" + stackName + '\'' + ", updatedTime=" + updatedTime + + ", creationTime=" + creationTime + ", stackStatus='" + stackStatus + '\'' + ", id='" + id + '\'' + + ", outputs='" + outputs + '\'' + ", parameters='" + parameters + '\'' + ", files='" + files + '\'' + + '}'; + } + + @JsonIgnoreProperties(ignoreUnknown = true) public static final class Output { @JsonProperty("output_value") private Object outputValue; - + private String description; - + @JsonProperty("output_key") private String outputKey; - + public Object getOutputValue() { return outputValue; } @@ -179,23 +238,24 @@ public class Stack { return outputKey; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { - return "Output [key=" + outputKey + ", value=" - + outputValue + "]"; + return "Output [key=" + outputKey + ", value=" + outputValue + "]"; } } - + private List<Output> outputs; public List<Output> getOutputs() { return outputs; } - - private Object _findOutputValue (String key) { + + private Object _findOutputValue(String key) { for (Output o : outputs) { if (o.getOutputKey().equals(key)) { return o.getOutputValue(); @@ -203,57 +263,49 @@ public class Stack { } return null; } - + /* - * Return a stack output as a String. - * Generally speaking, most outputs will be Strings. + * Return a stack output as a String. Generally speaking, most outputs will be Strings. */ - public String getOutputValue (String key) - { + public String getOutputValue(String key) { Object value = _findOutputValue(key); if (value != null) return value.toString(); else return null; } - + /* - * Return a stack output as a Json-mapped Object of the provided type. - * This is useful for json-object stack outputs. + * Return a stack output as a Json-mapped Object of the provided type. This is useful for json-object stack outputs. */ - public <T> T getOutputValue (String key, Class<T> type) - { + public <T> T getOutputValue(String key, Class<T> type) { try { String s = mapper.writeValueAsString(_findOutputValue(key)); return mapper.readValue(s, type); - } - catch (IOException e) { + } catch (IOException e) { return null; } } - + @JsonProperty("parameters") - private Map<String,Object> parameters = new HashMap<>(); - - public void setParameters (Map<String,Object> params) - { + private Map<String, Object> parameters = new HashMap<>(); + + public void setParameters(Map<String, Object> params) { // Need to "fix" comma-delimited-list parameters for pre-Juno Heat // (see https://bugs.launchpad.net/heat/+bug/1367393) parameters = params; - - for (Entry<String,Object> param : parameters.entrySet()) - { + + for (Entry<String, Object> param : parameters.entrySet()) { // CDL params are returned as a string with format: // "[u'<value1>',u'<value2>',...]" String value = param.getValue().toString(); - if (value.startsWith("[") && value.endsWith("]")) - { - param.setValue(value.substring(1,value.length()-1).replaceAll("u'([^\']+)'","$1")); + if (value.startsWith("[") && value.endsWith("]")) { + param.setValue(value.substring(1, value.length() - 1).replaceAll("u'([^\']+)'", "$1")); } } } - - public Map<String,Object> getParameters() { + + public Map<String, Object> getParameters() { return parameters; } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java index d4b11d6..59ff5dd 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java @@ -19,13 +19,23 @@ package com.woorea.openstack.heat.model; import java.io.Serializable; import java.util.Iterator; import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; public class Stacks implements Iterable<Stack>, Serializable { @JsonProperty("stacks") private List<Stack> list; + @JsonProperty("links") + private List<Link> links; + + public List<Link> getLinks() { + return links; + } + + public void setLinks(List<Link> links) { + this.links = links; + } + @Override public Iterator<Stack> iterator() { return list.iterator(); diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/UpdateStackParam.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/UpdateStackParam.java index 220e400..9a7c719 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/UpdateStackParam.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/UpdateStackParam.java @@ -16,7 +16,6 @@ package com.woorea.openstack.heat.model; import java.util.Map; - import com.fasterxml.jackson.annotation.JsonProperty; public class UpdateStackParam { @@ -37,7 +36,7 @@ public class UpdateStackParam { @JsonProperty("disable_rollback") private boolean disableRollback = true; - + @JsonProperty("files") private Map<String, Object> files; @@ -85,11 +84,12 @@ public class UpdateStackParam { public String getEnvironment() { return environment; - } + } public void setFiles(Map<String, Object> files) { this.files = files; } + public Map<String, Object> getFiles() { return this.files; } @@ -113,14 +113,8 @@ public class UpdateStackParam { @Override public String toString() { - return "UpdateStackParam{" + - " templateUrl='" + templateUrl + '\'' + - ", template='" + template + '\'' + - ", parameters=" + parameters + - ", timeoutMinutes=" + timeoutMinutes + - ", environment='" + environment + '\'' + - ", disableRollback='" + disableRollback + '\'' + - ", files=" + files + - '}'; + return "UpdateStackParam{" + " templateUrl='" + templateUrl + '\'' + ", template='" + template + '\'' + + ", parameters=" + parameters + ", timeoutMinutes=" + timeoutMinutes + ", environment='" + environment + + '\'' + ", disableRollback='" + disableRollback + '\'' + ", files=" + files + '}'; } } 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); |