From 3f9a0c3183480d150089c0d5a6e507c877f7d121 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Thu, 2 May 2019 09:42:55 -0400 Subject: Enhance Openstack Client Update Openstack Client to support additional fields Updat all formatting issues Issue-ID: SO-1844 Change-Id: I1369e0c18cc25274db8df7e12855a020b8da38da Signed-off-by: Smokowski, Steve (ss835w) --- swift-model/pom.xml | 47 +++++++++++----------- .../com/woorea/openstack/swift/model/Account.java | 14 ++++--- .../woorea/openstack/swift/model/Container.java | 18 ++++----- .../com/woorea/openstack/swift/model/Object.java | 15 ++++--- .../openstack/swift/model/ObjectDownload.java | 2 +- .../openstack/swift/model/ObjectForUpload.java | 10 ++--- .../openstack/swift/model/ContainerTest.java | 22 ++++------ .../woorea/openstack/swift/model/ObjectTest.java | 36 +++++++---------- 8 files changed, 76 insertions(+), 88 deletions(-) (limited to 'swift-model') diff --git a/swift-model/pom.xml b/swift-model/pom.xml index 0229890..38708cf 100644 --- a/swift-model/pom.xml +++ b/swift-model/pom.xml @@ -1,24 +1,25 @@ - - 4.0.0 - - org.onap.so.libs - openstack-java-sdk - 1.4.0-SNAPSHOT - - org.onap.so.libs.openstack-java-sdk - swift-model - OpenStack Swift Model - OpenStack Swift Model - - - junit - junit - test - - - org.skyscreamer - jsonassert - test - - + + 4.0.0 + + org.onap.so.libs + openstack-java-sdk + 1.4.0-SNAPSHOT + + org.onap.so.libs.openstack-java-sdk + swift-model + OpenStack Swift Model + OpenStack Swift Model + + + junit + junit + test + + + org.skyscreamer + jsonassert + test + + diff --git a/swift-model/src/main/java/com/woorea/openstack/swift/model/Account.java b/swift-model/src/main/java/com/woorea/openstack/swift/model/Account.java index 008574e..64bc2bf 100644 --- a/swift-model/src/main/java/com/woorea/openstack/swift/model/Account.java +++ b/swift-model/src/main/java/com/woorea/openstack/swift/model/Account.java @@ -21,9 +21,9 @@ import java.io.Serializable; public class Account implements Serializable { private Integer containerCount; - + private Integer objectCount; - + private Integer bytesUsed; /** @@ -68,13 +68,15 @@ public class Account implements Serializable { this.bytesUsed = bytesUsed; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { - return "Account [containerCount=" + containerCount + ", objectCount=" - + objectCount + ", bytesUsed=" + bytesUsed + "]"; + return "Account [containerCount=" + containerCount + ", objectCount=" + objectCount + ", bytesUsed=" + bytesUsed + + "]"; } - + } diff --git a/swift-model/src/main/java/com/woorea/openstack/swift/model/Container.java b/swift-model/src/main/java/com/woorea/openstack/swift/model/Container.java index 5efe9a7..5299a5f 100644 --- a/swift-model/src/main/java/com/woorea/openstack/swift/model/Container.java +++ b/swift-model/src/main/java/com/woorea/openstack/swift/model/Container.java @@ -17,16 +17,15 @@ package com.woorea.openstack.swift.model; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonProperty; public class Container implements Serializable { - + private String name; - + @JsonProperty("count") private Integer objectCount; - + @JsonProperty("bytes") private Long bytesUsed; @@ -72,15 +71,16 @@ public class Container implements Serializable { this.bytesUsed = bytesUsed; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { - return "Container [name=" + name + ", objectCount=" + objectCount - + ", bytesUsed=" + bytesUsed + "]"; + return "Container [name=" + name + ", objectCount=" + objectCount + ", bytesUsed=" + bytesUsed + "]"; } - - + + } diff --git a/swift-model/src/main/java/com/woorea/openstack/swift/model/Object.java b/swift-model/src/main/java/com/woorea/openstack/swift/model/Object.java index cfc3eba..36d56fe 100644 --- a/swift-model/src/main/java/com/woorea/openstack/swift/model/Object.java +++ b/swift-model/src/main/java/com/woorea/openstack/swift/model/Object.java @@ -18,22 +18,21 @@ package com.woorea.openstack.swift.model; import java.io.Serializable; import java.util.Calendar; - import com.fasterxml.jackson.annotation.JsonProperty; public class Object implements Serializable { - + private String subdir; - + private String name; - + private String hash; - + private int bytes; - + @JsonProperty("content_type") private String contentType; - + @JsonProperty("last_modified") private Calendar lastModified; @@ -120,5 +119,5 @@ public class Object implements Serializable { public void setLastModified(Calendar lastModified) { this.lastModified = lastModified; } - + } diff --git a/swift-model/src/main/java/com/woorea/openstack/swift/model/ObjectDownload.java b/swift-model/src/main/java/com/woorea/openstack/swift/model/ObjectDownload.java index 269532e..f75f27e 100644 --- a/swift-model/src/main/java/com/woorea/openstack/swift/model/ObjectDownload.java +++ b/swift-model/src/main/java/com/woorea/openstack/swift/model/ObjectDownload.java @@ -23,7 +23,7 @@ import java.io.InputStream; public class ObjectDownload { private Object object; - + private InputStream inputStream; /** diff --git a/swift-model/src/main/java/com/woorea/openstack/swift/model/ObjectForUpload.java b/swift-model/src/main/java/com/woorea/openstack/swift/model/ObjectForUpload.java index 93c8c72..b35d14f 100644 --- a/swift-model/src/main/java/com/woorea/openstack/swift/model/ObjectForUpload.java +++ b/swift-model/src/main/java/com/woorea/openstack/swift/model/ObjectForUpload.java @@ -22,11 +22,11 @@ import java.util.Map; public class ObjectForUpload { - + private String container; - + private String name; - + private Map properties; private InputStream inputStream; @@ -63,7 +63,7 @@ public class ObjectForUpload { * @return the properties */ public Map getProperties() { - if(properties == null) { + if (properties == null) { properties = new HashMap<>(); } return properties; @@ -83,6 +83,6 @@ public class ObjectForUpload { this.inputStream = inputStream; } - + } diff --git a/swift-model/src/test/java/com/woorea/openstack/swift/model/ContainerTest.java b/swift-model/src/test/java/com/woorea/openstack/swift/model/ContainerTest.java index 41d7f6e..d75d4ea 100644 --- a/swift-model/src/test/java/com/woorea/openstack/swift/model/ContainerTest.java +++ b/swift-model/src/test/java/com/woorea/openstack/swift/model/ContainerTest.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,17 +33,12 @@ public class ContainerTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"name\" : \"name\"," + EOL - + " \"count\" : 2," + EOL - + " \"bytes\" : 84" + EOL - + "}"; + private static final String JSON_FULL = + "{" + EOL + " \"name\" : \"name\"," + EOL + " \"count\" : 2," + EOL + " \"bytes\" : 84" + 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 { @@ -60,15 +54,15 @@ public class ContainerTest { public void testMethods() throws Exception { Container container = objectMapper.readValue(JSON_FULL, Container.class); container.toString(); - + Long bytesUsed = container.getBytesUsed(); Assert.assertNotNull(bytesUsed); container.setBytesUsed(bytesUsed); - + Integer objectCount = container.getObjectCount(); Assert.assertNotNull(objectCount); container.setObjectCount(objectCount); - + String name = container.getName(); Assert.assertNotNull(name); container.setName(name); diff --git a/swift-model/src/test/java/com/woorea/openstack/swift/model/ObjectTest.java b/swift-model/src/test/java/com/woorea/openstack/swift/model/ObjectTest.java index 28d909a..b3a72ca 100644 --- a/swift-model/src/test/java/com/woorea/openstack/swift/model/ObjectTest.java +++ b/swift-model/src/test/java/com/woorea/openstack/swift/model/ObjectTest.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.Calendar; - import org.junit.Assert; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -36,20 +34,13 @@ public class ObjectTest { private static final String EOL = System.lineSeparator(); - private static final String JSON_FULL = "{" + EOL - + " \"subdir\" : \"subdir\"," + EOL - + " \"name\" : \"name\"," + EOL - + " \"hash\" : \"hash\"," + EOL - + " \"bytes\" : 82," + EOL - + " \"content_type\" : \"contenttype\"," + EOL - + " \"last_modified\" : 1488715200000" + EOL - + "}"; + private static final String JSON_FULL = "{" + EOL + " \"subdir\" : \"subdir\"," + EOL + " \"name\" : \"name\"," + + EOL + " \"hash\" : \"hash\"," + EOL + " \"bytes\" : 82," + EOL + " \"content_type\" : \"contenttype\"," + + EOL + " \"last_modified\" : 1488715200000" + 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 { @@ -63,29 +54,30 @@ public class ObjectTest { @Test public void testMethods() throws Exception { - com.woorea.openstack.swift.model.Object object = objectMapper.readValue(JSON_FULL, com.woorea.openstack.swift.model.Object.class); + com.woorea.openstack.swift.model.Object object = + objectMapper.readValue(JSON_FULL, com.woorea.openstack.swift.model.Object.class); object.toString(); - + String subdir = object.getSubdir(); Assert.assertNotNull(subdir); object.setSubdir(subdir); - + Calendar lastModified = object.getLastModified(); Assert.assertNotNull(lastModified); object.setLastModified(lastModified); - + int bytes = object.getBytes(); Assert.assertNotNull(bytes); object.setBytes(bytes); - + String name = object.getName(); Assert.assertNotNull(name); object.setName(name); - + String hash = object.getHash(); Assert.assertNotNull(hash); object.setHash(hash); - + String contentType = object.getContentType(); Assert.assertNotNull(contentType); object.setContentType(contentType); -- cgit 1.2.3-korg