Functional so/libs unit tests 11/65611/2
authorRob Daugherty <rd472p@att.com>
Mon, 10 Sep 2018 21:45:52 +0000 (17:45 -0400)
committerRob Daugherty <rd472p@att.com>
Mon, 10 Sep 2018 21:53:28 +0000 (17:53 -0400)
Unit tests to prepare for migration from the codehaus to the fasterxml
implementation of jackson.

Iincreases the code coverage metric from 51% to 70%.

Change-Id: I6338214f3de9df95956b46d4e313d00052eb8692
Issue-ID: SO-1011
Signed-off-by: Rob Daugherty <rd472p@att.com>
183 files changed:
.gitignore
ceilometer-model/pom.xml
ceilometer-model/src/test/java/com/woorea/openstack/ceilometer/v2/model/MeterTest.java
ceilometer-model/src/test/java/com/woorea/openstack/ceilometer/v2/model/ResourceTest.java
ceilometer-model/src/test/java/com/woorea/openstack/ceilometer/v2/model/SampleTest.java
ceilometer-model/src/test/java/com/woorea/openstack/ceilometer/v2/model/StatisticsTest.java
glance-model/pom.xml
glance-model/src/test/java/com/woorea/openstack/glance/model/ImageMemberTest.java
glance-model/src/test/java/com/woorea/openstack/glance/model/ImageMembersTest.java
glance-model/src/test/java/com/woorea/openstack/glance/model/ImageTest.java
glance-model/src/test/java/com/woorea/openstack/glance/model/ImagesTest.java
glance-model/src/test/java/com/woorea/openstack/glance/model/SharedImageTest.java [new file with mode: 0644]
glance-model/src/test/java/com/woorea/openstack/glance/model/SharedImagesTest.java
heat-model/pom.xml
heat-model/src/test/java/com/woorea/openstack/heat/model/CreateStackParamTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/ErrorTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/ExplanationTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/LinkTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/OutputTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/ResourceTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/ResourcesTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/StackTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/StacksTest.java [new file with mode: 0644]
heat-model/src/test/java/com/woorea/openstack/heat/model/UpdateStackParamTest.java [new file with mode: 0644]
keystone-model/pom.xml
keystone-model/src/test/java/com/woorea/openstack/keystone/model/AccessTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/EndpointTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/EndpointsTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/ErrorTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/LinkTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/RoleTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/RolesTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/ServiceTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/ServicesTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/TenantTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/TenantsTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/TokenTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/UserTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/UsersTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/AccessKeyTest.java [new file with mode: 0644]
keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/ApiAccessKeyCredentialsTest.java [new file with mode: 0644]
keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/PasswordCredentialsTest.java [new file with mode: 0644]
keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/TokenTest.java [new file with mode: 0644]
keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/UsernamePasswordTest.java [new file with mode: 0644]
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/AuthenticationTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/CredentialTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/CredentialsTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/DomainTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/DomainsTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/EndpointTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/EndpointsTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/GroupTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/GroupsTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/IdentityTest.java [new file with mode: 0644]
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/PasswordTest.java [new file with mode: 0644]
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/PoliciesTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/PolicyTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/ProjectTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/ProjectsTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/RoleTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/RolesTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/ScopeTest.java [new file with mode: 0644]
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/ServiceTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/ServicesTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/TokenTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/UserTest.java
keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/UsersTest.java
nova-model/pom.xml
nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupRuleForCreate.java
nova-model/src/test/java/com/woorea/openstack/nova/model/AbsoluteLimitTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/AddressTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/AddressesTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/AssociateFloatingIpTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/CertificateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/ChangePasswordTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/CloudpipeTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/CloudpipesTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/ConfirmResizeTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ConsoleOutputTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/CreateBackupTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/CreateImageTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/DisassociateFloatingIpTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ExtensionTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/ExtensionsTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/FaultTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/FlavorForCreateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/FlavorTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/FlavorsTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpDomainTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpDomainsTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpPoolTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpPoolsTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpsTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ForceDeleteTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/GetConsoleOutputTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/GetVncConsoleTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/GroupTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/HostAggregateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/HostAggregatesTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/HostTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/HostsTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ImageFromVolumeTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/ImageTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/ImagesTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/IpRangeTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/KeyPairTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/KeyPairWrapperTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/KeyPairsTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/LimitEntryTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/LimitsTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/LinkTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/LockTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/NetworkForCreateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/NetworkTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/NetworksTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/PauseTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/PersonalityFileTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/QuotaSetTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/RateLimitTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/RebootTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/RebuildTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/RescueResponseTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/RescueTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ResizeTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ResourceTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ResourceWrapperTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/RestoreTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ResumeTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/RevertResizeTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/RuleTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/SecurityGroupForCreateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/SecurityGroupRuleForCreateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/SecurityGroupTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/SecurityGroupsTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/ServerForCreateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/ServerTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/ServerUsageTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/ServersTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/SimpleTenantUsageTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/SimpleTenantUsagesTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/SnapshotForCreateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/SnapshotTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/SnapshotsTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/StartTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/StopTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/SuspendTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/UnlockTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/UnpauseTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/UnrescueTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/VncConsoleTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeAttachmentTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeAttachmentsTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeForCreateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeForImageCreateTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeTypeTest.java [new file with mode: 0644]
nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeTypesTest.java
nova-model/src/test/java/com/woorea/openstack/nova/model/VolumesTest.java
pom.xml
quantum-model/pom.xml
quantum-model/src/test/java/com/woorea/openstack/quantum/model/BindingTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/GatewayInfoTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/HostRouteTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/IpTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/IpVersionTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworkTest.java
quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworksTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/NeutronErrorTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/PoolTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortTest.java
quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortsTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForAddInterfaceTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForCreateTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterInterfaceTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/RoutersTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/SegmentTest.java [new file with mode: 0644]
quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java
quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetsTest.java [new file with mode: 0644]
swift-model/pom.xml
swift-model/src/test/java/com/woorea/openstack/swift/model/ContainerTest.java [new file with mode: 0644]
swift-model/src/test/java/com/woorea/openstack/swift/model/ObjectTest.java [new file with mode: 0644]

index 0aab431..d1ca419 100644 (file)
@@ -3,6 +3,7 @@ target
 .classpath
 .project
 .buildpath
+.checkstyle
 .idea
 *.iml
 
index b6f2a8f..a86b621 100644 (file)
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.skyscreamer</groupId>
+            <artifactId>jsonassert</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
index e8ac582..97bb2af 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.ceilometer.v2.model;
 
+import com.woorea.openstack.ceilometer.v2.model.Meter;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class MeterTest {
 
-    Meter meter = new Meter();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getUserTest() throws Exception {
-        meter.getUser();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"name\" : \"name\"," + EOL
+        + "  \"type\" : \"type\"," + EOL
+        + "  \"unit\" : \"unit\"," + EOL
+        + "  \"user_id\" : \"user\"," + EOL
+        + "  \"resource_id\" : \"resource\"," + EOL
+        + "  \"project_id\" : \"project\"" + EOL
+        + "}";
 
-    @Test
-    public void getNameTest() throws Exception {
-        meter.getName();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getResource() throws Exception {
-        meter.getResource();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Meter.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Meter meter = objectMapper.readValue(JSON_FULL, Meter.class);
+        String json = objectMapper.writeValueAsString(meter);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getProjectTest() throws Exception {
-        meter.getProject();
+    public void testMethods() throws Exception {
+        Meter meter = objectMapper.readValue(JSON_FULL, Meter.class);
+        meter.toString();
+        
+        String unit = meter.getUnit();
+        Assert.assertNotNull(unit);
+        
+        String resource = meter.getResource();
+        Assert.assertNotNull(resource);
+        
+        String name = meter.getName();
+        Assert.assertNotNull(name);
+        
+        String project = meter.getProject();
+        Assert.assertNotNull(project);
+        
+        String type = meter.getType();
+        Assert.assertNotNull(type);
+        
+        String user = meter.getUser();
+        Assert.assertNotNull(user);
     }
-
-    @Test
-    public void getTypeTest() throws Exception {
-        meter.getType();
-    }
-
-    @Test
-    public void getUnitTest() throws Exception {
-        meter.getUnit();
-    }
-
-}
\ No newline at end of file
+}
index 13a75df..10b361e 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.ceilometer.v2.model;
 
+import com.woorea.openstack.ceilometer.v2.model.Resource;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ResourceTest {
 
-    Resource resource = new Resource();
-
-    @Test
-    public void getResourceTest() throws Exception {
-        resource.getResource();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getTimestampTest() throws Exception {
-        resource.getTimestamp();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"timestamp\" : \"timestamp\"," + EOL
+        + "  \"metadata\" : {" + EOL
+        + "    \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "    \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "  }," + EOL
+        + "  \"resource_id\" : \"resource\"," + EOL
+        + "  \"project_id\" : \"project\"," + EOL
+        + "  \"user_id\" : \"user\"" + EOL
+        + "}";
 
-    @Test
-    public void getProjectTest() throws Exception {
-        resource.getProject();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getUserTest() throws Exception {
-        resource.getUser();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Resource.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Resource resource = objectMapper.readValue(JSON_FULL, Resource.class);
+        String json = objectMapper.writeValueAsString(resource);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getMetadataTest() throws Exception {
-        resource.getMetadata();
+    public void testMethods() throws Exception {
+        Resource resource = objectMapper.readValue(JSON_FULL, Resource.class);
+        resource.toString();
+        
+        Map<String,Object> metadata = resource.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        
+        String resourceProperty = resource.getResource();
+        Assert.assertNotNull(resourceProperty);
+        
+        String project = resource.getProject();
+        Assert.assertNotNull(project);
+        
+        String user = resource.getUser();
+        Assert.assertNotNull(user);
+        
+        String timestamp = resource.getTimestamp();
+        Assert.assertNotNull(timestamp);
     }
-
-}
\ No newline at end of file
+}
index ed89c3b..fa8325e 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.ceilometer.v2.model;
 
+import com.woorea.openstack.ceilometer.v2.model.Sample;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SampleTest {
 
-    Sample sample = new Sample();
-
-    @Test
-    public void getCounterTypeTest() throws Exception {
-        sample.getCounterType();
-    }
-
-    @Test
-    public void getCounterNameTest() throws Exception {
-        sample.getCounterName();
-    }
-
-    @Test
-    public void getCounterUnitTest() throws Exception {
-        sample.getCounterUnit();
-    }
-
-    @Test
-    public void getCounterVolumeTest() throws Exception {
-        sample.getCounterVolume();
-    }
-
-    @Test
-    public void getSourceTest() throws Exception {
-        sample.getSource();
-    }
-
-    @Test
-    public void getProjectTest() throws Exception {
-        sample.getProject();
-    }
-
-    @Test
-    public void getUserTest() throws Exception {
-        sample.getUser();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getResourceTest() throws Exception {
-        sample.getResource();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"source\" : \"source\"," + EOL
+        + "  \"timestamp\" : \"timestamp\"," + EOL
+        + "  \"counter_type\" : \"countertype\"," + EOL
+        + "  \"counter_name\" : \"countername\"," + EOL
+        + "  \"counter_unit\" : \"counterunit\"," + EOL
+        + "  \"counter_volume\" : \"countervolume\"," + EOL
+        + "  \"project_id\" : \"project\"," + EOL
+        + "  \"user_id\" : \"user\"," + EOL
+        + "  \"resource_id\" : \"resource\"," + EOL
+        + "  \"message_id\" : \"message\"," + EOL
+        + "  \"resource_metadata\" : {" + EOL
+        + "    \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "    \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getTimestampTest() throws Exception {
-        sample.getTimestamp();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getMessageTest() throws Exception {
-        sample.getMessage();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Sample.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Sample sample = objectMapper.readValue(JSON_FULL, Sample.class);
+        String json = objectMapper.writeValueAsString(sample);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getMetadataTest() throws Exception {
-        sample.getMetadata();
+    public void testMethods() throws Exception {
+        Sample sample = objectMapper.readValue(JSON_FULL, Sample.class);
+        sample.toString();
+        
+        String counterName = sample.getCounterName();
+        Assert.assertNotNull(counterName);
+        
+        Map<String,Object> metadata = sample.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        
+        String resource = sample.getResource();
+        Assert.assertNotNull(resource);
+        
+        String counterVolume = sample.getCounterVolume();
+        Assert.assertNotNull(counterVolume);
+        
+        String project = sample.getProject();
+        Assert.assertNotNull(project);
+        
+        String counterUnit = sample.getCounterUnit();
+        Assert.assertNotNull(counterUnit);
+        
+        String source = sample.getSource();
+        Assert.assertNotNull(source);
+        
+        String counterType = sample.getCounterType();
+        Assert.assertNotNull(counterType);
+        
+        String message = sample.getMessage();
+        Assert.assertNotNull(message);
+        
+        String user = sample.getUser();
+        Assert.assertNotNull(user);
+        
+        String timestamp = sample.getTimestamp();
+        Assert.assertNotNull(timestamp);
     }
-
-}
\ No newline at end of file
+}
index a911bbb..d3e7597 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.ceilometer.v2.model;
 
+import com.woorea.openstack.ceilometer.v2.model.Statistics;
+import java.math.BigDecimal;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class StatisticsTest {
 
-    Statistics statistics = new Statistics();
-
-    @Test
-    public void getAvgTest() throws Exception {
-        statistics.getAvg();
-    }
-
-    @Test
-    public void getCountTest() throws Exception {
-        statistics.getCount();
-    }
-
-    @Test
-    public void getDurationTest() throws Exception {
-        statistics.getDuration();
-    }
-
-    @Test
-    public void getDurationStartTest() throws Exception {
-        statistics.getDurationStart();
-    }
-
-    @Test
-    public void getDurationEndTest() throws Exception {
-        statistics.getDurationEnd();
-    }
-
-    @Test
-    public void getMaxTest() throws Exception {
-        statistics.getMax();
-    }
-
-    @Test
-    public void getMinTest() throws Exception {
-        statistics.getMin();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getPeriodTest() throws Exception {
-        statistics.getPeriod();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"avg\" : 79," + EOL
+        + "  \"count\" : 14," + EOL
+        + "  \"duration\" : 31," + EOL
+        + "  \"max\" : 87," + EOL
+        + "  \"min\" : 85," + EOL
+        + "  \"period\" : 4," + EOL
+        + "  \"sum\" : 2," + EOL
+        + "  \"duration_start\" : \"durationstart\"," + EOL
+        + "  \"duration_end\" : \"durationend\"," + EOL
+        + "  \"period_start\" : \"periodstart\"," + EOL
+        + "  \"period_end\" : \"periodend\"" + EOL
+        + "}";
 
-    @Test
-    public void getPeriodStartTest() throws Exception {
-        statistics.getPeriodStart();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getPeriodEndTest() throws Exception {
-        statistics.getPeriodEnd();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Statistics.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Statistics statistics = objectMapper.readValue(JSON_FULL, Statistics.class);
+        String json = objectMapper.writeValueAsString(statistics);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getSumTest() throws Exception {
-        statistics.getSum();
+    public void testMethods() throws Exception {
+        Statistics statistics = objectMapper.readValue(JSON_FULL, Statistics.class);
+        statistics.toString();
+        
+        BigDecimal duration = statistics.getDuration();
+        Assert.assertNotNull(duration);
+        
+        BigDecimal period = statistics.getPeriod();
+        Assert.assertNotNull(period);
+        
+        BigDecimal avg = statistics.getAvg();
+        Assert.assertNotNull(avg);
+        
+        BigDecimal min = statistics.getMin();
+        Assert.assertNotNull(min);
+        
+        String durationStart = statistics.getDurationStart();
+        Assert.assertNotNull(durationStart);
+        
+        BigDecimal max = statistics.getMax();
+        Assert.assertNotNull(max);
+        
+        String durationEnd = statistics.getDurationEnd();
+        Assert.assertNotNull(durationEnd);
+        
+        BigDecimal count = statistics.getCount();
+        Assert.assertNotNull(count);
+        
+        BigDecimal sum = statistics.getSum();
+        Assert.assertNotNull(sum);
+        
+        String periodStart = statistics.getPeriodStart();
+        Assert.assertNotNull(periodStart);
+        
+        String periodEnd = statistics.getPeriodEnd();
+        Assert.assertNotNull(periodEnd);
     }
-
-}
\ No newline at end of file
+}
index fe104d7..71b224e 100644 (file)
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.skyscreamer</groupId>
+            <artifactId>jsonassert</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
index bcf5f77..155aac0 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.glance.model;
 
+import com.woorea.openstack.glance.model.ImageMember;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ImageMemberTest {
 
-    ImageMember imageMember = new ImageMember();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void isCanShareTest() throws Exception {
-        imageMember.isCanShare();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"can_share\" : false," + EOL
+        + "  \"member_id\" : \"memberid\"" + EOL
+        + "}";
 
-    @Test
-    public void setCanShareTest() throws Exception {
-        imageMember.setCanShare(true);
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getMemberIdTest() throws Exception {
-        imageMember.getMemberId();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ImageMember.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ImageMember imagemember = objectMapper.readValue(JSON_FULL, ImageMember.class);
+        String json = objectMapper.writeValueAsString(imagemember);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setMemberIdTest() throws Exception {
-        imageMember.setMemberId("id");
+    public void testMethods() throws Exception {
+        ImageMember imagemember = objectMapper.readValue(JSON_FULL, ImageMember.class);
+        imagemember.toString();
+        
+        String memberId = imagemember.getMemberId();
+        Assert.assertNotNull(memberId);
+        imagemember.setMemberId(memberId);
     }
-
-}
\ No newline at end of file
+}
index 410cea9..0b9e94c 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.glance.model;
 
+import com.woorea.openstack.glance.model.ImageMember;
+import com.woorea.openstack.glance.model.ImageMembers;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ImageMembersTest {
 
-    ImageMembers imageMembers = new ImageMembers();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"members\" : [ {" + EOL
+        + "    \"can_share\" : false," + EOL
+        + "    \"member_id\" : \"memberid\"" + EOL
+        + "  }, {" + EOL
+        + "    \"can_share\" : false," + EOL
+        + "    \"member_id\" : \"memberid\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getListTest() throws Exception {
-        imageMembers.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ImageMembers.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ImageMembers imagemembers = objectMapper.readValue(JSON_FULL, ImageMembers.class);
+        String json = objectMapper.writeValueAsString(imagemembers);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-}
\ No newline at end of file
+    @Test
+    public void testMethods() throws Exception {
+        ImageMembers imagemembers = objectMapper.readValue(JSON_FULL, ImageMembers.class);
+        imagemembers.toString();
+        
+        List<ImageMember> list = imagemembers.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") ImageMember x : imagemembers) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
index b47bdd7..4e54413 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.glance.model;
 
+import com.woorea.openstack.glance.model.Image;
+import java.util.Calendar;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import java.util.GregorianCalendar;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ImageTest {
 
-    Image image = new Image();
-
-    @Test
-    public void getIdTest() throws Exception {
-        image.getId();
-    }
-
-    @Test
-    public void setIdTest() throws Exception {
-        image.setId("uuid");
-    }
-
-    @Test
-    public void getUriTest() throws Exception {
-        image.getUri();
-    }
-
-    @Test
-    public void setUriTest() throws Exception {
-        image.setUri("uri");
-    }
-
-    @Test
-    public void getNameTest() throws Exception {
-        image.getName();
-    }
-
-    @Test
-    public void setNameTest() throws Exception {
-        image.setName("image-123");
-    }
-
-    @Test
-    public void getDiskFormatTest() throws Exception {
-        image.getDiskFormat();
-    }
-
-    @Test
-    public void setDiskFormatTest() throws Exception {
-        image.setDiskFormat("disk-format");
-    }
-
-    @Test
-    public void getContainerFormatTest() throws Exception {
-        image.getContainerFormat();
-    }
-
-    @Test
-    public void setContainerFormatTest() throws Exception {
-        image.setContainerFormat("format");
-    }
-
-    @Test
-    public void getSizeTest() throws Exception {
-        image.getSize();
-    }
-
-    @Test
-    public void setSizeTest() throws Exception {
-        image.setSize(12345L);
-    }
-
-    @Test
-    public void getVirtualSizeTest() throws Exception {
-        image.getVirtualSize();
-    }
-
-    @Test
-    public void setVirtualSizeTest() throws Exception {
-        image.setVirtualSize(1234L);
-    }
-
-    @Test
-    public void getChecksumTest() throws Exception {
-        image.getChecksum();
-    }
-
-    @Test
-    public void setChecksumTest() throws Exception {
-        image.setChecksum("ABC");
-    }
-
-    @Test
-    public void getCreatedAtTest() throws Exception {
-        image.getCreatedAt();
-    }
-
-    @Test
-    public void setCreatedAtTest() throws Exception {
-        image.setCreatedAt(new GregorianCalendar());
-    }
-
-    @Test
-    public void getUpdatedAtTest() throws Exception {
-        image.getUpdatedAt();
-    }
-
-    @Test
-    public void setUpdatedAt() throws Exception {
-        image.setUpdatedAt(new GregorianCalendar());
-    }
-
-    @Test
-    public void getDeletedAtTest() throws Exception {
-        image.getDeletedAt();
-    }
-
-    @Test
-    public void setDeletedAtTest() throws Exception {
-        image.setDeletedAt(new GregorianCalendar());
-    }
-
-    @Test
-    public void getStatus() throws Exception {
-        image.getStatus();
-    }
-
-    @Test
-    public void setStatusTest() throws Exception {
-        image.setStatus("status");
-    }
-
-    @Test
-    public void isPublicTest() throws Exception {
-        image.isPublic();
-    }
-
-    @Test
-    public void setPublicTest() throws Exception {
-        image.setPublic(true);
-    }
-
-    @Test
-    public void getMinRamTest() throws Exception {
-        image.getMinRam();
-    }
-
-    @Test
-    public void setMinRamTest() throws Exception {
-        image.setMinRam(256);
-    }
-
-    @Test
-    public void getMinDiskTest() throws Exception {
-        image.getMinDisk();
-    }
-
-    @Test
-    public void setMinDiskTest() throws Exception {
-        image.setMinDisk(8);
-    }
-
-    @Test
-    public void getOwnerTest() throws Exception {
-        image.getOwner();
-    }
-
-    @Test
-    public void setOwnerTest() throws Exception {
-        image.setOwner("onap");
-    }
-
-    @Test
-    public void isDeletedTest() throws Exception {
-        image.isDeleted();
-    }
-
-    @Test
-    public void setDeletedTest() throws Exception {
-        image.setDeleted(true);
-    }
-
-    @Test
-    public void isProtectedTest() throws Exception {
-        image.isProtected();
-    }
-
-    @Test
-    public void setProtectedTest() throws Exception {
-        image.setProtected(true);
-    }
-
-    @Test
-    public void getPropertiesTest() throws Exception {
-        image.getProperties();
-    }
-
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"image\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"uri\" : \"uri\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"size\" : 43," + EOL
+        + "    \"checksum\" : \"checksum\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"owner\" : \"owner\"," + EOL
+        + "    \"properties\" : {" + EOL
+        + "      \"properties-k1\" : \"properties-v1\"," + EOL
+        + "      \"properties-k2\" : \"properties-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"public\" : false," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"protected\" : true," + EOL
+        + "    \"disk_format\" : \"diskformat\"," + EOL
+        + "    \"container_format\" : \"containerformat\"," + EOL
+        + "    \"virtual_size\" : 18," + EOL
+        + "    \"created_at\" : 1486296000000," + EOL
+        + "    \"updated_at\" : 1487592000000," + EOL
+        + "    \"deleted_at\" : 1486209600000," + EOL
+        + "    \"is_public\" : false," + EOL
+        + "    \"min_ram\" : 62," + EOL
+        + "    \"min_disk\" : 69" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Image.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Image image = objectMapper.readValue(JSON_FULL, Image.class);
+        String json = objectMapper.writeValueAsString(image);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Image image = objectMapper.readValue(JSON_FULL, Image.class);
+        image.toString();
+        
+        String owner = image.getOwner();
+        Assert.assertNotNull(owner);
+        image.setOwner(owner);
+        
+        String containerFormat = image.getContainerFormat();
+        Assert.assertNotNull(containerFormat);
+        image.setContainerFormat(containerFormat);
+        
+        String uri = image.getUri();
+        Assert.assertNotNull(uri);
+        image.setUri(uri);
+        
+        Calendar createdAt = image.getCreatedAt();
+        Assert.assertNotNull(createdAt);
+        image.setCreatedAt(createdAt);
+        
+        Calendar deletedAt = image.getDeletedAt();
+        Assert.assertNotNull(deletedAt);
+        image.setDeletedAt(deletedAt);
+        
+        Long size = image.getSize();
+        Assert.assertNotNull(size);
+        image.setSize(size);
+        
+        Integer minRam = image.getMinRam();
+        Assert.assertNotNull(minRam);
+        image.setMinRam(minRam);
+        
+        String diskFormat = image.getDiskFormat();
+        Assert.assertNotNull(diskFormat);
+        image.setDiskFormat(diskFormat);
+        
+        String checksum = image.getChecksum();
+        Assert.assertNotNull(checksum);
+        image.setChecksum(checksum);
+        
+        String name = image.getName();
+        Assert.assertNotNull(name);
+        image.setName(name);
+        
+        String id = image.getId();
+        Assert.assertNotNull(id);
+        image.setId(id);
+        
+        Long virtualSize = image.getVirtualSize();
+        Assert.assertNotNull(virtualSize);
+        image.setVirtualSize(virtualSize);
+        
+        Map<String,Object> properties = image.getProperties();
+        Assert.assertNotNull(properties);
+        Assert.assertEquals(2, properties.size());
+        
+        Integer minDisk = image.getMinDisk();
+        Assert.assertNotNull(minDisk);
+        image.setMinDisk(minDisk);
+        
+        String status = image.getStatus();
+        Assert.assertNotNull(status);
+        image.setStatus(status);
+        
+        Calendar updatedAt = image.getUpdatedAt();
+        Assert.assertNotNull(updatedAt);
+        image.setUpdatedAt(updatedAt);
+    }
+}
index 1dc02be..913fa01 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.glance.model;
 
+import com.woorea.openstack.glance.model.Image;
+import com.woorea.openstack.glance.model.Images;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ImagesTest {
 
-    Images images = new Images();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"images\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"uri\" : \"uri\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"size\" : 43," + EOL
+        + "    \"checksum\" : \"checksum\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"owner\" : \"owner\"," + EOL
+        + "    \"properties\" : {" + EOL
+        + "      \"properties-k1\" : \"properties-v1\"," + EOL
+        + "      \"properties-k2\" : \"properties-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"public\" : false," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"protected\" : true," + EOL
+        + "    \"disk_format\" : \"diskformat\"," + EOL
+        + "    \"container_format\" : \"containerformat\"," + EOL
+        + "    \"virtual_size\" : 18," + EOL
+        + "    \"created_at\" : 1486296000000," + EOL
+        + "    \"updated_at\" : 1487592000000," + EOL
+        + "    \"deleted_at\" : 1486209600000," + EOL
+        + "    \"is_public\" : false," + EOL
+        + "    \"min_ram\" : 62," + EOL
+        + "    \"min_disk\" : 69" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"uri\" : \"uri\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"size\" : 43," + EOL
+        + "    \"checksum\" : \"checksum\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"owner\" : \"owner\"," + EOL
+        + "    \"properties\" : {" + EOL
+        + "      \"properties-k1\" : \"properties-v1\"," + EOL
+        + "      \"properties-k2\" : \"properties-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"public\" : false," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"protected\" : true," + EOL
+        + "    \"disk_format\" : \"diskformat\"," + EOL
+        + "    \"container_format\" : \"containerformat\"," + EOL
+        + "    \"virtual_size\" : 18," + EOL
+        + "    \"created_at\" : 1486296000000," + EOL
+        + "    \"updated_at\" : 1487592000000," + EOL
+        + "    \"deleted_at\" : 1486209600000," + EOL
+        + "    \"is_public\" : false," + EOL
+        + "    \"min_ram\" : 62," + EOL
+        + "    \"min_disk\" : 69" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
     @Test
-    public void getListTest() throws Exception {
-        images.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Images.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Images images = objectMapper.readValue(JSON_FULL, Images.class);
+        String json = objectMapper.writeValueAsString(images);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-}
\ No newline at end of file
+    @Test
+    public void testMethods() throws Exception {
+        Images images = objectMapper.readValue(JSON_FULL, Images.class);
+        images.toString();
+        
+        List<Image> list = images.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Image x : images) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/glance-model/src/test/java/com/woorea/openstack/glance/model/SharedImageTest.java b/glance-model/src/test/java/com/woorea/openstack/glance/model/SharedImageTest.java
new file mode 100644 (file)
index 0000000..f1348ee
--- /dev/null
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.glance.model;
+
+import com.woorea.openstack.glance.model.SharedImage;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class SharedImageTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{ }";
+
+    // FAIL_ON_EMPTY_BEANS set to false to conform to legacy behavior
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SharedImage.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SharedImage sharedimage = objectMapper.readValue(JSON_FULL, SharedImage.class);
+        String json = objectMapper.writeValueAsString(sharedimage);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        SharedImage sharedimage = objectMapper.readValue(JSON_FULL, SharedImage.class);
+        sharedimage.toString();
+    }
+}
index 9198300..f888fb2 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.glance.model;
 
+import com.woorea.openstack.glance.model.SharedImage;
+import com.woorea.openstack.glance.model.SharedImages;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SharedImagesTest {
 
-    SharedImages sharedImages = new SharedImages();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"shared_images\" : [ { }, { } ]" + EOL
+        + "}";
+
+    // FAIL_ON_EMPTY_BEANS set to false to conform to legacy behavior
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        sharedImages.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SharedImages.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SharedImages sharedimages = objectMapper.readValue(JSON_FULL, SharedImages.class);
+        String json = objectMapper.writeValueAsString(sharedimages);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-}
\ No newline at end of file
+    @Test
+    public void testMethods() throws Exception {
+        SharedImages sharedimages = objectMapper.readValue(JSON_FULL, SharedImages.class);
+        sharedimages.toString();
+        
+        List<SharedImage> list = sharedimages.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") SharedImage x : sharedimages) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
index e33b807..47a5a55 100644 (file)
@@ -1,14 +1,18 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
-    <dependencies>
+       <dependencies>
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
-                       <version>4.12</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.skyscreamer</groupId>
+                       <artifactId>jsonassert</artifactId>
                        <scope>test</scope>
                </dependency>
        </dependencies>
-    <parent>
+       <parent>
                <groupId>org.onap.so.libs</groupId>
                <artifactId>openstack-java-sdk</artifactId>
                <version>1.2.1-SNAPSHOT</version>
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
new file mode 100644 (file)
index 0000000..f181175
--- /dev/null
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.CreateStackParam;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + CreateStackParam.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        CreateStackParam createstackparam = objectMapper.readValue(JSON_FULL, CreateStackParam.class);
+        String json = objectMapper.writeValueAsString(createstackparam);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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();
+        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();
+        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
new file mode 100644 (file)
index 0000000..76582e7
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.Explanation.Error;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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 ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Error.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Error error = objectMapper.readValue(JSON_FULL, Error.class);
+        String json = objectMapper.writeValueAsString(error);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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
new file mode 100644 (file)
index 0000000..4132cb0
--- /dev/null
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.Explanation;
+import com.woorea.openstack.heat.model.Explanation.Error;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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 ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Explanation.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Explanation explanation = objectMapper.readValue(JSON_FULL, Explanation.class);
+        String json = objectMapper.writeValueAsString(explanation);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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
new file mode 100644 (file)
index 0000000..503e0e5
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.Link;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class LinkTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"href\" : \"href\"," + EOL
+        + "  \"rel\" : \"rel\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Link.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Link link = objectMapper.readValue(JSON_FULL, Link.class);
+        String json = objectMapper.writeValueAsString(link);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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
new file mode 100644 (file)
index 0000000..cc07012
--- /dev/null
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.Stack.Output;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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 ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Output.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Output output = objectMapper.readValue(JSON_FULL, Output.class);
+        String json = objectMapper.writeValueAsString(output);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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
new file mode 100644 (file)
index 0000000..ff7497e
--- /dev/null
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.Link;
+import com.woorea.openstack.heat.model.Resource;
+import java.util.Date;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Resource.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Resource resource = objectMapper.readValue(JSON_FULL, Resource.class);
+        String json = objectMapper.writeValueAsString(resource);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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
new file mode 100644 (file)
index 0000000..0093ab3
--- /dev/null
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.Resource;
+import com.woorea.openstack.heat.model.Resources;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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 ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Resources.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Resources resources = objectMapper.readValue(JSON_FULL, Resources.class);
+        String json = objectMapper.writeValueAsString(resources);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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) {
+            ++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
new file mode 100644 (file)
index 0000000..8659895
--- /dev/null
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.Link;
+import com.woorea.openstack.heat.model.Stack;
+import com.woorea.openstack.heat.model.Stack.Output;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Stack.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Stack stack = objectMapper.readValue(JSON_FULL, Stack.class);
+        String json = objectMapper.writeValueAsString(stack);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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();
+        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();
+        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
new file mode 100644 (file)
index 0000000..884d5a9
--- /dev/null
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.Stack;
+import com.woorea.openstack.heat.model.Stacks;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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 ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Stacks.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Stacks stacks = objectMapper.readValue(JSON_FULL, Stacks.class);
+        String json = objectMapper.writeValueAsString(stacks);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Stacks stacks = objectMapper.readValue(JSON_FULL, Stacks.class);
+        stacks.toString();
+        
+        int cnt = 0;
+        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
new file mode 100644 (file)
index 0000000..5bff417
--- /dev/null
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.heat.model;
+
+import com.woorea.openstack.heat.model.UpdateStackParam;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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 ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + UpdateStackParam.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        UpdateStackParam updatestackparam = objectMapper.readValue(JSON_FULL, UpdateStackParam.class);
+        String json = objectMapper.writeValueAsString(updatestackparam);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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();
+        Assert.assertNotNull(files);
+        Assert.assertEquals(2, files.size());
+        updatestackparam.setFiles(files);
+        
+        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);
+    }
+}
index 0780cc2..406c79b 100644 (file)
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
-                       <version>4.12</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.skyscreamer</groupId>
+                       <artifactId>jsonassert</artifactId>
                        <scope>test</scope>
                </dependency>
        </dependencies>
index cd4e80f..c6c3ec5 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Access;
+import com.woorea.openstack.keystone.model.Access.Service;
+import com.woorea.openstack.keystone.model.Access.User;
+import com.woorea.openstack.keystone.model.Token;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class AccessTest {
 
-    Access access = new Access();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getTokenTest() throws Exception {
-        access.getToken();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"access\" : {" + EOL
+        + "    \"token\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"issued_at\" : 1488024000000," + EOL
+        + "      \"expires\" : 1488628800000," + EOL
+        + "      \"tenant\" : {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"description\" : \"description\"," + EOL
+        + "        \"enabled\" : false" + EOL
+        + "      }" + EOL
+        + "    }," + EOL
+        + "    \"serviceCatalog\" : [ {" + EOL
+        + "      \"type\" : \"type\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"endpoints\" : [ {" + EOL
+        + "        \"region\" : \"region\"," + EOL
+        + "        \"publicURL\" : \"publicurl\"," + EOL
+        + "        \"internalURL\" : \"internalurl\"," + EOL
+        + "        \"adminURL\" : \"adminurl\"" + EOL
+        + "      }, {" + EOL
+        + "        \"region\" : \"region\"," + EOL
+        + "        \"publicURL\" : \"publicurl\"," + EOL
+        + "        \"internalURL\" : \"internalurl\"," + EOL
+        + "        \"adminURL\" : \"adminurl\"" + EOL
+        + "      } ]," + EOL
+        + "      \"endpoints_links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]" + EOL
+        + "    }, {" + EOL
+        + "      \"type\" : \"type\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"endpoints\" : [ {" + EOL
+        + "        \"region\" : \"region\"," + EOL
+        + "        \"publicURL\" : \"publicurl\"," + EOL
+        + "        \"internalURL\" : \"internalurl\"," + EOL
+        + "        \"adminURL\" : \"adminurl\"" + EOL
+        + "      }, {" + EOL
+        + "        \"region\" : \"region\"," + EOL
+        + "        \"publicURL\" : \"publicurl\"," + EOL
+        + "        \"internalURL\" : \"internalurl\"," + EOL
+        + "        \"adminURL\" : \"adminurl\"" + EOL
+        + "      } ]," + EOL
+        + "      \"endpoints_links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]" + EOL
+        + "    } ]," + EOL
+        + "    \"user\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"username\" : \"username\"," + EOL
+        + "      \"roles\" : [ {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"" + EOL
+        + "      }, {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"" + EOL
+        + "      } ]," + EOL
+        + "      \"roles_links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]" + EOL
+        + "    }," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getServiceCatalogTest() throws Exception {
-        access.getServiceCatalog();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getUserTest() throws Exception {
-        access.getUser();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Access.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Access access = objectMapper.readValue(JSON_FULL, Access.class);
+        String json = objectMapper.writeValueAsString(access);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getMetadataTest() throws Exception {
-        access.getMetadata();
+    public void testMethods() throws Exception {
+        Access access = objectMapper.readValue(JSON_FULL, Access.class);
+        access.toString();
+        
+        List<Service> serviceCatalog = access.getServiceCatalog();
+        Assert.assertNotNull(serviceCatalog);
+        Assert.assertEquals(2, serviceCatalog.size());
+        
+        Map<String,Object> metadata = access.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        
+        User user = access.getUser();
+        Assert.assertNotNull(user);
+        
+        Token token = access.getToken();
+        Assert.assertNotNull(token);
     }
-
-}
\ No newline at end of file
+}
index b832da3..a379617 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Endpoint;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class EndpointTest {
 
-    Endpoint endpoint = new Endpoint();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"endpoint\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"region\" : \"region\"," + EOL
+        + "    \"service_id\" : \"serviceid\"," + EOL
+        + "    \"publicurl\" : \"publicurl\"," + EOL
+        + "    \"internalurl\" : \"internalurl\"," + EOL
+        + "    \"adminurl\" : \"adminurl\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getId() throws Exception {
-        endpoint.getId();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Endpoint.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Endpoint endpoint = objectMapper.readValue(JSON_FULL, Endpoint.class);
+        String json = objectMapper.writeValueAsString(endpoint);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setId() throws Exception {
-        endpoint.setId("test");
+    public void testMethods() throws Exception {
+        Endpoint endpoint = objectMapper.readValue(JSON_FULL, Endpoint.class);
+        endpoint.toString();
+        
+        String publicURL = endpoint.getPublicURL();
+        Assert.assertNotNull(publicURL);
+        endpoint.setPublicURL(publicURL);
+        
+        String internalURL = endpoint.getInternalURL();
+        Assert.assertNotNull(internalURL);
+        endpoint.setInternalURL(internalURL);
+        
+        String id = endpoint.getId();
+        Assert.assertNotNull(id);
+        endpoint.setId(id);
+        
+        String region = endpoint.getRegion();
+        Assert.assertNotNull(region);
+        endpoint.setRegion(region);
+        
+        String serviceId = endpoint.getServiceId();
+        Assert.assertNotNull(serviceId);
+        endpoint.setServiceId(serviceId);
+        
+        String adminURL = endpoint.getAdminURL();
+        Assert.assertNotNull(adminURL);
+        endpoint.setAdminURL(adminURL);
     }
-
-    @Test
-    public void getServiceId() throws Exception {
-        endpoint.getServiceId();
-    }
-
-    @Test
-    public void setServiceId() throws Exception {
-        endpoint.setServiceId("test");
-    }
-
-    @Test
-    public void getRegion() throws Exception {
-        endpoint.getRegion();
-    }
-
-    @Test
-    public void setRegion() throws Exception {
-        endpoint.setRegion("region");
-    }
-
-    @Test
-    public void getPublicURL() throws Exception {
-        endpoint.getPublicURL();
-    }
-
-    @Test
-    public void setPublicURL() throws Exception {
-        endpoint.setPublicURL("url");
-    }
-
-    @Test
-    public void getInternalURL() throws Exception {
-        endpoint.getInternalURL();
-    }
-
-    @Test
-    public void setInternalURL() throws Exception {
-        endpoint.setInternalURL("test");
-    }
-
-    @Test
-    public void getAdminURL() throws Exception {
-        endpoint.getAdminURL();
-    }
-
-    @Test
-    public void setAdminURL() throws Exception {
-        endpoint.setAdminURL("admin url");
-    }
-
-}
\ No newline at end of file
+}
index 8bc2870..a566f0f 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Endpoint;
+import com.woorea.openstack.keystone.model.Endpoints;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class EndpointsTest {
 
-    Endpoints endpoints = new Endpoints();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"endpoints\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"region\" : \"region\"," + EOL
+        + "    \"service_id\" : \"serviceid\"," + EOL
+        + "    \"publicurl\" : \"publicurl\"," + EOL
+        + "    \"internalurl\" : \"internalurl\"," + EOL
+        + "    \"adminurl\" : \"adminurl\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"region\" : \"region\"," + EOL
+        + "    \"service_id\" : \"serviceid\"," + EOL
+        + "    \"publicurl\" : \"publicurl\"," + EOL
+        + "    \"internalurl\" : \"internalurl\"," + EOL
+        + "    \"adminurl\" : \"adminurl\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        endpoints.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Endpoints.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Endpoints endpoints = objectMapper.readValue(JSON_FULL, Endpoints.class);
+        String json = objectMapper.writeValueAsString(endpoints);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        endpoints.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Endpoints endpoints = objectMapper.readValue(JSON_FULL, Endpoints.class);
+        endpoints.toString();
+        
+        List<Endpoint> list = endpoints.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Endpoint x : endpoints) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 33c0726..357f9c6 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Error;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ErrorTest {
 
-    Error error = new Error();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getCode() throws Exception {
-        error.getCode();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"error\" : {" + EOL
+        + "    \"code\" : 29," + EOL
+        + "    \"title\" : \"title\"," + EOL
+        + "    \"message\" : \"message\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getTitle() throws Exception {
-        error.getTitle();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Error.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Error error = objectMapper.readValue(JSON_FULL, Error.class);
+        String json = objectMapper.writeValueAsString(error);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getMessage() throws Exception {
-        error.getMessage();
+    public void testMethods() throws Exception {
+        Error error = objectMapper.readValue(JSON_FULL, Error.class);
+        error.toString();
+        
+        Integer code = error.getCode();
+        Assert.assertNotNull(code);
+        
+        String title = error.getTitle();
+        Assert.assertNotNull(title);
+        
+        String message = error.getMessage();
+        Assert.assertNotNull(message);
     }
-
-}
\ No newline at end of file
+}
index 521ad09..a7a20b9 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Link;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class LinkTest {
 
-    Link link = new Link();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getRel() throws Exception {
-        link.getRel();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"rel\" : \"rel\"," + EOL
+        + "  \"href\" : \"href\"," + EOL
+        + "  \"type\" : \"type\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getHref() throws Exception {
-        link.getHref();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Link.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Link link = objectMapper.readValue(JSON_FULL, Link.class);
+        String json = objectMapper.writeValueAsString(link);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getType() throws Exception {
-        link.getType();
+    public void testMethods() throws Exception {
+        Link link = objectMapper.readValue(JSON_FULL, Link.class);
+        link.toString();
+        
+        String rel = link.getRel();
+        Assert.assertNotNull(rel);
+        
+        String href = link.getHref();
+        Assert.assertNotNull(href);
+        
+        String type = link.getType();
+        Assert.assertNotNull(type);
     }
-
-}
\ No newline at end of file
+}
index 0f7f7f3..b93532c 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Role;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class RoleTest {
 
-    Role role = new Role();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() throws Exception {
-        role.getId();
-    }
-
-    @Test
-    public void getName() throws Exception {
-        role.getName();
-    }
-
-    @Test
-    public void setName() throws Exception {
-        role.setName("name");
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"role\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : \"enabled\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getDescription() throws Exception {
-        role.getDescription();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void setDescription() throws Exception {
-        role.setDescription("desc");
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Role.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Role role = objectMapper.readValue(JSON_FULL, Role.class);
+        String json = objectMapper.writeValueAsString(role);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getEnabled() throws Exception {
-        role.getEnabled();
+    public void testMethods() throws Exception {
+        Role role = objectMapper.readValue(JSON_FULL, Role.class);
+        role.toString();
+        
+        String name = role.getName();
+        Assert.assertNotNull(name);
+        role.setName(name);
+        
+        String description = role.getDescription();
+        Assert.assertNotNull(description);
+        role.setDescription(description);
+        
+        String id = role.getId();
+        Assert.assertNotNull(id);
+        
+        String enabled = role.getEnabled();
+        Assert.assertNotNull(enabled);
+        role.setEnabled(enabled);
     }
-
-    @Test
-    public void setEnabled() throws Exception {
-        role.setEnabled("test");
-    }
-
-}
\ No newline at end of file
+}
index 7656dd6..98a7c79 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Role;
+import com.woorea.openstack.keystone.model.Roles;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class RolesTest {
 
-    Roles roles = new Roles();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"roles\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : \"enabled\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : \"enabled\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        roles.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Roles.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Roles roles = objectMapper.readValue(JSON_FULL, Roles.class);
+        String json = objectMapper.writeValueAsString(roles);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        roles.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Roles roles = objectMapper.readValue(JSON_FULL, Roles.class);
+        roles.toString();
+        
+        List<Role> list = roles.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Role x : roles) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 03c4f98..e6c8a28 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Service;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ServiceTest {
 
-    Service service = new Service();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() throws Exception {
-        service.getId();
-    }
-
-    @Test
-    public void getType() throws Exception {
-        service.getType();
-    }
-
-    @Test
-    public void setType() throws Exception {
-        service.setType("type");
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"OS-KSADM:service\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getName() throws Exception {
-        service.getName();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void setName() throws Exception {
-        service.setName("name");
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Service.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Service service = objectMapper.readValue(JSON_FULL, Service.class);
+        String json = objectMapper.writeValueAsString(service);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getDescription() throws Exception {
-        service.getDescription();
+    public void testMethods() throws Exception {
+        Service service = objectMapper.readValue(JSON_FULL, Service.class);
+        service.toString();
+        
+        String name = service.getName();
+        Assert.assertNotNull(name);
+        service.setName(name);
+        
+        String description = service.getDescription();
+        Assert.assertNotNull(description);
+        service.setDescription(description);
+        
+        String id = service.getId();
+        Assert.assertNotNull(id);
+        
+        String type = service.getType();
+        Assert.assertNotNull(type);
+        service.setType(type);
     }
-
-    @Test
-    public void setDescription() throws Exception {
-        service.setDescription("desc");
-    }
-
-}
\ No newline at end of file
+}
index c095e66..28b7517 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Service;
+import com.woorea.openstack.keystone.model.Services;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ServicesTest {
 
-    Services services = new Services();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"OS-KSADM:services\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        services.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Services.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Services services = objectMapper.readValue(JSON_FULL, Services.class);
+        String json = objectMapper.writeValueAsString(services);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        services.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Services services = objectMapper.readValue(JSON_FULL, Services.class);
+        services.toString();
+        
+        List<Service> list = services.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Service x : services) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 9c5b02e..6ce4a11 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Tenant;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class TenantTest {
 
-    Tenant tenant = new Tenant();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() throws Exception {
-        tenant.getId();
-    }
-
-    @Test
-    public void setId() throws Exception {
-        tenant.setId("tenantid");
-    }
-
-    @Test
-    public void getName() throws Exception {
-        tenant.getName();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"tenant\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void setName() throws Exception {
-        tenant.setName("test");
-    }
-
-    @Test
-    public void getDescription() throws Exception {
-        tenant.getDescription();
-    }
-
-    @Test
-    public void setDescription() throws Exception {
-        tenant.setDescription("desc");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getEnabled() throws Exception {
-        tenant.getEnabled();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Tenant.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Tenant tenant = objectMapper.readValue(JSON_FULL, Tenant.class);
+        String json = objectMapper.writeValueAsString(tenant);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setEnabled() throws Exception {
-        tenant.setEnabled(true);
+    public void testMethods() throws Exception {
+        Tenant tenant = objectMapper.readValue(JSON_FULL, Tenant.class);
+        tenant.toString();
+        
+        String name = tenant.getName();
+        Assert.assertNotNull(name);
+        tenant.setName(name);
+        
+        String description = tenant.getDescription();
+        Assert.assertNotNull(description);
+        tenant.setDescription(description);
+        
+        String id = tenant.getId();
+        Assert.assertNotNull(id);
+        tenant.setId(id);
+        
+        Boolean enabled = tenant.getEnabled();
+        Assert.assertNotNull(enabled);
+        tenant.setEnabled(enabled);
     }
-}
\ No newline at end of file
+}
index eb4c2ee..f3d10e3 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Link;
+import com.woorea.openstack.keystone.model.Tenant;
+import com.woorea.openstack.keystone.model.Tenants;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class TenantsTest {
 
-    Tenants tenants= new Tenants();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getList() throws Exception {
-        tenants.getList();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"tenants\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  } ]," + EOL
+        + "  \"tenants_links\" : [ {" + EOL
+        + "    \"rel\" : \"rel\"," + EOL
+        + "    \"href\" : \"href\"," + EOL
+        + "    \"type\" : \"type\"" + EOL
+        + "  }, {" + EOL
+        + "    \"rel\" : \"rel\"," + EOL
+        + "    \"href\" : \"href\"," + EOL
+        + "    \"type\" : \"type\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getLinks() throws Exception {
-        tenants.getLinks();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Tenants.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Tenants tenants = objectMapper.readValue(JSON_FULL, Tenants.class);
+        String json = objectMapper.writeValueAsString(tenants);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        tenants.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Tenants tenants = objectMapper.readValue(JSON_FULL, Tenants.class);
+        tenants.toString();
+        
+        List<Link> links = tenants.getLinks();
+        Assert.assertNotNull(links);
+        Assert.assertEquals(2, links.size());
+        
+        List<Tenant> list = tenants.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Tenant x : tenants) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index a9c0d7c..65308b9 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.Tenant;
+import com.woorea.openstack.keystone.model.Token;
+import java.util.Calendar;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class TokenTest {
 
-    Token token = new Token();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() throws Exception {
-        token.getId();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"id\" : \"id\"," + EOL
+        + "  \"issued_at\" : 1488024000000," + EOL
+        + "  \"expires\" : 1488628800000," + EOL
+        + "  \"tenant\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getIssued_at() throws Exception {
-        token.getIssued_at();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getExpires() throws Exception {
-        token.getExpires();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Token.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Token token = objectMapper.readValue(JSON_FULL, Token.class);
+        String json = objectMapper.writeValueAsString(token);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getTenant() throws Exception {
-        token.getTenant();
+    public void testMethods() throws Exception {
+        Token token = objectMapper.readValue(JSON_FULL, Token.class);
+        token.toString();
+        
+        Calendar expires = token.getExpires();
+        Assert.assertNotNull(expires);
+        
+        String id = token.getId();
+        Assert.assertNotNull(id);
+        
+        Calendar issued_at = token.getIssued_at();
+        Assert.assertNotNull(issued_at);
+        
+        Tenant tenant = token.getTenant();
+        Assert.assertNotNull(tenant);
     }
-
-}
\ No newline at end of file
+}
index 7898a76..5669dab 100644 (file)
@@ -1,9 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
- * 
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.User;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class UserTest {
 
-    User user = new User();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"user\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"username\" : \"username\"," + EOL
+        + "    \"password\" : \"password\"," + EOL
+        + "    \"tenantId\" : \"tenantid\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"email\" : \"email\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getId() throws Exception {
-        user.getId();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + User.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        User user = objectMapper.readValue(JSON_FULL, User.class);
+        String json = objectMapper.writeValueAsString(user);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setId() throws Exception {
-        user.setId("test");
+    public void testMethods() throws Exception {
+        User user = objectMapper.readValue(JSON_FULL, User.class);
+        user.toString();
+        
+        String password = user.getPassword();
+        Assert.assertNotNull(password);
+        user.setPassword(password);
+        
+        String name = user.getName();
+        Assert.assertNotNull(name);
+        user.setName(name);
+        
+        String tenantId = user.getTenantId();
+        Assert.assertNotNull(tenantId);
+        user.setTenantId(tenantId);
+        
+        String id = user.getId();
+        Assert.assertNotNull(id);
+        user.setId(id);
+        
+        String email = user.getEmail();
+        Assert.assertNotNull(email);
+        user.setEmail(email);
+        
+        Boolean enabled = user.getEnabled();
+        Assert.assertNotNull(enabled);
+        user.setEnabled(enabled);
+        
+        String username = user.getUsername();
+        Assert.assertNotNull(username);
+        user.setUsername(username);
     }
-
-    @Test
-    public void getUsername() throws Exception {
-        user.getUsername();
-    }
-
-    @Test
-    public void setUsername() throws Exception {
-        user.setUsername("test");
-    }
-
-    @Test
-    public void getPassword() throws Exception {
-        user.getPassword();
-    }
-
-    @Test
-    public void setPassword() throws Exception {
-        user.setPassword("test");
-    }
-
-    @Test
-    public void getTenantId() throws Exception {
-        user.getTenantId();
-    }
-
-    @Test
-    public void setTenantId() throws Exception {
-        user.setTenantId("test");
-    }
-
-    @Test
-    public void getName() throws Exception {
-        user.getName();
-    }
-
-    @Test
-    public void setName() throws Exception {
-        user.setName("test");
-    }
-
-    @Test
-    public void getEmail() throws Exception {
-        user.getEmail();
-    }
-
-    @Test
-    public void setEmail() throws Exception {
-        user.setEmail("test");
-    }
-
-    @Test
-    public void getEnabled() throws Exception {
-        user.getEnabled();
-    }
-
-    @Test
-    public void setEnabled() throws Exception {
-        user.setEnabled(true);
-    }
-
-}
\ No newline at end of file
+}
index 8a3f16d..acb96a3 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.keystone.model;
 
+import com.woorea.openstack.keystone.model.User;
+import com.woorea.openstack.keystone.model.Users;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class UsersTest {
 
-    Users users = new Users();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"users\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"username\" : \"username\"," + EOL
+        + "    \"password\" : \"password\"," + EOL
+        + "    \"tenantId\" : \"tenantid\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"email\" : \"email\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"username\" : \"username\"," + EOL
+        + "    \"password\" : \"password\"," + EOL
+        + "    \"tenantId\" : \"tenantid\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"email\" : \"email\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        users.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Users.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Users users = objectMapper.readValue(JSON_FULL, Users.class);
+        String json = objectMapper.writeValueAsString(users);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        users.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Users users = objectMapper.readValue(JSON_FULL, Users.class);
+        users.toString();
+        
+        List<User> list = users.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") User x : users) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
diff --git a/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/AccessKeyTest.java b/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/AccessKeyTest.java
new file mode 100644 (file)
index 0000000..413097f
--- /dev/null
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.keystone.model.authentication;
+
+import com.woorea.openstack.keystone.model.authentication.AccessKey;
+import com.woorea.openstack.keystone.model.authentication.AccessKey.ApiAccessKeyCredentials;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class AccessKeyTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"auth\" : {" + EOL
+        + "    \"tenantId\" : \"tenantid\"," + EOL
+        + "    \"tenantName\" : \"tenantname\"," + EOL
+        + "    \"apiAccessKeyCredentials\" : {" + EOL
+        + "      \"accessKey\" : \"accesskey\"," + EOL
+        + "      \"secretKey\" : \"secretkey\"" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + AccessKey.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        AccessKey accesskey = objectMapper.readValue(JSON_FULL, AccessKey.class);
+        String json = objectMapper.writeValueAsString(accesskey);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        AccessKey accesskey = objectMapper.readValue(JSON_FULL, AccessKey.class);
+        accesskey.toString();
+        
+        ApiAccessKeyCredentials apiAccessKeyCredentials = accesskey.getApiAccessKeyCredentials();
+        Assert.assertNotNull(apiAccessKeyCredentials);
+        accesskey.setApiAccessKeyCredentials(apiAccessKeyCredentials);
+        
+        String tenantId = accesskey.getTenantId();
+        Assert.assertNotNull(tenantId);
+        accesskey.setTenantId(tenantId);
+        
+        String tenantName = accesskey.getTenantName();
+        Assert.assertNotNull(tenantName);
+        accesskey.setTenantName(tenantName);
+    }
+}
diff --git a/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/ApiAccessKeyCredentialsTest.java b/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/ApiAccessKeyCredentialsTest.java
new file mode 100644 (file)
index 0000000..ae63a61
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.keystone.model.authentication;
+
+import com.woorea.openstack.keystone.model.authentication.AccessKey.ApiAccessKeyCredentials;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ApiAccessKeyCredentialsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"accessKey\" : \"accesskey\"," + EOL
+        + "  \"secretKey\" : \"secretkey\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ApiAccessKeyCredentials.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ApiAccessKeyCredentials apiaccesskeycredentials = objectMapper.readValue(JSON_FULL, ApiAccessKeyCredentials.class);
+        String json = objectMapper.writeValueAsString(apiaccesskeycredentials);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ApiAccessKeyCredentials apiaccesskeycredentials = objectMapper.readValue(JSON_FULL, ApiAccessKeyCredentials.class);
+        apiaccesskeycredentials.toString();
+        
+        String secretKey = apiaccesskeycredentials.getSecretKey();
+        Assert.assertNotNull(secretKey);
+        apiaccesskeycredentials.setSecretKey(secretKey);
+        
+        String accessKey = apiaccesskeycredentials.getAccessKey();
+        Assert.assertNotNull(accessKey);
+        apiaccesskeycredentials.setAccessKey(accessKey);
+    }
+}
diff --git a/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/PasswordCredentialsTest.java b/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/PasswordCredentialsTest.java
new file mode 100644 (file)
index 0000000..4c71e1c
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.keystone.model.authentication;
+
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword.PasswordCredentials;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class PasswordCredentialsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"username\" : \"username\"," + EOL
+        + "  \"password\" : \"password\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + PasswordCredentials.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        PasswordCredentials passwordcredentials = objectMapper.readValue(JSON_FULL, PasswordCredentials.class);
+        String json = objectMapper.writeValueAsString(passwordcredentials);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        PasswordCredentials passwordcredentials = objectMapper.readValue(JSON_FULL, PasswordCredentials.class);
+        passwordcredentials.toString();
+        
+        String password = passwordcredentials.getPassword();
+        Assert.assertNotNull(password);
+        passwordcredentials.setPassword(password);
+        
+        String username = passwordcredentials.getUsername();
+        Assert.assertNotNull(username);
+        passwordcredentials.setUsername(username);
+    }
+}
diff --git a/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/TokenTest.java b/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/TokenTest.java
new file mode 100644 (file)
index 0000000..170f0b4
--- /dev/null
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.keystone.model.authentication;
+
+import com.woorea.openstack.keystone.model.authentication.TokenAuthentication.Token;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class TokenTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"id\" : \"id\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Token.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Token token = objectMapper.readValue(JSON_FULL, Token.class);
+        String json = objectMapper.writeValueAsString(token);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Token token = objectMapper.readValue(JSON_FULL, Token.class);
+        token.toString();
+        
+        String id = token.getId();
+        Assert.assertNotNull(id);
+        token.setId(id);
+    }
+}
diff --git a/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/UsernamePasswordTest.java b/keystone-model/src/test/java/com/woorea/openstack/keystone/model/authentication/UsernamePasswordTest.java
new file mode 100644 (file)
index 0000000..ee98274
--- /dev/null
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.keystone.model.authentication;
+
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword.PasswordCredentials;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class UsernamePasswordTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"auth\" : {" + EOL
+        + "    \"tenantId\" : \"tenantid\"," + EOL
+        + "    \"tenantName\" : \"tenantname\"," + EOL
+        + "    \"passwordCredentials\" : {" + EOL
+        + "      \"username\" : \"username\"," + EOL
+        + "      \"password\" : \"password\"" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + UsernamePassword.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        UsernamePassword usernamepassword = objectMapper.readValue(JSON_FULL, UsernamePassword.class);
+        String json = objectMapper.writeValueAsString(usernamepassword);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        UsernamePassword usernamepassword = objectMapper.readValue(JSON_FULL, UsernamePassword.class);
+        usernamepassword.toString();
+        
+        PasswordCredentials passwordCredentials = usernamepassword.getPasswordCredentials();
+        Assert.assertNotNull(passwordCredentials);
+        usernamepassword.setPasswordCredentials(passwordCredentials);
+        
+        String tenantId = usernamepassword.getTenantId();
+        Assert.assertNotNull(tenantId);
+        usernamepassword.setTenantId(tenantId);
+        
+        String tenantName = usernamepassword.getTenantName();
+        Assert.assertNotNull(tenantName);
+        usernamepassword.setTenantName(tenantName);
+    }
+}
index ec3d138..31a1099 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Authentication;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity;
+import com.woorea.openstack.keystone.v3.model.Authentication.Scope;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class AuthenticationTest {
 
-    Authentication authentication = new Authentication();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getIdentity() throws Exception {
-        authentication.getIdentity();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"auth\" : {" + EOL
+        + "    \"identity\" : {" + EOL
+        + "      \"methods\" : [ \"methods-v1\", \"methods-v2\" ]," + EOL
+        + "      \"password\" : {" + EOL
+        + "        \"user\" : {" + EOL
+        + "          \"domain\" : {" + EOL
+        + "            \"id\" : \"id\"," + EOL
+        + "            \"name\" : \"name\"" + EOL
+        + "          }," + EOL
+        + "          \"id\" : \"id\"," + EOL
+        + "          \"name\" : \"name\"," + EOL
+        + "          \"password\" : \"password\"" + EOL
+        + "        }" + EOL
+        + "      }," + EOL
+        + "      \"token\" : {" + EOL
+        + "        \"id\" : \"id\"" + EOL
+        + "      }" + EOL
+        + "    }," + EOL
+        + "    \"scope\" : {" + EOL
+        + "      \"project\" : {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"domain\" : {" + EOL
+        + "          \"id\" : \"id\"," + EOL
+        + "          \"name\" : \"name\"" + EOL
+        + "        }," + EOL
+        + "        \"name\" : \"name\"" + EOL
+        + "      }" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void setIdentity() throws Exception {
-        authentication.setIdentity(new Authentication.Identity());
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getScope() throws Exception {
-        authentication.getScope();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Authentication.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Authentication authentication = objectMapper.readValue(JSON_FULL, Authentication.class);
+        String json = objectMapper.writeValueAsString(authentication);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setScope() throws Exception {
-        authentication.setScope(new Authentication.Scope());
+    public void testMethods() throws Exception {
+        Authentication authentication = objectMapper.readValue(JSON_FULL, Authentication.class);
+        authentication.toString();
+        
+        Identity identity = authentication.getIdentity();
+        Assert.assertNotNull(identity);
+        authentication.setIdentity(identity);
+        
+        Scope scope = authentication.getScope();
+        Assert.assertNotNull(scope);
+        authentication.setScope(scope);
     }
-
-}
\ No newline at end of file
+}
index be5740f..b0c75b2 100644 (file)
@@ -1,7 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Credential;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import java.util.HashMap;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class CredentialTest {
 
-    Credential credential = new Credential();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() throws Exception {
-        credential.getId();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"credential\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"userId\" : \"userid\"," + EOL
+        + "    \"blob\" : {" + EOL
+        + "      \"blob-k1\" : \"blob-v1\"," + EOL
+        + "      \"blob-k2\" : \"blob-v2\"" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void setId() throws Exception {
-        credential.setId("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getProjectId() throws Exception {
-        credential.getProjectId();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Credential.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Credential credential = objectMapper.readValue(JSON_FULL, Credential.class);
+        String json = objectMapper.writeValueAsString(credential);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setProjectId() throws Exception {
-        credential.setProjectId("test");
+    public void testMethods() throws Exception {
+        Credential credential = objectMapper.readValue(JSON_FULL, Credential.class);
+        credential.toString();
+        
+        Map<String,String> blob = credential.getBlob();
+        Assert.assertNotNull(blob);
+        Assert.assertEquals(2, blob.size());
+        credential.setBlob(blob);
+        
+        String id = credential.getId();
+        Assert.assertNotNull(id);
+        credential.setId(id);
+        
+        String type = credential.getType();
+        Assert.assertNotNull(type);
+        credential.setType(type);
+        
+        String userId = credential.getUserId();
+        Assert.assertNotNull(userId);
+        credential.setUserId(userId);
+        
+        String projectId = credential.getProjectId();
+        Assert.assertNotNull(projectId);
+        credential.setProjectId(projectId);
     }
-
-    @Test
-    public void getType() throws Exception {
-        credential.getType();
-    }
-
-    @Test
-    public void setType() throws Exception {
-        credential.setType("test");
-    }
-
-    @Test
-    public void getUserId() throws Exception {
-        credential.getUserId();
-    }
-
-    @Test
-    public void setUserId() throws Exception {
-        credential.setUserId("test");
-    }
-
-    @Test
-    public void getBlob() throws Exception {
-        credential.getBlob();
-    }
-
-    @Test
-    public void setBlob() throws Exception {
-        credential.setBlob(new HashMap<String, String>());
-    }
-
-}
\ No newline at end of file
+}
index a14ab9b..a158efb 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Credential;
+import com.woorea.openstack.keystone.v3.model.Credentials;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class CredentialsTest {
 
-    Credentials credentials = new Credentials();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"credentials\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"userId\" : \"userid\"," + EOL
+        + "    \"blob\" : {" + EOL
+        + "      \"blob-k1\" : \"blob-v1\"," + EOL
+        + "      \"blob-k2\" : \"blob-v2\"" + EOL
+        + "    }" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"userId\" : \"userid\"," + EOL
+        + "    \"blob\" : {" + EOL
+        + "      \"blob-k1\" : \"blob-v1\"," + EOL
+        + "      \"blob-k2\" : \"blob-v2\"" + EOL
+        + "    }" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        credentials.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Credentials.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Credentials credentials = objectMapper.readValue(JSON_FULL, Credentials.class);
+        String json = objectMapper.writeValueAsString(credentials);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        credentials.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Credentials credentials = objectMapper.readValue(JSON_FULL, Credentials.class);
+        credentials.toString();
+        
+        List<Credential> list = credentials.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Credential x : credentials) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-}
\ No newline at end of file
+}
index 7741a41..f4e75c3 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Token.Domain;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class DomainTest {
 
-    Domain domain = new Domain();
-
-    @Test
-    public void getId() throws Exception {
-        domain.getId();
-    }
-
-    @Test
-    public void setId() throws Exception {
-        domain.setId("test");
-    }
-
-    @Test
-    public void getName() throws Exception {
-        domain.getName();
-    }
-
-    @Test
-    public void setName() throws Exception {
-        domain.setName("test");
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getDescription() throws Exception {
-        domain.getDescription();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"id\" : \"id\"," + EOL
+        + "  \"name\" : \"name\"" + EOL
+        + "}";
 
-    @Test
-    public void setDescription() throws Exception {
-        domain.setDescription("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getEnabled() throws Exception {
-        domain.getEnabled();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Domain.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Domain domain = objectMapper.readValue(JSON_FULL, Domain.class);
+        String json = objectMapper.writeValueAsString(domain);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setEnabled() throws Exception {
-        domain.setEnabled(true);
+    public void testMethods() throws Exception {
+        Domain domain = objectMapper.readValue(JSON_FULL, Domain.class);
+        domain.toString();
+        
+        String name = domain.getName();
+        Assert.assertNotNull(name);
+        domain.setName(name);
+        
+        String id = domain.getId();
+        Assert.assertNotNull(id);
+        domain.setId(id);
     }
-
-}
\ No newline at end of file
+}
index aa8ff41..ee694d5 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Domain;
+import com.woorea.openstack.keystone.v3.model.Domains;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class DomainsTest {
 
-    Domains domains = new Domains();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"domains\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        domains.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Domains.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Domains domains = objectMapper.readValue(JSON_FULL, Domains.class);
+        String json = objectMapper.writeValueAsString(domains);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        domains.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Domains domains = objectMapper.readValue(JSON_FULL, Domains.class);
+        domains.toString();
+        
+        List<Domain> list = domains.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Domain x : domains) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 9a52223..75a4441 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Token.Service.Endpoint;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class EndpointTest {
 
-    Endpoint endpoint = new Endpoint();
-
-    @Test
-    public void getId() throws Exception {
-        endpoint.getId();
-    }
-
-    @Test
-    public void setId() throws Exception {
-        endpoint.setId("test");
-    }
-
-    @Test
-    public void getInterface() throws Exception {
-        endpoint.getInterface();
-    }
-
-    @Test
-    public void setInterface() throws Exception {
-        endpoint.setInterface("test");
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getName() throws Exception {
-        endpoint.getName();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"id\" : \"id\"," + EOL
+        + "  \"url\" : \"url\"," + EOL
+        + "  \"region\" : \"region\"," + EOL
+        + "  \"enabled\" : false," + EOL
+        + "  \"interface\" : \"interface\"," + EOL
+        + "  \"legacy_endpoint_id\" : \"legacyendpointid\"" + EOL
+        + "}";
 
-    @Test
-    public void setName() throws Exception {
-        endpoint.setName("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getServiceId() throws Exception {
-        endpoint.getServiceId();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Endpoint.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Endpoint endpoint = objectMapper.readValue(JSON_FULL, Endpoint.class);
+        String json = objectMapper.writeValueAsString(endpoint);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setServiceId() throws Exception {
-        endpoint.setServiceId("test");
+    public void testMethods() throws Exception {
+        Endpoint endpoint = objectMapper.readValue(JSON_FULL, Endpoint.class);
+        endpoint.toString();
+        
+        String legacyEndpointId = endpoint.getLegacyEndpointId();
+        Assert.assertNotNull(legacyEndpointId);
+        endpoint.setLegacyEndpointId(legacyEndpointId);
+        
+        String id = endpoint.getId();
+        Assert.assertNotNull(id);
+        endpoint.setId(id);
+        
+        String region = endpoint.getRegion();
+        Assert.assertNotNull(region);
+        endpoint.setRegion(region);
+        
+        String interfaceProperty = endpoint.getInterface();
+        Assert.assertNotNull(interfaceProperty);
+        endpoint.setInterface(interfaceProperty);
+        
+        String url = endpoint.getUrl();
+        Assert.assertNotNull(url);
+        endpoint.setUrl(url);
+        
+        Boolean enabled = endpoint.getEnabled();
+        Assert.assertNotNull(enabled);
+        endpoint.setEnabled(enabled);
     }
-
-}
\ No newline at end of file
+}
index 4f6a4a9..8002b1c 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Endpoint;
+import com.woorea.openstack.keystone.v3.model.Endpoints;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class EndpointsTest {
 
-    Endpoints endpoints = new Endpoints();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"endpoints\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"interface\" : \"interface\"," + EOL
+        + "    \"service_id\" : \"serviceid\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"interface\" : \"interface\"," + EOL
+        + "    \"service_id\" : \"serviceid\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        endpoints.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Endpoints.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Endpoints endpoints = objectMapper.readValue(JSON_FULL, Endpoints.class);
+        String json = objectMapper.writeValueAsString(endpoints);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        endpoints.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Endpoints endpoints = objectMapper.readValue(JSON_FULL, Endpoints.class);
+        endpoints.toString();
+        
+        List<Endpoint> list = endpoints.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Endpoint x : endpoints) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 76a3dd9..75fc901 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Group;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class GroupTest {
 
-    Group group = new Group();
-
-    @Test
-    public void getId() throws Exception {
-        group.getId();
-    }
-
-    @Test
-    public void setId() throws Exception {
-        group.setId("test");
-    }
-
-    @Test
-    public void getDomainId() throws Exception {
-        group.getDomainId();
-    }
-
-    @Test
-    public void setDomainId() throws Exception {
-        group.setDomainId("test");
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getName() throws Exception {
-        group.getName();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"group\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"domain_id\" : \"domainid\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void setName() throws Exception {
-        group.setName("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getDescription() throws Exception {
-        group.getDescription();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Group.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Group group = objectMapper.readValue(JSON_FULL, Group.class);
+        String json = objectMapper.writeValueAsString(group);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setDescription() throws Exception {
-        group.setDescription("test");
+    public void testMethods() throws Exception {
+        Group group = objectMapper.readValue(JSON_FULL, Group.class);
+        group.toString();
+        
+        String name = group.getName();
+        Assert.assertNotNull(name);
+        group.setName(name);
+        
+        String description = group.getDescription();
+        Assert.assertNotNull(description);
+        group.setDescription(description);
+        
+        String id = group.getId();
+        Assert.assertNotNull(id);
+        group.setId(id);
+        
+        String domainId = group.getDomainId();
+        Assert.assertNotNull(domainId);
+        group.setDomainId(domainId);
     }
-
-}
\ No newline at end of file
+}
index 3f399fd..c16c25a 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Group;
+import com.woorea.openstack.keystone.v3.model.Groups;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class GroupsTest {
 
-    Groups groups = new Groups();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"groups\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"domain_id\" : \"domainid\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"domain_id\" : \"domainid\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        groups.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Groups.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Groups groups = objectMapper.readValue(JSON_FULL, Groups.class);
+        String json = objectMapper.writeValueAsString(groups);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        groups.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Groups groups = objectMapper.readValue(JSON_FULL, Groups.class);
+        groups.toString();
+        
+        List<Group> list = groups.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Group x : groups) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-}
\ No newline at end of file
+}
diff --git a/keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/IdentityTest.java b/keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/IdentityTest.java
new file mode 100644 (file)
index 0000000..ba55e8b
--- /dev/null
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.keystone.v3.model;
+
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity.Token;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class IdentityTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"methods\" : [ \"methods-v1\", \"methods-v2\" ]," + EOL
+        + "  \"password\" : {" + EOL
+        + "    \"user\" : {" + EOL
+        + "      \"domain\" : {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"" + EOL
+        + "      }," + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"password\" : \"password\"" + EOL
+        + "    }" + EOL
+        + "  }," + EOL
+        + "  \"token\" : {" + EOL
+        + "    \"id\" : \"id\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Identity.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Identity identity = objectMapper.readValue(JSON_FULL, Identity.class);
+        String json = objectMapper.writeValueAsString(identity);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Identity identity = objectMapper.readValue(JSON_FULL, Identity.class);
+        identity.toString();
+        
+        Password password = identity.getPassword();
+        Assert.assertNotNull(password);
+        identity.setPassword(password);
+        
+        List<String> methods = identity.getMethods();
+        Assert.assertNotNull(methods);
+        Assert.assertEquals(2, methods.size());
+        identity.setMethods(methods);
+        
+        Token token = identity.getToken();
+        Assert.assertNotNull(token);
+        identity.setToken(token);
+    }
+}
diff --git a/keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/PasswordTest.java b/keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/PasswordTest.java
new file mode 100644 (file)
index 0000000..d1230e2
--- /dev/null
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.keystone.v3.model;
+
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class PasswordTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"user\" : {" + EOL
+        + "    \"domain\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"" + EOL
+        + "    }," + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"password\" : \"password\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Password.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Password password = objectMapper.readValue(JSON_FULL, Password.class);
+        String json = objectMapper.writeValueAsString(password);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Password password = objectMapper.readValue(JSON_FULL, Password.class);
+        password.toString();
+        
+        User user = password.getUser();
+        Assert.assertNotNull(user);
+        password.setUser(user);
+    }
+}
index ce0a224..a3e8a8a 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Policies;
+import com.woorea.openstack.keystone.v3.model.Policy;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class PoliciesTest {
 
-    Policies policies = new Policies();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"policies\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"userId\" : \"userid\"," + EOL
+        + "    \"blob\" : {" + EOL
+        + "      \"blob-k1\" : \"blob-v1\"," + EOL
+        + "      \"blob-k2\" : \"blob-v2\"" + EOL
+        + "    }" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"userId\" : \"userid\"," + EOL
+        + "    \"blob\" : {" + EOL
+        + "      \"blob-k1\" : \"blob-v1\"," + EOL
+        + "      \"blob-k2\" : \"blob-v2\"" + EOL
+        + "    }" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        policies.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Policies.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Policies policies = objectMapper.readValue(JSON_FULL, Policies.class);
+        String json = objectMapper.writeValueAsString(policies);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        policies.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Policies policies = objectMapper.readValue(JSON_FULL, Policies.class);
+        policies.toString();
+        
+        List<Policy> list = policies.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Policy x : policies) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 3062c64..2aae601 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Policy;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import java.util.HashMap;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class PolicyTest {
 
-    Policy policy = new Policy();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() throws Exception {
-        policy.getId();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"policy\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"userId\" : \"userid\"," + EOL
+        + "    \"blob\" : {" + EOL
+        + "      \"blob-k1\" : \"blob-v1\"," + EOL
+        + "      \"blob-k2\" : \"blob-v2\"" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void setId() throws Exception {
-        policy.setId("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getProjectId() throws Exception {
-        policy.getProjectId();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Policy.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Policy policy = objectMapper.readValue(JSON_FULL, Policy.class);
+        String json = objectMapper.writeValueAsString(policy);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setProjectId() throws Exception {
-        policy.setProjectId("test");
+    public void testMethods() throws Exception {
+        Policy policy = objectMapper.readValue(JSON_FULL, Policy.class);
+        policy.toString();
+        
+        Map<String,String> blob = policy.getBlob();
+        Assert.assertNotNull(blob);
+        Assert.assertEquals(2, blob.size());
+        policy.setBlob(blob);
+        
+        String id = policy.getId();
+        Assert.assertNotNull(id);
+        policy.setId(id);
+        
+        String type = policy.getType();
+        Assert.assertNotNull(type);
+        policy.setType(type);
+        
+        String userId = policy.getUserId();
+        Assert.assertNotNull(userId);
+        policy.setUserId(userId);
+        
+        String projectId = policy.getProjectId();
+        Assert.assertNotNull(projectId);
+        policy.setProjectId(projectId);
     }
-
-    @Test
-    public void getType() throws Exception {
-        policy.getType();
-    }
-
-    @Test
-    public void setType() throws Exception {
-        policy.setType("test");
-    }
-
-    @Test
-    public void getUserId() throws Exception {
-        policy.getUserId();
-    }
-
-    @Test
-    public void setUserId() throws Exception {
-        policy.setUserId("test");
-    }
-
-    @Test
-    public void getBlob() throws Exception {
-        policy.getBlob();
-    }
-
-    @Test
-    public void setBlob() throws Exception {
-        policy.setBlob(new HashMap<String, String>());
-    }
-
-}
\ No newline at end of file
+}
index 0a9ee02..80b4122 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Token.Domain;
+import com.woorea.openstack.keystone.v3.model.Token.Project;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ProjectTest {
 
-    Project project = new Project();
-
-    @Test
-    public void getId() throws Exception {
-        project.getId();
-    }
-
-    @Test
-    public void setId() throws Exception {
-        project.setId("test");
-    }
-
-    @Test
-    public void getDomainId() throws Exception {
-        project.getDomainId();
-    }
-
-    @Test
-    public void setDomainId() throws Exception {
-        project.setDomainId("test");
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getName() throws Exception {
-        project.getName();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"domain\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"" + EOL
+        + "  }," + EOL
+        + "  \"id\" : \"id\"," + EOL
+        + "  \"name\" : \"name\"" + EOL
+        + "}";
 
-    @Test
-    public void setName() throws Exception {
-        project.setName("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getEnabled() throws Exception {
-        project.getEnabled();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Project.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Project project = objectMapper.readValue(JSON_FULL, Project.class);
+        String json = objectMapper.writeValueAsString(project);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setEnabled() throws Exception {
-        project.setEnabled(true);
+    public void testMethods() throws Exception {
+        Project project = objectMapper.readValue(JSON_FULL, Project.class);
+        project.toString();
+        
+        Domain domain = project.getDomain();
+        Assert.assertNotNull(domain);
+        project.setDomain(domain);
+        
+        String name = project.getName();
+        Assert.assertNotNull(name);
+        project.setName(name);
+        
+        String id = project.getId();
+        Assert.assertNotNull(id);
+        project.setId(id);
     }
-
-}
\ No newline at end of file
+}
index f4732b2..6ab1c88 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Project;
+import com.woorea.openstack.keystone.v3.model.Projects;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ProjectsTest {
 
-    Projects projects = new Projects();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"projects\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"enabled\" : false," + EOL
+        + "    \"domain_id\" : \"domainid\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"enabled\" : false," + EOL
+        + "    \"domain_id\" : \"domainid\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        projects.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Projects.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Projects projects = objectMapper.readValue(JSON_FULL, Projects.class);
+        String json = objectMapper.writeValueAsString(projects);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        projects.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Projects projects = objectMapper.readValue(JSON_FULL, Projects.class);
+        projects.toString();
+        
+        List<Project> list = projects.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Project x : projects) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index d1c0c43..189205e 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Token.Role;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class RoleTest {
 
-    Role role = new Role();
-
-    @Test
-    public void getId() throws Exception {
-        role.getId();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getName() throws Exception {
-        role.getName();
-    }
+    private static final String JSON_FULL = "{ }";
 
-    @Test
-    public void setName() throws Exception {
-        role.setName("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getDescription() throws Exception {
-        role.getDescription();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Role.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Role role = objectMapper.readValue(JSON_FULL, Role.class);
+        String json = objectMapper.writeValueAsString(role);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setDescription() throws Exception {
-        role.setDescription("test");
+    public void testMethods() throws Exception {
+        Role role = objectMapper.readValue(JSON_FULL, Role.class);
+        role.toString();
     }
-
-    @Test
-    public void getEnabled() throws Exception {
-        role.getEnabled();
-    }
-
-    @Test
-    public void setEnabled() throws Exception {
-        role.setEnabled("test");
-    }
-
-}
\ No newline at end of file
+}
index a18efb3..6ee1b2c 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Role;
+import com.woorea.openstack.keystone.v3.model.Roles;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class RolesTest {
 
-    Roles roles = new Roles();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"roles\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : \"enabled\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : \"enabled\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        roles.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Roles.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Roles roles = objectMapper.readValue(JSON_FULL, Roles.class);
+        String json = objectMapper.writeValueAsString(roles);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        roles.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Roles roles = objectMapper.readValue(JSON_FULL, Roles.class);
+        roles.toString();
+        
+        List<Role> list = roles.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Role x : roles) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
diff --git a/keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/ScopeTest.java b/keystone-model/src/test/java/com/woorea/openstack/keystone/v3/model/ScopeTest.java
new file mode 100644 (file)
index 0000000..3f3708b
--- /dev/null
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.keystone.v3.model;
+
+import com.woorea.openstack.keystone.v3.model.Authentication.Scope;
+import com.woorea.openstack.keystone.v3.model.Authentication.Scope.Project;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ScopeTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"project\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"domain\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"" + EOL
+        + "    }," + EOL
+        + "    \"name\" : \"name\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Scope.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Scope scope = objectMapper.readValue(JSON_FULL, Scope.class);
+        String json = objectMapper.writeValueAsString(scope);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Scope scope = objectMapper.readValue(JSON_FULL, Scope.class);
+        scope.toString();
+        
+        Project project = scope.getProject();
+        Assert.assertNotNull(project);
+        scope.setProject(project);
+    }
+}
index fbdc411..31430de 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Token.Service;
+import com.woorea.openstack.keystone.v3.model.Token.Service.Endpoint;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ServiceTest {
 
-    Service service = new Service();
-
-    @Test
-    public void getId() throws Exception {
-        service.getId();
-    }
-
-    @Test
-    public void setId() throws Exception {
-        service.setId("test");
-    }
-
-    @Test
-    public void getType() throws Exception {
-        service.getType();
-    }
-
-    @Test
-    public void setType() throws Exception {
-        service.setType("test");
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getName() throws Exception {
-        service.getName();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"id\" : \"id\"," + EOL
+        + "  \"type\" : \"type\"," + EOL
+        + "  \"endpoints\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"url\" : \"url\"," + EOL
+        + "    \"region\" : \"region\"," + EOL
+        + "    \"enabled\" : false," + EOL
+        + "    \"interface\" : \"interface\"," + EOL
+        + "    \"legacy_endpoint_id\" : \"legacyendpointid\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"url\" : \"url\"," + EOL
+        + "    \"region\" : \"region\"," + EOL
+        + "    \"enabled\" : false," + EOL
+        + "    \"interface\" : \"interface\"," + EOL
+        + "    \"legacy_endpoint_id\" : \"legacyendpointid\"" + EOL
+        + "  } ]" + EOL
+        + "}";
 
-    @Test
-    public void setName() throws Exception {
-        service.setName("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getDescription() throws Exception {
-        service.getDescription();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Service.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Service service = objectMapper.readValue(JSON_FULL, Service.class);
+        String json = objectMapper.writeValueAsString(service);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setDescription() throws Exception {
-        service.setDescription("test");
+    public void testMethods() throws Exception {
+        Service service = objectMapper.readValue(JSON_FULL, Service.class);
+        service.toString();
+        
+        List<Endpoint> endpoints = service.getEndpoints();
+        Assert.assertNotNull(endpoints);
+        Assert.assertEquals(2, endpoints.size());
+        service.setEndpoints(endpoints);
+        
+        String id = service.getId();
+        Assert.assertNotNull(id);
+        service.setId(id);
+        
+        String type = service.getType();
+        Assert.assertNotNull(type);
+        service.setType(type);
     }
-
-}
\ No newline at end of file
+}
index f9d19cd..28246c6 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.model.Service;
+import com.woorea.openstack.keystone.v3.model.Services;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ServicesTest {
 
-    Services services = new Services();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"services\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        services.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Services.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Services services = objectMapper.readValue(JSON_FULL, Services.class);
+        String json = objectMapper.writeValueAsString(services);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        services.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Services services = objectMapper.readValue(JSON_FULL, Services.class);
+        services.toString();
+        
+        List<Service> list = services.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Service x : services) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index c8d009b..aabcfb7 100644 (file)
@@ -1,9 +1,9 @@
 /*-
-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package com.woorea.openstack.keystone.v3.model;
 
-import org.junit.Test;
+package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.Token;
+import com.woorea.openstack.keystone.v3.model.Token.Domain;
+import com.woorea.openstack.keystone.v3.model.Token.Project;
+import com.woorea.openstack.keystone.v3.model.Token.Role;
+import com.woorea.openstack.keystone.v3.model.Token.Service;
+import com.woorea.openstack.keystone.v3.model.Token.User;
 import java.util.Calendar;
-import java.util.Collections;
-import java.util.GregorianCalendar;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class TokenTest {
 
-    Token token = new Token();
-
-    @Test
-    public void getId() throws Exception {
-        token.getId();
-    }
-
-    @Test
-    public void setId() throws Exception {
-        token.setId("test");
-    }
-
-    @Test
-    public void getExpiresAt() throws Exception {
-        token.getExpiresAt();
-    }
-
-    @Test
-    public void setExpiresAt() throws Exception {
-        Calendar calendar = new GregorianCalendar();
-        token.setExpiresAt(calendar);
-    }
-
-    @Test
-    public void getIssuedAt() throws Exception {
-        token.getIssuedAt();
-    }
-
-    @Test
-    public void setIssuedAt() throws Exception {
-        token.setIssuedAt(new GregorianCalendar());
-    }
-
-    @Test
-    public void getMethods() throws Exception {
-        token.getMethods();
-    }
-
-    @Test
-    public void setMethods() throws Exception {
-        token.setMethods(Collections.<String>emptyList());
-    }
-
-    @Test
-    public void getDomain() throws Exception {
-        token.getDomain();
-    }
-
-    @Test
-    public void setDomain() throws Exception {
-        token.setDomain(new Token.Domain());
-    }
-
-    @Test
-    public void getProject() throws Exception {
-        token.getProject();
-    }
-
-    @Test
-    public void setProject() throws Exception {
-        token.setProject(new Token.Project());
-    }
-
-    @Test
-    public void getUser() throws Exception {
-        token.getUser();
-    }
-
-    @Test
-    public void setUser() throws Exception {
-        token.setUser(new Token.User());
-    }
-
-    @Test
-    public void getRoles() throws Exception {
-        token.getRoles();
-    }
-
-    @Test
-    public void setRoles() throws Exception {
-        token.setRoles(Collections.<Token.Role>emptyList());
-    }
-
-    @Test
-    public void getCatalog() throws Exception {
-        token.getCatalog();
-    }
-
-    @Test
-    public void setCatalog() throws Exception {
-        token.setCatalog(Collections.<Token.Service>emptyList());
-    }
-
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"token\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"methods\" : [ \"methods-v1\", \"methods-v2\" ]," + EOL
+        + "    \"domain\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"" + EOL
+        + "    }," + EOL
+        + "    \"project\" : {" + EOL
+        + "      \"domain\" : {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"" + EOL
+        + "      }," + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"" + EOL
+        + "    }," + EOL
+        + "    \"user\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"" + EOL
+        + "    }," + EOL
+        + "    \"roles\" : [ { }, { } ]," + EOL
+        + "    \"catalog\" : [ {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"type\" : \"type\"," + EOL
+        + "      \"endpoints\" : [ {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"url\" : \"url\"," + EOL
+        + "        \"region\" : \"region\"," + EOL
+        + "        \"enabled\" : false," + EOL
+        + "        \"interface\" : \"interface\"," + EOL
+        + "        \"legacy_endpoint_id\" : \"legacyendpointid\"" + EOL
+        + "      }, {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"url\" : \"url\"," + EOL
+        + "        \"region\" : \"region\"," + EOL
+        + "        \"enabled\" : false," + EOL
+        + "        \"interface\" : \"interface\"," + EOL
+        + "        \"legacy_endpoint_id\" : \"legacyendpointid\"" + EOL
+        + "      } ]" + EOL
+        + "    }, {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"type\" : \"type\"," + EOL
+        + "      \"endpoints\" : [ {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"url\" : \"url\"," + EOL
+        + "        \"region\" : \"region\"," + EOL
+        + "        \"enabled\" : false," + EOL
+        + "        \"interface\" : \"interface\"," + EOL
+        + "        \"legacy_endpoint_id\" : \"legacyendpointid\"" + EOL
+        + "      }, {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"url\" : \"url\"," + EOL
+        + "        \"region\" : \"region\"," + EOL
+        + "        \"enabled\" : false," + EOL
+        + "        \"interface\" : \"interface\"," + EOL
+        + "        \"legacy_endpoint_id\" : \"legacyendpointid\"" + EOL
+        + "      } ]" + EOL
+        + "    } ]," + EOL
+        + "    \"expires_at\" : 1489752000000," + EOL
+        + "    \"issued_at\" : 1488456000000" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Token.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Token token = objectMapper.readValue(JSON_FULL, Token.class);
+        String json = objectMapper.writeValueAsString(token);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Token token = objectMapper.readValue(JSON_FULL, Token.class);
+        token.toString();
+        
+        List<String> methods = token.getMethods();
+        Assert.assertNotNull(methods);
+        Assert.assertEquals(2, methods.size());
+        token.setMethods(methods);
+        
+        List<Service> catalog = token.getCatalog();
+        Assert.assertNotNull(catalog);
+        Assert.assertEquals(2, catalog.size());
+        token.setCatalog(catalog);
+        
+        Domain domain = token.getDomain();
+        Assert.assertNotNull(domain);
+        token.setDomain(domain);
+        
+        List<Role> roles = token.getRoles();
+        Assert.assertNotNull(roles);
+        Assert.assertEquals(2, roles.size());
+        token.setRoles(roles);
+        
+        Project project = token.getProject();
+        Assert.assertNotNull(project);
+        token.setProject(project);
+        
+        Calendar issuedAt = token.getIssuedAt();
+        Assert.assertNotNull(issuedAt);
+        token.setIssuedAt(issuedAt);
+        
+        String id = token.getId();
+        Assert.assertNotNull(id);
+        token.setId(id);
+        
+        User user = token.getUser();
+        Assert.assertNotNull(user);
+        token.setUser(user);
+        
+        Calendar expiresAt = token.getExpiresAt();
+        Assert.assertNotNull(expiresAt);
+        token.setExpiresAt(expiresAt);
+    }
+}
index 6a8f7bc..061b0bc 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * ===================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.v3.model.User;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class UserTest {
 
-    User user = new User();
-
-    @Test
-    public void getId() throws Exception {
-        user.getId();
-    }
-
-    @Test
-    public void setId() throws Exception {
-        user.setId("Test");
-    }
-
-    @Test
-    public void getDomainId() throws Exception {
-        user.getDomainId();
-    }
-
-    @Test
-    public void setDomainId() throws Exception {
-        user.setDomainId("test");
-    }
-
-    @Test
-    public void getDefaultProjectId() throws Exception {
-        user.getDefaultProjectId();
-    }
-
-    @Test
-    public void setDefaultProjectId() throws Exception {
-        user.setDefaultProjectId("tets");
-    }
-
-    @Test
-    public void getName() throws Exception {
-        user.getName();
-    }
-
-    @Test
-    public void setName() throws Exception {
-        user.setName("test");
-    }
-
-    @Test
-    public void getPassword() throws Exception {
-        user.getPassword();
-    }
-
-    @Test
-    public void setPassword() throws Exception {
-        user.setPassword("test");
-    }
-
-    @Test
-    public void getEmail() throws Exception {
-        user.getEmail();
-    }
-
-    @Test
-    public void setEmail() throws Exception {
-        user.setEmail("test");
-    }
-
-    @Test
-    public void getDescription() throws Exception {
-        user.getDescription();
-    }
-
-    @Test
-    public void setDescription() throws Exception {
-        user.setDescription("test");
-    }
-
-    @Test
-    public void getEnabled() throws Exception {
-        user.getEnabled();
-    }
-
-    @Test
-    public void setEnabled() throws Exception {
-        user.setEnabled(true);
-    }
-
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"user\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"password\" : \"password\"," + EOL
+        + "    \"email\" : \"email\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"enabled\" : false," + EOL
+        + "    \"domain_id\" : \"domainid\"," + EOL
+        + "    \"default_project_id\" : \"defaultprojectid\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + User.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        User user = objectMapper.readValue(JSON_FULL, User.class);
+        String json = objectMapper.writeValueAsString(user);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        User user = objectMapper.readValue(JSON_FULL, User.class);
+        user.toString();
+        
+        String password = user.getPassword();
+        Assert.assertNotNull(password);
+        user.setPassword(password);
+        
+        String name = user.getName();
+        Assert.assertNotNull(name);
+        user.setName(name);
+        
+        String description = user.getDescription();
+        Assert.assertNotNull(description);
+        user.setDescription(description);
+        
+        String id = user.getId();
+        Assert.assertNotNull(id);
+        user.setId(id);
+        
+        String email = user.getEmail();
+        Assert.assertNotNull(email);
+        user.setEmail(email);
+        
+        String domainId = user.getDomainId();
+        Assert.assertNotNull(domainId);
+        user.setDomainId(domainId);
+        
+        Boolean enabled = user.getEnabled();
+        Assert.assertNotNull(enabled);
+        user.setEnabled(enabled);
+        
+        String defaultProjectId = user.getDefaultProjectId();
+        Assert.assertNotNull(defaultProjectId);
+        user.setDefaultProjectId(defaultProjectId);
+    }
+}
index 2d27173..35554bd 100644 (file)
@@ -1,8 +1,9 @@
 /*-
- * ONAP-SO
  * ============LICENSE_START=======================================================
- * Copyright 2018 Huawei Intellectual Property. All rights reserved.
- * =================================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.keystone.v3.model;
 
+import com.woorea.openstack.keystone.model.User;
+import com.woorea.openstack.keystone.v3.model.Users;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class UsersTest {
 
-    Users users = new Users();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"users\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"username\" : \"username\"," + EOL
+        + "    \"password\" : \"password\"," + EOL
+        + "    \"tenantId\" : \"tenantid\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"email\" : \"email\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"username\" : \"username\"," + EOL
+        + "    \"password\" : \"password\"," + EOL
+        + "    \"tenantId\" : \"tenantid\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"email\" : \"email\"," + EOL
+        + "    \"enabled\" : false" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        users.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Users.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Users users = objectMapper.readValue(JSON_FULL, Users.class);
+        String json = objectMapper.writeValueAsString(users);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        users.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Users users = objectMapper.readValue(JSON_FULL, Users.class);
+        users.toString();
+        
+        List<User> list = users.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") User x : users) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 19ce8bd..4d20af9 100644 (file)
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
-                       <version>4.12</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.skyscreamer</groupId>
+                       <artifactId>jsonassert</artifactId>
                        <scope>test</scope>
                </dependency>
        </dependencies>
index fbb3f46..8911156 100644 (file)
@@ -20,6 +20,7 @@ import java.io.Serializable;
 
 import javax.xml.bind.annotation.XmlElement;
 
+import org.codehaus.jackson.annotate.JsonIgnore;
 import org.codehaus.jackson.annotate.JsonProperty;
 import org.codehaus.jackson.map.annotate.JsonRootName;
 
@@ -112,6 +113,7 @@ public class SecurityGroupRuleForCreate implements Serializable {
      * @deprecated Use {@link #setParentGroupId(String)}
      */
     @Deprecated
+    @JsonIgnore
     public void setParentGroupId(Integer parentGroupId) {
         this.parentGroupId = String.valueOf(parentGroupId);
     }
@@ -191,6 +193,7 @@ public class SecurityGroupRuleForCreate implements Serializable {
      * @deprecated Use {@link #setGroupId(String)}
      */
     @Deprecated
+    @JsonIgnore
     public void setGroupId(Integer groupId) {
         this.groupId = String.valueOf(groupId);
     }
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/AbsoluteLimitTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/AbsoluteLimitTest.java
new file mode 100644 (file)
index 0000000..2fabb2b
--- /dev/null
@@ -0,0 +1,164 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Limits.AbsoluteLimit;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class AbsoluteLimitTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"maxServerMeta\" : 30," + EOL
+        + "  \"serverMetaUsed\" : 37," + EOL
+        + "  \"maxPersonality\" : 54," + EOL
+        + "  \"personalityUsed\" : 61," + EOL
+        + "  \"maxImageMeta\" : 82," + EOL
+        + "  \"imageMetaUsed\" : 89," + EOL
+        + "  \"maxPersonalitySize\" : 97," + EOL
+        + "  \"personalitySizeUsed\" : 4," + EOL
+        + "  \"maxTotalCores\" : 32," + EOL
+        + "  \"totalCoresUsed\" : 39," + EOL
+        + "  \"maxTotalInstances\" : 60," + EOL
+        + "  \"totalInstancesUsed\" : 67," + EOL
+        + "  \"maxTotalRAMSize\" : 55," + EOL
+        + "  \"totalRAMUsed\" : 19," + EOL
+        + "  \"maxSecurityGroupRules\" : 44," + EOL
+        + "  \"securityGroupRulesUsed\" : 51," + EOL
+        + "  \"maxTotalKeypairs\" : 64," + EOL
+        + "  \"totalKeyPairsUsed\" : 71," + EOL
+        + "  \"maxTotalVolumes\" : 71," + EOL
+        + "  \"totalVolumesUsed\" : 78," + EOL
+        + "  \"maxSecurityGroups\" : 4," + EOL
+        + "  \"totalSecurityGroupsUsed\" : 59," + EOL
+        + "  \"maxTotalFloatingIps\" : 76," + EOL
+        + "  \"totalFloatingIpsUsed\" : 83," + EOL
+        + "  \"maxTotalVolumeGigabytes\" : 15," + EOL
+        + "  \"totalVolumeGigabytesUsed\" : 22" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + AbsoluteLimit.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        AbsoluteLimit absolutelimit = objectMapper.readValue(JSON_FULL, AbsoluteLimit.class);
+        String json = objectMapper.writeValueAsString(absolutelimit);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        AbsoluteLimit absolutelimit = objectMapper.readValue(JSON_FULL, AbsoluteLimit.class);
+        absolutelimit.toString();
+        
+        Integer maxTotalRAMSize = absolutelimit.getMaxTotalRAMSize();
+        Assert.assertNotNull(maxTotalRAMSize);
+        
+        Integer maxTotalInstances = absolutelimit.getMaxTotalInstances();
+        Assert.assertNotNull(maxTotalInstances);
+        
+        Integer serverMetaUsed = absolutelimit.getServerMetaUsed();
+        Assert.assertNotNull(serverMetaUsed);
+        
+        Integer maxTotalKeypairs = absolutelimit.getMaxTotalKeypairs();
+        Assert.assertNotNull(maxTotalKeypairs);
+        
+        Integer maxTotalVolumeGigabytes = absolutelimit.getMaxTotalVolumeGigabytes();
+        Assert.assertNotNull(maxTotalVolumeGigabytes);
+        
+        Integer totalSecurityGroupsUsed = absolutelimit.getTotalSecurityGroupsUsed();
+        Assert.assertNotNull(totalSecurityGroupsUsed);
+        
+        Integer maxTotalVolumes = absolutelimit.getMaxTotalVolumes();
+        Assert.assertNotNull(maxTotalVolumes);
+        
+        Integer maxImageMeta = absolutelimit.getMaxImageMeta();
+        Assert.assertNotNull(maxImageMeta);
+        
+        Integer imageMetaUsed = absolutelimit.getImageMetaUsed();
+        Assert.assertNotNull(imageMetaUsed);
+        
+        Integer totalVolumeGigabytesUsed = absolutelimit.getTotalVolumeGigabytesUsed();
+        Assert.assertNotNull(totalVolumeGigabytesUsed);
+        
+        Integer maxSecurityGroupRules = absolutelimit.getMaxSecurityGroupRules();
+        Assert.assertNotNull(maxSecurityGroupRules);
+        
+        Integer totalCoresUsed = absolutelimit.getTotalCoresUsed();
+        Assert.assertNotNull(totalCoresUsed);
+        
+        Integer totalVolumesUsed = absolutelimit.getTotalVolumesUsed();
+        Assert.assertNotNull(totalVolumesUsed);
+        
+        Integer maxTotalFloatingIps = absolutelimit.getMaxTotalFloatingIps();
+        Assert.assertNotNull(maxTotalFloatingIps);
+        
+        Integer maxPersonality = absolutelimit.getMaxPersonality();
+        Assert.assertNotNull(maxPersonality);
+        
+        Integer personalityUsed = absolutelimit.getPersonalityUsed();
+        Assert.assertNotNull(personalityUsed);
+        
+        Integer maxSecurityGroups = absolutelimit.getMaxSecurityGroups();
+        Assert.assertNotNull(maxSecurityGroups);
+        
+        Integer securityGroupRulesUsed = absolutelimit.getSecurityGroupRulesUsed();
+        Assert.assertNotNull(securityGroupRulesUsed);
+        
+        Integer maxTotalCores = absolutelimit.getMaxTotalCores();
+        Assert.assertNotNull(maxTotalCores);
+        
+        Integer maxServerMeta = absolutelimit.getMaxServerMeta();
+        Assert.assertNotNull(maxServerMeta);
+        
+        Integer maxPersonalitySize = absolutelimit.getMaxPersonalitySize();
+        Assert.assertNotNull(maxPersonalitySize);
+        
+        Integer personalitySizeUsed = absolutelimit.getPersonalitySizeUsed();
+        Assert.assertNotNull(personalitySizeUsed);
+        
+        Integer totalKeyPairsUsed = absolutelimit.getTotalKeyPairsUsed();
+        Assert.assertNotNull(totalKeyPairsUsed);
+        
+        Integer totalFloatingIpsUsed = absolutelimit.getTotalFloatingIpsUsed();
+        Assert.assertNotNull(totalFloatingIpsUsed);
+        
+        Integer totalInstancesUsed = absolutelimit.getTotalInstancesUsed();
+        Assert.assertNotNull(totalInstancesUsed);
+        
+        Integer totalRAMUsed = absolutelimit.getTotalRAMUsed();
+        Assert.assertNotNull(totalRAMUsed);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/AddressTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/AddressTest.java
new file mode 100644 (file)
index 0000000..45e1f1d
--- /dev/null
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Server.Addresses.Address;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class AddressTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"version\" : \"version\"," + EOL
+        + "  \"addr\" : \"addr\"," + EOL
+        + "  \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "  \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Address.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Address address = objectMapper.readValue(JSON_FULL, Address.class);
+        String json = objectMapper.writeValueAsString(address);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Address address = objectMapper.readValue(JSON_FULL, Address.class);
+        address.toString();
+        
+        String type = address.getType();
+        Assert.assertNotNull(type);
+        address.setType(type);
+        
+        String addr = address.getAddr();
+        Assert.assertNotNull(addr);
+        address.setAddr(addr);
+        
+        String version = address.getVersion();
+        Assert.assertNotNull(version);
+        address.setVersion(version);
+        
+        String macAddr = address.getMacAddr();
+        Assert.assertNotNull(macAddr);
+        address.setMacAddr(macAddr);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/AddressesTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/AddressesTest.java
new file mode 100644 (file)
index 0000000..8449f83
--- /dev/null
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Server.Addresses;
+import com.woorea.openstack.nova.model.Server.Addresses.Address;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class AddressesTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"addresses\" : {" + EOL
+        + "    \"addresses-k1\" : [ {" + EOL
+        + "      \"version\" : \"version\"," + EOL
+        + "      \"addr\" : \"addr\"," + EOL
+        + "      \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "      \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"version\" : \"version\"," + EOL
+        + "      \"addr\" : \"addr\"," + EOL
+        + "      \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "      \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"addresses-k2\" : [ {" + EOL
+        + "      \"version\" : \"version\"," + EOL
+        + "      \"addr\" : \"addr\"," + EOL
+        + "      \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "      \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"version\" : \"version\"," + EOL
+        + "      \"addr\" : \"addr\"," + EOL
+        + "      \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "      \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "    } ]" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Addresses.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Addresses addresses = objectMapper.readValue(JSON_FULL, Addresses.class);
+        String json = objectMapper.writeValueAsString(addresses);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Addresses addresses = objectMapper.readValue(JSON_FULL, Addresses.class);
+        addresses.toString();
+        
+        Map<String,List<Address>> addressesProperty = addresses.getAddresses();
+        Assert.assertNotNull(addressesProperty);
+        Assert.assertEquals(2, addressesProperty.size());
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/AssociateFloatingIpTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/AssociateFloatingIpTest.java
new file mode 100644 (file)
index 0000000..a242728
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class AssociateFloatingIpTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"addFloatingIp\" : {" + EOL
+        + "    \"address\" : \"address\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + AssociateFloatingIp.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        AssociateFloatingIp associatefloatingip = objectMapper.readValue(JSON_FULL, AssociateFloatingIp.class);
+        String json = objectMapper.writeValueAsString(associatefloatingip);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        AssociateFloatingIp associatefloatingip = objectMapper.readValue(JSON_FULL, AssociateFloatingIp.class);
+        associatefloatingip.toString();
+        
+        String address = associatefloatingip.getAddress();
+        Assert.assertNotNull(address);
+        associatefloatingip.setAddress(address);
+    }
+}
index 46d8c2b..24ca40c 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Certificate;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class CertificateTest {
 
-    private Certificate certificate = new Certificate();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"certificate\" : {" + EOL
+        + "    \"data\" : \"data\"," + EOL
+        + "    \"private_key\" : \"privatekey\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getData() {
-        certificate.getData();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Certificate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Certificate certificate = objectMapper.readValue(JSON_FULL, Certificate.class);
+        String json = objectMapper.writeValueAsString(certificate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getPrivateKey() {
-        certificate.getPrivateKey();
+    public void testMethods() throws Exception {
+        Certificate certificate = objectMapper.readValue(JSON_FULL, Certificate.class);
+        certificate.toString();
+        
+        String privateKey = certificate.getPrivateKey();
+        Assert.assertNotNull(privateKey);
+        
+        String data = certificate.getData();
+        Assert.assertNotNull(data);
     }
-
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ChangePasswordTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ChangePasswordTest.java
new file mode 100644 (file)
index 0000000..35a3c8d
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.ChangePassword;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ChangePasswordTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"changePassword\" : {" + EOL
+        + "    \"adminPass\" : \"adminpass\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ChangePassword.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ChangePassword changepassword = objectMapper.readValue(JSON_FULL, ChangePassword.class);
+        String json = objectMapper.writeValueAsString(changepassword);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ChangePassword changepassword = objectMapper.readValue(JSON_FULL, ChangePassword.class);
+        changepassword.toString();
+        
+        String adminPass = changepassword.getAdminPass();
+        Assert.assertNotNull(adminPass);
+        changepassword.setAdminPass(adminPass);
+    }
+}
index a35676f..b59703c 100644 (file)
@@ -1,5 +1,9 @@
 /*-
  * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
-import org.junit.Test;
-
+import com.woorea.openstack.nova.model.Cloudpipe;
 import java.util.Calendar;
-
-import static org.junit.Assert.*;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class CloudpipeTest {
 
-    private Cloudpipe pipe = new Cloudpipe();
-
-    @Test
-    public void getProjectId() {
-        pipe.getProjectId();
-    }
-
-    @Test
-    public void setProjectId() {
-        pipe.setProjectId("1234");
-    }
-
-    @Test
-    public void getInternalIp() {
-        pipe.getInternalIp();
-    }
-
-    @Test
-    public void setInternalIp() {
-        pipe.setInternalIp("123");
-    }
-
-    @Test
-    public void getPublicIp() {
-        pipe.getPublicIp();
-    }
-
-    @Test
-    public void setPublicIp() {
-        pipe.setPublicIp("1234");
-    }
-
-    @Test
-    public void getPublicPort() {
-        pipe.getPublicPort();
-    }
-
-    @Test
-    public void setPublicPort() {
-        pipe.setPublicPort("1234");
-    }
-
-    @Test
-    public void getState() {
-        pipe.getState();
-    }
-
-    @Test
-    public void setState() {
-        pipe.setState("1234");
-    }
-
-    @Test
-    public void getInstanceId() {
-        pipe.getInstanceId();
-    }
-
-    @Test
-    public void setInstanceId() {
-        pipe.setInstanceId("1234");
-    }
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"cloudpipe\" : {" + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"internalIp\" : \"internalip\"," + EOL
+        + "    \"publicIp\" : \"publicip\"," + EOL
+        + "    \"publicPort\" : \"publicport\"," + EOL
+        + "    \"state\" : \"state\"," + EOL
+        + "    \"instanceId\" : \"instanceid\"," + EOL
+        + "    \"createdAt\" : 1486296000000" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getCreatedAt() {
-        pipe.getCreatedAt();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Cloudpipe.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Cloudpipe cloudpipe = objectMapper.readValue(JSON_FULL, Cloudpipe.class);
+        String json = objectMapper.writeValueAsString(cloudpipe);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setCreatedAt() {
-        pipe.setCreatedAt(Calendar.getInstance());
+    public void testMethods() throws Exception {
+        Cloudpipe cloudpipe = objectMapper.readValue(JSON_FULL, Cloudpipe.class);
+        cloudpipe.toString();
+        
+        Calendar createdAt = cloudpipe.getCreatedAt();
+        Assert.assertNotNull(createdAt);
+        cloudpipe.setCreatedAt(createdAt);
+        
+        String instanceId = cloudpipe.getInstanceId();
+        Assert.assertNotNull(instanceId);
+        cloudpipe.setInstanceId(instanceId);
+        
+        String publicIp = cloudpipe.getPublicIp();
+        Assert.assertNotNull(publicIp);
+        cloudpipe.setPublicIp(publicIp);
+        
+        String publicPort = cloudpipe.getPublicPort();
+        Assert.assertNotNull(publicPort);
+        cloudpipe.setPublicPort(publicPort);
+        
+        String state = cloudpipe.getState();
+        Assert.assertNotNull(state);
+        cloudpipe.setState(state);
+        
+        String projectId = cloudpipe.getProjectId();
+        Assert.assertNotNull(projectId);
+        cloudpipe.setProjectId(projectId);
+        
+        String internalIp = cloudpipe.getInternalIp();
+        Assert.assertNotNull(internalIp);
+        cloudpipe.setInternalIp(internalIp);
     }
-}
\ No newline at end of file
+}
index 71cacd1..b7e0b01 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Cloudpipe;
+import com.woorea.openstack.nova.model.Cloudpipes;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class CloudpipesTest {
 
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"cloudpipes\" : [ {" + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"internalIp\" : \"internalip\"," + EOL
+        + "    \"publicIp\" : \"publicip\"," + EOL
+        + "    \"publicPort\" : \"publicport\"," + EOL
+        + "    \"state\" : \"state\"," + EOL
+        + "    \"instanceId\" : \"instanceid\"," + EOL
+        + "    \"createdAt\" : 1486296000000" + EOL
+        + "  }, {" + EOL
+        + "    \"projectId\" : \"projectid\"," + EOL
+        + "    \"internalIp\" : \"internalip\"," + EOL
+        + "    \"publicIp\" : \"publicip\"," + EOL
+        + "    \"publicPort\" : \"publicport\"," + EOL
+        + "    \"state\" : \"state\"," + EOL
+        + "    \"instanceId\" : \"instanceid\"," + EOL
+        + "    \"createdAt\" : 1486296000000" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Cloudpipes.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Cloudpipes cloudpipes = objectMapper.readValue(JSON_FULL, Cloudpipes.class);
+        String json = objectMapper.writeValueAsString(cloudpipes);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
     @Test
-    public void getList() {
-        new Cloudpipes().getList();
+    public void testMethods() throws Exception {
+        Cloudpipes cloudpipes = objectMapper.readValue(JSON_FULL, Cloudpipes.class);
+        cloudpipes.toString();
+        
+        List<Cloudpipe> list = cloudpipes.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
     }
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ConfirmResizeTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ConfirmResizeTest.java
new file mode 100644 (file)
index 0000000..c5710a9
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.ConfirmResize;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ConfirmResizeTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"confirmResize\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ConfirmResize.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ConfirmResize confirmresize = objectMapper.readValue(JSON_FULL, ConfirmResize.class);
+        String json = objectMapper.writeValueAsString(confirmresize);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ConfirmResize confirmresize = objectMapper.readValue(JSON_FULL, ConfirmResize.class);
+        confirmresize.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ConsoleOutputTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ConsoleOutputTest.java
new file mode 100644 (file)
index 0000000..85385d8
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.ConsoleOutput;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ConsoleOutputTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"output\" : \"output\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ConsoleOutput.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ConsoleOutput consoleoutput = objectMapper.readValue(JSON_FULL, ConsoleOutput.class);
+        String json = objectMapper.writeValueAsString(consoleoutput);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ConsoleOutput consoleoutput = objectMapper.readValue(JSON_FULL, ConsoleOutput.class);
+        consoleoutput.toString();
+        
+        String output = consoleoutput.getOutput();
+        Assert.assertNotNull(output);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/CreateBackupTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/CreateBackupTest.java
new file mode 100644 (file)
index 0000000..84b0622
--- /dev/null
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.CreateBackup;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class CreateBackupTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"createBackup\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"rotation\" : \"rotation\"," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"backup_type\" : \"type\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + CreateBackup.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        CreateBackup createbackup = objectMapper.readValue(JSON_FULL, CreateBackup.class);
+        String json = objectMapper.writeValueAsString(createbackup);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        CreateBackup createbackup = objectMapper.readValue(JSON_FULL, CreateBackup.class);
+        createbackup.toString();
+        
+        Map<String,String> metadata = createbackup.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        createbackup.setMetadata(metadata);
+        
+        String rotation = createbackup.getRotation();
+        Assert.assertNotNull(rotation);
+        createbackup.setRotation(rotation);
+        
+        String name = createbackup.getName();
+        Assert.assertNotNull(name);
+        createbackup.setName(name);
+        
+        String type = createbackup.getType();
+        Assert.assertNotNull(type);
+        createbackup.setType(type);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/CreateImageTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/CreateImageTest.java
new file mode 100644 (file)
index 0000000..cd0603d
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.CreateImage;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class CreateImageTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"createImage\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + CreateImage.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        CreateImage createimage = objectMapper.readValue(JSON_FULL, CreateImage.class);
+        String json = objectMapper.writeValueAsString(createimage);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        CreateImage createimage = objectMapper.readValue(JSON_FULL, CreateImage.class);
+        createimage.toString();
+        
+        Map<String,String> metadata = createimage.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        createimage.setMetadata(metadata);
+        
+        String name = createimage.getName();
+        Assert.assertNotNull(name);
+        createimage.setName(name);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/DisassociateFloatingIpTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/DisassociateFloatingIpTest.java
new file mode 100644 (file)
index 0000000..c58daa1
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class DisassociateFloatingIpTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"removeFloatingIp\" : {" + EOL
+        + "    \"address\" : \"address\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + DisassociateFloatingIp.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        DisassociateFloatingIp disassociatefloatingip = objectMapper.readValue(JSON_FULL, DisassociateFloatingIp.class);
+        String json = objectMapper.writeValueAsString(disassociatefloatingip);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        DisassociateFloatingIp disassociatefloatingip = objectMapper.readValue(JSON_FULL, DisassociateFloatingIp.class);
+        disassociatefloatingip.toString();
+        
+        String address = disassociatefloatingip.getAddress();
+        Assert.assertNotNull(address);
+        disassociatefloatingip.setAddress(address);
+    }
+}
index ab27d8c..2047d22 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Extension;
+import com.woorea.openstack.nova.model.Link;
+import java.util.Calendar;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ExtensionTest {
 
-    private Extension extension = new Extension();
-
-    @Test
-    public void getAlias() {
-        extension.getAlias();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getDescription() {
-        extension.getDescription();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"extension\" : {" + EOL
+        + "    \"alias\" : \"alias\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"namespace\" : \"namespace\"," + EOL
+        + "    \"updated\" : 1486468800000," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getName() {
-        extension.getName();
-    }
-
-    @Test
-    public void getNamespace() {
-        extension.getNamespace();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getUpdated() {
-        extension.getUpdated();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Extension.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Extension extension = objectMapper.readValue(JSON_FULL, Extension.class);
+        String json = objectMapper.writeValueAsString(extension);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getLinks() {
-        extension.getLinks();
+    public void testMethods() throws Exception {
+        Extension extension = objectMapper.readValue(JSON_FULL, Extension.class);
+        extension.toString();
+        
+        String name = extension.getName();
+        Assert.assertNotNull(name);
+        
+        String namespace = extension.getNamespace();
+        Assert.assertNotNull(namespace);
+        
+        String alias = extension.getAlias();
+        Assert.assertNotNull(alias);
+        
+        String description = extension.getDescription();
+        Assert.assertNotNull(description);
+        
+        List<Link> links = extension.getLinks();
+        Assert.assertNotNull(links);
+        Assert.assertEquals(2, links.size());
+        
+        Calendar updated = extension.getUpdated();
+        Assert.assertNotNull(updated);
     }
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ExtensionsTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ExtensionsTest.java
new file mode 100644 (file)
index 0000000..56bdf9c
--- /dev/null
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Extension;
+import com.woorea.openstack.nova.model.Extensions;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ExtensionsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"extensions\" : [ {" + EOL
+        + "    \"alias\" : \"alias\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"namespace\" : \"namespace\"," + EOL
+        + "    \"updated\" : 1486468800000," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]" + EOL
+        + "  }, {" + EOL
+        + "    \"alias\" : \"alias\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"namespace\" : \"namespace\"," + EOL
+        + "    \"updated\" : 1486468800000," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Extensions.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Extensions extensions = objectMapper.readValue(JSON_FULL, Extensions.class);
+        String json = objectMapper.writeValueAsString(extensions);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Extensions extensions = objectMapper.readValue(JSON_FULL, Extensions.class);
+        extensions.toString();
+        
+        List<Extension> list = extensions.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Extension x : extensions) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/FaultTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/FaultTest.java
new file mode 100644 (file)
index 0000000..d4d58fb
--- /dev/null
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Server.Fault;
+import java.util.Calendar;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class FaultTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"code\" : 29," + EOL
+        + "  \"message\" : \"message\"," + EOL
+        + "  \"details\" : \"details\"," + EOL
+        + "  \"created\" : 1485172800000" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Fault.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Fault fault = objectMapper.readValue(JSON_FULL, Fault.class);
+        String json = objectMapper.writeValueAsString(fault);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Fault fault = objectMapper.readValue(JSON_FULL, Fault.class);
+        fault.toString();
+        
+        Integer code = fault.getCode();
+        Assert.assertNotNull(code);
+        
+        Calendar created = fault.getCreated();
+        Assert.assertNotNull(created);
+        
+        String details = fault.getDetails();
+        Assert.assertNotNull(details);
+        
+        String message = fault.getMessage();
+        Assert.assertNotNull(message);
+    }
+}
index ebd88b4..578f55a 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.FlavorForCreate;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class FlavorForCreateTest {
 
-    private FlavorForCreate flavor = new FlavorForCreate();
-
-    @Test
-    public void getId() {
-        flavor.getId();
-    }
-
-    @Test
-    public void setId() {
-        flavor.setId("123");
-    }
-
-    @Test
-    public void getName() {
-        flavor.getName();
-    }
-
-    @Test
-    public void setName() {
-        flavor.setName("123");
-    }
-
-    @Test
-    public void getVcpus() {
-        flavor.getVcpus();
-    }
-
-    @Test
-    public void setVcpus() {
-        flavor.setVcpus("123");
-    }
-
-    @Test
-    public void getRam() {
-        flavor.getRam();
-    }
-
-    @Test
-    public void setRam() {
-        flavor.setRam(123);
-    }
-
-    @Test
-    public void getDisk() {
-        flavor.getDisk();
-    }
-
-    @Test
-    public void setDisk() {
-        flavor.setDisk("123");
-    }
-
-    @Test
-    public void getEphemeral() {
-        flavor.getEphemeral();
-    }
-
-    @Test
-    public void setEphemeral() {
-        flavor.setEphemeral(123);
-    }
-
-    @Test
-    public void getSwap() {
-        flavor.getSwap();
-    }
-
-    @Test
-    public void setSwap() {
-        flavor.setSwap("123");
-    }
-
-    @Test
-    public void getRxtxFactor() {
-        flavor.getRxtxFactor();
-    }
-
-    @Test
-    public void setRxtxFactor() {
-        flavor.setRxtxFactor(123.0f);
-    }
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"flavor\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"vcpus\" : \"vcpus\"," + EOL
+        + "    \"ram\" : 38," + EOL
+        + "    \"disk\" : \"disk\"," + EOL
+        + "    \"swap\" : \"swap\"," + EOL
+        + "    \"OS-FLV-EXT-DATA:ephemeral\" : 65," + EOL
+        + "    \"rxtx_factor\" : 11.0" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + FlavorForCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        FlavorForCreate flavorforcreate = objectMapper.readValue(JSON_FULL, FlavorForCreate.class);
+        String json = objectMapper.writeValueAsString(flavorforcreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        FlavorForCreate flavorforcreate = objectMapper.readValue(JSON_FULL, FlavorForCreate.class);
+        flavorforcreate.toString();
+        
+        String disk = flavorforcreate.getDisk();
+        Assert.assertNotNull(disk);
+        flavorforcreate.setDisk(disk);
+        
+        String swap = flavorforcreate.getSwap();
+        Assert.assertNotNull(swap);
+        flavorforcreate.setSwap(swap);
+        
+        String name = flavorforcreate.getName();
+        Assert.assertNotNull(name);
+        flavorforcreate.setName(name);
+        
+        Float rxtxFactor = flavorforcreate.getRxtxFactor();
+        Assert.assertNotNull(rxtxFactor);
+        flavorforcreate.setRxtxFactor(rxtxFactor);
+        
+        Integer ephemeral = flavorforcreate.getEphemeral();
+        Assert.assertNotNull(ephemeral);
+        flavorforcreate.setEphemeral(ephemeral);
+        
+        String id = flavorforcreate.getId();
+        Assert.assertNotNull(id);
+        flavorforcreate.setId(id);
+        
+        String vcpus = flavorforcreate.getVcpus();
+        Assert.assertNotNull(vcpus);
+        flavorforcreate.setVcpus(vcpus);
+        
+        Integer ram = flavorforcreate.getRam();
+        Assert.assertNotNull(ram);
+        flavorforcreate.setRam(ram);
+    }
+}
index cef42fc..d3a369f 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Flavor;
+import com.woorea.openstack.nova.model.Link;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import java.util.Collections;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class FlavorTest {
 
-    private Flavor flavor = new Flavor();
-
-    @Test
-    public void getId() {
-        flavor.getId();
-    }
-
-    @Test
-    public void setId() {
-        flavor.setId("123");
-    }
-
-    @Test
-    public void getName() {
-        flavor.getName();
-    }
-
-    @Test
-    public void setName() {
-        flavor.setName("123");
-    }
-
-    @Test
-    public void getVcpus() {
-        flavor.getVcpus();
-    }
-
-    @Test
-    public void setVcpus() {
-        flavor.setVcpus(123);
-    }
-
-    @Test
-    public void getRam() {
-        flavor.getRam();
-    }
-
-    @Test
-    public void setRam() {
-        flavor.setRam(123);
-    }
-
-    @Test
-    public void getDisk() {
-        flavor.getDisk();
-    }
-
-    @Test
-    public void setDisk() {
-        flavor.setDisk(123);
-    }
-
-    @Test
-    public void getEphemeral() {
-        flavor.getEphemeral();
-    }
-
-    @Test
-    public void setEphemeral() {
-        flavor.setEphemeral(123);
-    }
-
-    @Test
-    public void getSwap() {
-        flavor.getSwap();
-    }
-
-    @Test
-    public void setSwap() {
-        flavor.setSwap("123");
-    }
-
-    @Test
-    public void getRxtxFactor() {
-        flavor.getRxtxFactor();
-    }
-
-    @Test
-    public void setRxtxFactor() {
-        flavor.setRxtxFactor(123.0f);
-    }
-
-    @Test
-    public void getRxtxQuota() {
-        flavor.getRxtxQuota();
-    }
-
-    @Test
-    public void setRxtxQuota() {
-        flavor.setRxtxQuota(123);
-    }
-
-    @Test
-    public void getRxtxCap() {
-        flavor.getRxtxCap();
-    }
-
-    @Test
-    public void setRxtxCap() {
-        flavor.setRxtxCap(123);
-    }
-
-    @Test
-    public void getDisabled() {
-        flavor.getDisabled();
-    }
-
-    @Test
-    public void setDisabled() {
-        flavor.setDisabled(true);
-    }
-
-    @Test
-    public void isPublic() {
-        flavor.isPublic();
-    }
-
-    @Test
-    public void setPublic() {
-        flavor.setPublic(true);
-    }
-
-    @Test
-    public void getLinks() {
-        flavor.getLinks();
-    }
-
-    @Test
-    public void setLinks() {
-        flavor.setLinks(Collections.<Link>emptyList());
-    }
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"flavor\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"vcpus\" : 79," + EOL
+        + "    \"ram\" : 38," + EOL
+        + "    \"disk\" : 45," + EOL
+        + "    \"swap\" : \"swap\"," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"public\" : false," + EOL
+        + "    \"OS-FLV-EXT-DATA:ephemeral\" : 65," + EOL
+        + "    \"rxtx_factor\" : 11.0," + EOL
+        + "    \"OS-FLV-DISABLED:disabled\" : true," + EOL
+        + "    \"rxtx_quota\" : 42," + EOL
+        + "    \"rxtx_cap\" : 96," + EOL
+        + "    \"os-flavor-access:is_public\" : false" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Flavor.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Flavor flavor = objectMapper.readValue(JSON_FULL, Flavor.class);
+        String json = objectMapper.writeValueAsString(flavor);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Flavor flavor = objectMapper.readValue(JSON_FULL, Flavor.class);
+        flavor.toString();
+        
+        Integer rxtxQuota = flavor.getRxtxQuota();
+        Assert.assertNotNull(rxtxQuota);
+        flavor.setRxtxQuota(rxtxQuota);
+        
+        String swap = flavor.getSwap();
+        Assert.assertNotNull(swap);
+        flavor.setSwap(swap);
+        
+        Float rxtxFactor = flavor.getRxtxFactor();
+        Assert.assertNotNull(rxtxFactor);
+        flavor.setRxtxFactor(rxtxFactor);
+        
+        Integer ephemeral = flavor.getEphemeral();
+        Assert.assertNotNull(ephemeral);
+        flavor.setEphemeral(ephemeral);
+        
+        Integer vcpus = flavor.getVcpus();
+        Assert.assertNotNull(vcpus);
+        flavor.setVcpus(vcpus);
+        
+        Integer rxtxCap = flavor.getRxtxCap();
+        Assert.assertNotNull(rxtxCap);
+        flavor.setRxtxCap(rxtxCap);
+        
+        Integer disk = flavor.getDisk();
+        Assert.assertNotNull(disk);
+        flavor.setDisk(disk);
+        
+        String name = flavor.getName();
+        Assert.assertNotNull(name);
+        flavor.setName(name);
+        
+        List<Link> links = flavor.getLinks();
+        Assert.assertNotNull(links);
+        Assert.assertEquals(2, links.size());
+        flavor.setLinks(links);
+        
+        Boolean disabled = flavor.getDisabled();
+        Assert.assertNotNull(disabled);
+        flavor.setDisabled(disabled);
+        
+        String id = flavor.getId();
+        Assert.assertNotNull(id);
+        flavor.setId(id);
+        
+        Integer ram = flavor.getRam();
+        Assert.assertNotNull(ram);
+        flavor.setRam(ram);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/FlavorsTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/FlavorsTest.java
new file mode 100644 (file)
index 0000000..326b11e
--- /dev/null
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Flavor;
+import com.woorea.openstack.nova.model.Flavors;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class FlavorsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"flavors\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"vcpus\" : 79," + EOL
+        + "    \"ram\" : 38," + EOL
+        + "    \"disk\" : 45," + EOL
+        + "    \"swap\" : \"swap\"," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"public\" : false," + EOL
+        + "    \"OS-FLV-EXT-DATA:ephemeral\" : 65," + EOL
+        + "    \"rxtx_factor\" : 11.0," + EOL
+        + "    \"OS-FLV-DISABLED:disabled\" : true," + EOL
+        + "    \"rxtx_quota\" : 42," + EOL
+        + "    \"rxtx_cap\" : 96," + EOL
+        + "    \"os-flavor-access:is_public\" : false" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"vcpus\" : 79," + EOL
+        + "    \"ram\" : 38," + EOL
+        + "    \"disk\" : 45," + EOL
+        + "    \"swap\" : \"swap\"," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"public\" : false," + EOL
+        + "    \"OS-FLV-EXT-DATA:ephemeral\" : 65," + EOL
+        + "    \"rxtx_factor\" : 11.0," + EOL
+        + "    \"OS-FLV-DISABLED:disabled\" : true," + EOL
+        + "    \"rxtx_quota\" : 42," + EOL
+        + "    \"rxtx_cap\" : 96," + EOL
+        + "    \"os-flavor-access:is_public\" : false" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Flavors.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Flavors flavors = objectMapper.readValue(JSON_FULL, Flavors.class);
+        String json = objectMapper.writeValueAsString(flavors);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Flavors flavors = objectMapper.readValue(JSON_FULL, Flavors.class);
+        flavors.toString();
+        
+        List<Flavor> list = flavors.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Flavor x : flavors) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
index 0107cef..02fd66c 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.FloatingIpDomain;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class FloatingIpDomainTest {
 
-    private FloatingIpDomain domain = new FloatingIpDomain();;
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getDomain() {
-        domain.getDomain();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"floating-ip-pool\" : {" + EOL
+        + "    \"domain\" : \"domain\"," + EOL
+        + "    \"scope\" : \"scope\"," + EOL
+        + "    \"project\" : \"project\"," + EOL
+        + "    \"availabilityZone\" : \"availabilityzone\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getScope() {
-        domain.getScope();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getProject() {
-        domain.getProject();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + FloatingIpDomain.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        FloatingIpDomain floatingipdomain = objectMapper.readValue(JSON_FULL, FloatingIpDomain.class);
+        String json = objectMapper.writeValueAsString(floatingipdomain);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getAvailabilityZone() {
-        domain.getAvailabilityZone();
+    public void testMethods() throws Exception {
+        FloatingIpDomain floatingipdomain = objectMapper.readValue(JSON_FULL, FloatingIpDomain.class);
+        floatingipdomain.toString();
+        
+        String domain = floatingipdomain.getDomain();
+        Assert.assertNotNull(domain);
+        
+        String scope = floatingipdomain.getScope();
+        Assert.assertNotNull(scope);
+        
+        String project = floatingipdomain.getProject();
+        Assert.assertNotNull(project);
+        
+        String availabilityZone = floatingipdomain.getAvailabilityZone();
+        Assert.assertNotNull(availabilityZone);
     }
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpDomainsTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpDomainsTest.java
new file mode 100644 (file)
index 0000000..6cc5108
--- /dev/null
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.FloatingIpDomain;
+import com.woorea.openstack.nova.model.FloatingIpDomains;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class FloatingIpDomainsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"domain_entries\" : [ {" + EOL
+        + "    \"domain\" : \"domain\"," + EOL
+        + "    \"scope\" : \"scope\"," + EOL
+        + "    \"project\" : \"project\"," + EOL
+        + "    \"availabilityZone\" : \"availabilityzone\"" + EOL
+        + "  }, {" + EOL
+        + "    \"domain\" : \"domain\"," + EOL
+        + "    \"scope\" : \"scope\"," + EOL
+        + "    \"project\" : \"project\"," + EOL
+        + "    \"availabilityZone\" : \"availabilityzone\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + FloatingIpDomains.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        FloatingIpDomains floatingipdomains = objectMapper.readValue(JSON_FULL, FloatingIpDomains.class);
+        String json = objectMapper.writeValueAsString(floatingipdomains);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        FloatingIpDomains floatingipdomains = objectMapper.readValue(JSON_FULL, FloatingIpDomains.class);
+        floatingipdomains.toString();
+        
+        List<FloatingIpDomain> list = floatingipdomains.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") FloatingIpDomain x : floatingipdomains) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpPoolTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpPoolTest.java
new file mode 100644 (file)
index 0000000..d8dd6c2
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.FloatingIpPools.FloatingIpPool;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class FloatingIpPoolTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"name\" : \"name\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + FloatingIpPool.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        FloatingIpPool floatingippool = objectMapper.readValue(JSON_FULL, FloatingIpPool.class);
+        String json = objectMapper.writeValueAsString(floatingippool);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        FloatingIpPool floatingippool = objectMapper.readValue(JSON_FULL, FloatingIpPool.class);
+        floatingippool.toString();
+        
+        String name = floatingippool.getName();
+        Assert.assertNotNull(name);
+    }
+}
index 334942e..d4dcfd6 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.FloatingIpPools;
+import com.woorea.openstack.nova.model.FloatingIpPools.FloatingIpPool;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class FloatingIpPoolsTest {
 
-    private FloatingIpPools pools = new FloatingIpPools();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"floating_ip_pools\" : [ {" + EOL
+        + "    \"name\" : \"name\"" + EOL
+        + "  }, {" + EOL
+        + "    \"name\" : \"name\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() {
-        pools.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + FloatingIpPools.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        FloatingIpPools floatingippools = objectMapper.readValue(JSON_FULL, FloatingIpPools.class);
+        String json = objectMapper.writeValueAsString(floatingippools);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void iterator() {
-        pools.getList();
+    public void testMethods() throws Exception {
+        FloatingIpPools floatingippools = objectMapper.readValue(JSON_FULL, FloatingIpPools.class);
+        floatingippools.toString();
+        
+        List<FloatingIpPool> list = floatingippools.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") FloatingIpPool x : floatingippools) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-}
\ No newline at end of file
+}
index 968b8bd..f184e83 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.FloatingIp;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class FloatingIpTest {
 
-    private FloatingIp ip = new FloatingIp();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() {
-        ip.getId();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"floating_ip\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"pool\" : \"pool\"," + EOL
+        + "    \"ip\" : \"ip\"," + EOL
+        + "    \"fixed_ip\" : \"fixedip\"," + EOL
+        + "    \"instance_id\" : \"instanceid\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getPool() {
-        ip.getPool();
-    }
-
-    @Test
-    public void getIp() {
-        ip.getIp();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getFixedIp() {
-        ip.getFixedIp();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + FloatingIp.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        FloatingIp floatingip = objectMapper.readValue(JSON_FULL, FloatingIp.class);
+        String json = objectMapper.writeValueAsString(floatingip);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getInstanceId() {
-        ip.getInstanceId();
+    public void testMethods() throws Exception {
+        FloatingIp floatingip = objectMapper.readValue(JSON_FULL, FloatingIp.class);
+        floatingip.toString();
+        
+        String instanceId = floatingip.getInstanceId();
+        Assert.assertNotNull(instanceId);
+        
+        String ip = floatingip.getIp();
+        Assert.assertNotNull(ip);
+        
+        String pool = floatingip.getPool();
+        Assert.assertNotNull(pool);
+        
+        String fixedIp = floatingip.getFixedIp();
+        Assert.assertNotNull(fixedIp);
+        
+        String id = floatingip.getId();
+        Assert.assertNotNull(id);
     }
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpsTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/FloatingIpsTest.java
new file mode 100644 (file)
index 0000000..9cfd3ec
--- /dev/null
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.FloatingIp;
+import com.woorea.openstack.nova.model.FloatingIps;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class FloatingIpsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"floating_ips\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"pool\" : \"pool\"," + EOL
+        + "    \"ip\" : \"ip\"," + EOL
+        + "    \"fixed_ip\" : \"fixedip\"," + EOL
+        + "    \"instance_id\" : \"instanceid\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"pool\" : \"pool\"," + EOL
+        + "    \"ip\" : \"ip\"," + EOL
+        + "    \"fixed_ip\" : \"fixedip\"," + EOL
+        + "    \"instance_id\" : \"instanceid\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + FloatingIps.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        FloatingIps floatingips = objectMapper.readValue(JSON_FULL, FloatingIps.class);
+        String json = objectMapper.writeValueAsString(floatingips);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        FloatingIps floatingips = objectMapper.readValue(JSON_FULL, FloatingIps.class);
+        floatingips.toString();
+        
+        List<FloatingIp> list = floatingips.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") FloatingIp x : floatingips) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ForceDeleteTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ForceDeleteTest.java
new file mode 100644 (file)
index 0000000..87a904c
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.ForceDelete;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ForceDeleteTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"forceDelete\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ForceDelete.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ForceDelete forcedelete = objectMapper.readValue(JSON_FULL, ForceDelete.class);
+        String json = objectMapper.writeValueAsString(forcedelete);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ForceDelete forcedelete = objectMapper.readValue(JSON_FULL, ForceDelete.class);
+        forcedelete.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/GetConsoleOutputTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/GetConsoleOutputTest.java
new file mode 100644 (file)
index 0000000..6293712
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.GetConsoleOutput;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class GetConsoleOutputTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"os-getConsoleOutput\" : {" + EOL
+        + "    \"length\" : 60" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + GetConsoleOutput.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        GetConsoleOutput getconsoleoutput = objectMapper.readValue(JSON_FULL, GetConsoleOutput.class);
+        String json = objectMapper.writeValueAsString(getconsoleoutput);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        GetConsoleOutput getconsoleoutput = objectMapper.readValue(JSON_FULL, GetConsoleOutput.class);
+        getconsoleoutput.toString();
+        
+        Integer length = getconsoleoutput.getLength();
+        Assert.assertNotNull(length);
+        getconsoleoutput.setLength(length);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/GetVncConsoleTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/GetVncConsoleTest.java
new file mode 100644 (file)
index 0000000..0de38d7
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.GetVncConsole;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class GetVncConsoleTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"os-getVNCConsole\" : {" + EOL
+        + "    \"type\" : \"type\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + GetVncConsole.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        GetVncConsole getvncconsole = objectMapper.readValue(JSON_FULL, GetVncConsole.class);
+        String json = objectMapper.writeValueAsString(getvncconsole);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        GetVncConsole getvncconsole = objectMapper.readValue(JSON_FULL, GetVncConsole.class);
+        getvncconsole.toString();
+        
+        String type = getvncconsole.getType();
+        Assert.assertNotNull(type);
+        getvncconsole.setType(type);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/GroupTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/GroupTest.java
new file mode 100644 (file)
index 0000000..3cb1144
--- /dev/null
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.SecurityGroup.Rule.Group;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class GroupTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"name\" : \"name\"," + EOL
+        + "  \"tenant_id\" : \"tenantid\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Group.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Group group = objectMapper.readValue(JSON_FULL, Group.class);
+        String json = objectMapper.writeValueAsString(group);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Group group = objectMapper.readValue(JSON_FULL, Group.class);
+        group.toString();
+        
+        String name = group.getName();
+        Assert.assertNotNull(name);
+        
+        String tenantId = group.getTenantId();
+        Assert.assertNotNull(tenantId);
+    }
+}
index 414ada0..f694e44 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.HostAggregate;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class HostAggregateTest {
 
-    private HostAggregate host = new HostAggregate();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() {
-        host.getId();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"aggregate\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"hosts\" : [ \"hosts-v1\", \"hosts-v2\" ]," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"availability_zone\" : \"availabilityzone\"," + EOL
+        + "    \"created_at\" : \"createdat\"," + EOL
+        + "    \"updated_at\" : \"updatedat\"," + EOL
+        + "    \"deleted_at\" : \"deletedat\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getName() {
-        host.getName();
-    }
-
-    @Test
-    public void getAvailabilityZone() {
-        host.getAvailabilityZone();
-    }
-
-    @Test
-    public void getCreatedAt() {
-        host.getCreatedAt();
-    }
-
-    @Test
-    public void getUpdatedAt() {
-        host.getUpdatedAt();
-    }
-
-    @Test
-    public void getDeletedAt() {
-        host.getDeletedAt();
-    }
-
-    @Test
-    public void getDeleted() {
-        host.getDeleted();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getHosts() {
-        host.getHosts();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + HostAggregate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        HostAggregate hostaggregate = objectMapper.readValue(JSON_FULL, HostAggregate.class);
+        String json = objectMapper.writeValueAsString(hostaggregate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getMetadata() {
-        host.getMetadata();
+    public void testMethods() throws Exception {
+        HostAggregate hostaggregate = objectMapper.readValue(JSON_FULL, HostAggregate.class);
+        hostaggregate.toString();
+        
+        String createdAt = hostaggregate.getCreatedAt();
+        Assert.assertNotNull(createdAt);
+        
+        Map<String,String> metadata = hostaggregate.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        
+        String deletedAt = hostaggregate.getDeletedAt();
+        Assert.assertNotNull(deletedAt);
+        
+        Boolean deleted = hostaggregate.getDeleted();
+        Assert.assertNotNull(deleted);
+        
+        List<String> hosts = hostaggregate.getHosts();
+        Assert.assertNotNull(hosts);
+        Assert.assertEquals(2, hosts.size());
+        
+        String name = hostaggregate.getName();
+        Assert.assertNotNull(name);
+        
+        String id = hostaggregate.getId();
+        Assert.assertNotNull(id);
+        
+        String availabilityZone = hostaggregate.getAvailabilityZone();
+        Assert.assertNotNull(availabilityZone);
+        
+        String updatedAt = hostaggregate.getUpdatedAt();
+        Assert.assertNotNull(updatedAt);
     }
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/HostAggregatesTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/HostAggregatesTest.java
new file mode 100644 (file)
index 0000000..8e97938
--- /dev/null
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.HostAggregate;
+import com.woorea.openstack.nova.model.HostAggregates;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class HostAggregatesTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"aggregates\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"hosts\" : [ \"hosts-v1\", \"hosts-v2\" ]," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"availability_zone\" : \"availabilityzone\"," + EOL
+        + "    \"created_at\" : \"createdat\"," + EOL
+        + "    \"updated_at\" : \"updatedat\"," + EOL
+        + "    \"deleted_at\" : \"deletedat\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"hosts\" : [ \"hosts-v1\", \"hosts-v2\" ]," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"availability_zone\" : \"availabilityzone\"," + EOL
+        + "    \"created_at\" : \"createdat\"," + EOL
+        + "    \"updated_at\" : \"updatedat\"," + EOL
+        + "    \"deleted_at\" : \"deletedat\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + HostAggregates.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        HostAggregates hostaggregates = objectMapper.readValue(JSON_FULL, HostAggregates.class);
+        String json = objectMapper.writeValueAsString(hostaggregates);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        HostAggregates hostaggregates = objectMapper.readValue(JSON_FULL, HostAggregates.class);
+        hostaggregates.toString();
+        
+        List<HostAggregate> list = hostaggregates.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") HostAggregate x : hostaggregates) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
index abf1fc5..424a265 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Hosts.Host;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class HostTest {
 
-    private Host host = new Host();
-    private Host.ResourceWrapper wrapper = new Host.ResourceWrapper();
-    private Host.ResourceWrapper.Resource resource = new Host.ResourceWrapper.Resource();
-
-    @Test
-    public void getHost() {
-        host.getHost();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getResource() {
-        wrapper.getResource();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"zone\" : \"zone\"," + EOL
+        + "  \"service\" : \"service\"," + EOL
+        + "  \"host_name\" : \"hostname\"" + EOL
+        + "}";
 
-    @Test
-    public void getProject() {
-         resource.getProject();
-    }
-
-    @Test
-    public void getMemoryMb() {
-         resource.getMemoryMb();
-    }
-
-    @Test
-    public void getHostResource() {
-         resource.getHost();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getCpu() {
-         resource.getCpu();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Host.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Host host = objectMapper.readValue(JSON_FULL, Host.class);
+        String json = objectMapper.writeValueAsString(host);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getDiskGb() {
-         resource.getDiskGb();
+    public void testMethods() throws Exception {
+        Host host = objectMapper.readValue(JSON_FULL, Host.class);
+        host.toString();
+        
+        String hostName = host.getHostName();
+        Assert.assertNotNull(hostName);
+        
+        String zone = host.getZone();
+        Assert.assertNotNull(zone);
+        host.setZone(zone);
+        
+        String service = host.getService();
+        Assert.assertNotNull(service);
     }
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/HostsTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/HostsTest.java
new file mode 100644 (file)
index 0000000..ae0c6d8
--- /dev/null
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Hosts;
+import com.woorea.openstack.nova.model.Hosts.Host;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class HostsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"hosts\" : [ {" + EOL
+        + "    \"zone\" : \"zone\"," + EOL
+        + "    \"service\" : \"service\"," + EOL
+        + "    \"host_name\" : \"hostname\"" + EOL
+        + "  }, {" + EOL
+        + "    \"zone\" : \"zone\"," + EOL
+        + "    \"service\" : \"service\"," + EOL
+        + "    \"host_name\" : \"hostname\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Hosts.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Hosts hosts = objectMapper.readValue(JSON_FULL, Hosts.class);
+        String json = objectMapper.writeValueAsString(hosts);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Hosts hosts = objectMapper.readValue(JSON_FULL, Hosts.class);
+        hosts.toString();
+        
+        List<Host> list = hosts.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Host x : hosts) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
index 4084d10..2c4b6c4 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.ImageFromVolume;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ImageFromVolumeTest {
 
-    private ImageFromVolume image = new ImageFromVolume();
-
-    @Test
-    public void getId() {
-        image.getId();
-    }
-
-    @Test
-    public void setId() {
-        image.setId("123");
-    }
-
-    @Test
-    public void getUpdates_at() {
-        image.getUpdates_at();
-    }
-
-    @Test
-    public void setUpdates_at() {
-        image.setUpdates_at("123");
-    }
-
-    @Test
-    public void getStatus() {
-        image.getStatus();
-    }
-
-    @Test
-    public void setStatus() {
-        image.setStatus("123");
-    }
-
-    @Test
-    public void getDisplay_description() {
-        image.getDisplay_description();
-    }
-
-    @Test
-    public void setDisplay_description() {
-        image.setDisplay_description("123");
-    }
-
-    @Test
-    public void getSize() {
-        image.getSize();
-    }
-
-    @Test
-    public void setSize() {
-        image.setSize("123");
-    }
-
-    @Test
-    public void getVolume_type() {
-        image.getVolume_type();
-    }
-
-    @Test
-    public void setVolume_type() {
-        image.setVolume_type("123");
-    }
-
-    @Test
-    public void getImage_id() {
-        image.getImage_id();
-    }
-
-    @Test
-    public void setImage_id() {
-        image.setImage_id("123");
-    }
-
-    @Test
-    public void getContainer_format() {
-        image.getContainer_format();
-    }
-
-    @Test
-    public void setContainer_format() {
-        image.setContainer_format("123");
-    }
-
-    @Test
-    public void getDisk_format() {
-        image.getDisk_format();
-    }
-
-    @Test
-    public void setDisk_format() {
-        image.setDisk_format("123");
-    }
-
-    @Test
-    public void getImage_name() {
-        image.getImage_name();
-    }
-
-    @Test
-    public void setImage_name() {
-        image.setImage_name("123");
-    }
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"os-volume_upload_image\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"updates_at\" : \"updates_at\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"display_description\" : \"display_description\"," + EOL
+        + "    \"size\" : \"size\"," + EOL
+        + "    \"volume_type\" : \"volume_type\"," + EOL
+        + "    \"image_id\" : \"image_id\"," + EOL
+        + "    \"container_format\" : \"container_format\"," + EOL
+        + "    \"disk_format\" : \"disk_format\"," + EOL
+        + "    \"image_name\" : \"image_name\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ImageFromVolume.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ImageFromVolume imagefromvolume = objectMapper.readValue(JSON_FULL, ImageFromVolume.class);
+        String json = objectMapper.writeValueAsString(imagefromvolume);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ImageFromVolume imagefromvolume = objectMapper.readValue(JSON_FULL, ImageFromVolume.class);
+        imagefromvolume.toString();
+        
+        String image_name = imagefromvolume.getImage_name();
+        Assert.assertNotNull(image_name);
+        imagefromvolume.setImage_name(image_name);
+        
+        String display_description = imagefromvolume.getDisplay_description();
+        Assert.assertNotNull(display_description);
+        imagefromvolume.setDisplay_description(display_description);
+        
+        String updates_at = imagefromvolume.getUpdates_at();
+        Assert.assertNotNull(updates_at);
+        imagefromvolume.setUpdates_at(updates_at);
+        
+        String volume_type = imagefromvolume.getVolume_type();
+        Assert.assertNotNull(volume_type);
+        imagefromvolume.setVolume_type(volume_type);
+        
+        String size = imagefromvolume.getSize();
+        Assert.assertNotNull(size);
+        imagefromvolume.setSize(size);
+        
+        String disk_format = imagefromvolume.getDisk_format();
+        Assert.assertNotNull(disk_format);
+        imagefromvolume.setDisk_format(disk_format);
+        
+        String id = imagefromvolume.getId();
+        Assert.assertNotNull(id);
+        imagefromvolume.setId(id);
+        
+        String image_id = imagefromvolume.getImage_id();
+        Assert.assertNotNull(image_id);
+        imagefromvolume.setImage_id(image_id);
+        
+        String container_format = imagefromvolume.getContainer_format();
+        Assert.assertNotNull(container_format);
+        imagefromvolume.setContainer_format(container_format);
+        
+        String status = imagefromvolume.getStatus();
+        Assert.assertNotNull(status);
+        imagefromvolume.setStatus(status);
+    }
+}
index 4db1cc1..4fa6869 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
-import org.junit.Test;
-
-import java.io.PrintStream;
+import com.woorea.openstack.nova.model.Image;
+import com.woorea.openstack.nova.model.Image.Server;
+import com.woorea.openstack.nova.model.Link;
 import java.util.Calendar;
-import java.util.Collections;
-
-import static org.junit.Assert.*;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ImageTest {
 
-    private Image image = new Image();
-
-    @Test
-    public void getId() {
-        image.getId();
-    }
-
-    @Test
-    public void setId() {
-        image.setId("123");
-    }
-
-    @Test
-    public void getStatus() {
-        image.getStatus();
-    }
-
-    @Test
-    public void setStatus() {
-        image.setStatus("123");
-    }
-
-    @Test
-    public void getName() {
-        image.setName("123");
-    }
-
-    @Test
-    public void setName() {
-        image.setName("123");
-    }
-
-    @Test
-    public void getProgress() {
-        image.getProgress();
-    }
-
-    @Test
-    public void setProgress() {
-        image.setProgress(123);
-    }
-
-    @Test
-    public void getMinRam() {
-        image.getMinRam();
-    }
-
-    @Test
-    public void setMinRam() {
-        image.setMinRam(123);
-    }
-
-    @Test
-    public void getMinDisk() {
-        image.getMinDisk();
-    }
-
-    @Test
-    public void setMinDisk() {
-        image.setMinDisk(123);
-    }
-
-    @Test
-    public void getCreated() {
-        image.getCreated();
-    }
-
-    @Test
-    public void setCreated() {
-        image.setCreated(Calendar.getInstance());
-    }
-
-    @Test
-    public void getUpdated() {
-        image.getUpdated();
-    }
-
-    @Test
-    public void setUpdated() {
-        image.setUpdated(Calendar.getInstance());
-    }
-
-    @Test
-    public void getMetadata() {
-        image.getMetadata();
-    }
-
-    @Test
-    public void getSize() {
-        image.getSize();
-    }
-
-    @Test
-    public void setMetadata() {
-        image.setMetadata(Collections.<String, String>emptyMap());
-    }
-
-    @Test
-    public void getServer() {
-        image.getServer();
-    }
-
-    @Test
-    public void getLinks() {
-        image.getLinks();
-    }
-
-    @Test
-    public void setLinks() {
-        image.setLinks(Collections.<Link>emptyList());
-    }
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"image\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"progress\" : 3," + EOL
+        + "    \"minRam\" : 62," + EOL
+        + "    \"minDisk\" : 69," + EOL
+        + "    \"created\" : 1485172800000," + EOL
+        + "    \"updated\" : 1486468800000," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"server\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]" + EOL
+        + "    }," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"OS-EXT-IMG-SIZE:size\" : 43" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Image.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Image image = objectMapper.readValue(JSON_FULL, Image.class);
+        String json = objectMapper.writeValueAsString(image);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Image image = objectMapper.readValue(JSON_FULL, Image.class);
+        image.toString();
+        
+        Server server = image.getServer();
+        Assert.assertNotNull(server);
+        
+        Map<String,String> metadata = image.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        image.setMetadata(metadata);
+        
+        Long size = image.getSize();
+        Assert.assertNotNull(size);
+        
+        Calendar created = image.getCreated();
+        Assert.assertNotNull(created);
+        image.setCreated(created);
+        
+        Integer minRam = image.getMinRam();
+        Assert.assertNotNull(minRam);
+        image.setMinRam(minRam);
+        
+        String name = image.getName();
+        Assert.assertNotNull(name);
+        image.setName(name);
+        
+        Integer progress = image.getProgress();
+        Assert.assertNotNull(progress);
+        image.setProgress(progress);
+        
+        List<Link> links = image.getLinks();
+        Assert.assertNotNull(links);
+        Assert.assertEquals(2, links.size());
+        image.setLinks(links);
+        
+        String id = image.getId();
+        Assert.assertNotNull(id);
+        image.setId(id);
+        
+        Calendar updated = image.getUpdated();
+        Assert.assertNotNull(updated);
+        image.setUpdated(updated);
+        
+        Integer minDisk = image.getMinDisk();
+        Assert.assertNotNull(minDisk);
+        image.setMinDisk(minDisk);
+        
+        String status = image.getStatus();
+        Assert.assertNotNull(status);
+        image.setStatus(status);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ImagesTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ImagesTest.java
new file mode 100644 (file)
index 0000000..bd92fb2
--- /dev/null
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Image;
+import com.woorea.openstack.nova.model.Images;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ImagesTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"images\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"progress\" : 3," + EOL
+        + "    \"minRam\" : 62," + EOL
+        + "    \"minDisk\" : 69," + EOL
+        + "    \"created\" : 1485172800000," + EOL
+        + "    \"updated\" : 1486468800000," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"server\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]" + EOL
+        + "    }," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"OS-EXT-IMG-SIZE:size\" : 43" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"progress\" : 3," + EOL
+        + "    \"minRam\" : 62," + EOL
+        + "    \"minDisk\" : 69," + EOL
+        + "    \"created\" : 1485172800000," + EOL
+        + "    \"updated\" : 1486468800000," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"server\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]" + EOL
+        + "    }," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"OS-EXT-IMG-SIZE:size\" : 43" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Images.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Images images = objectMapper.readValue(JSON_FULL, Images.class);
+        String json = objectMapper.writeValueAsString(images);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Images images = objectMapper.readValue(JSON_FULL, Images.class);
+        images.toString();
+        
+        List<Image> list = images.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Image x : images) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/IpRangeTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/IpRangeTest.java
new file mode 100644 (file)
index 0000000..2db77e5
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.SecurityGroup.Rule.IpRange;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class IpRangeTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"cidr\" : \"cidr\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + IpRange.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        IpRange iprange = objectMapper.readValue(JSON_FULL, IpRange.class);
+        String json = objectMapper.writeValueAsString(iprange);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        IpRange iprange = objectMapper.readValue(JSON_FULL, IpRange.class);
+        iprange.toString();
+        
+        String cidr = iprange.getCidr();
+        Assert.assertNotNull(cidr);
+    }
+}
index 31cf096..39a159e 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.KeyPair;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class KeyPairTest {
 
-    private KeyPair pair = new KeyPair();
-
-    @Test
-    public void getName() {
-        pair.getName();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void setName() {
-        pair.setName("123");
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"keypair\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"fingerprint\" : \"fingerprint\"," + EOL
+        + "    \"user_id\" : \"userid\"," + EOL
+        + "    \"public_key\" : \"publickey\"," + EOL
+        + "    \"private_key\" : \"privatekey\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getUserId() {
-        pair.getUserId();
-    }
-
-    @Test
-    public void getPublicKey() {
-        pair.getPublicKey();
-    }
-
-    @Test
-    public void setPublicKey() {
-        pair.setPublicKey("123");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getPrivateKey() {
-        pair.getPrivateKey();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + KeyPair.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        KeyPair keypair = objectMapper.readValue(JSON_FULL, KeyPair.class);
+        String json = objectMapper.writeValueAsString(keypair);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getFingerprint() {
-        pair.getFingerprint();
+    public void testMethods() throws Exception {
+        KeyPair keypair = objectMapper.readValue(JSON_FULL, KeyPair.class);
+        keypair.toString();
+        
+        String privateKey = keypair.getPrivateKey();
+        Assert.assertNotNull(privateKey);
+        
+        String name = keypair.getName();
+        Assert.assertNotNull(name);
+        keypair.setName(name);
+        
+        String fingerprint = keypair.getFingerprint();
+        Assert.assertNotNull(fingerprint);
+        
+        String publicKey = keypair.getPublicKey();
+        Assert.assertNotNull(publicKey);
+        keypair.setPublicKey(publicKey);
+        
+        String userId = keypair.getUserId();
+        Assert.assertNotNull(userId);
     }
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/KeyPairWrapperTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/KeyPairWrapperTest.java
new file mode 100644 (file)
index 0000000..b71cc09
--- /dev/null
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.KeyPair;
+import com.woorea.openstack.nova.model.KeyPairs.KeyPairWrapper;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class KeyPairWrapperTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"keypair\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"fingerprint\" : \"fingerprint\"," + EOL
+        + "    \"user_id\" : \"userid\"," + EOL
+        + "    \"public_key\" : \"publickey\"," + EOL
+        + "    \"private_key\" : \"privatekey\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + KeyPairWrapper.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        KeyPairWrapper keypairwrapper = objectMapper.readValue(JSON_FULL, KeyPairWrapper.class);
+        String json = objectMapper.writeValueAsString(keypairwrapper);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        KeyPairWrapper keypairwrapper = objectMapper.readValue(JSON_FULL, KeyPairWrapper.class);
+        keypairwrapper.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/KeyPairsTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/KeyPairsTest.java
new file mode 100644 (file)
index 0000000..4eb25a8
--- /dev/null
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.KeyPairs;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class KeyPairsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"keypairs\" : [ {" + EOL
+        + "    \"keypair\" : {" + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"fingerprint\" : \"fingerprint\"," + EOL
+        + "      \"user_id\" : \"userid\"," + EOL
+        + "      \"public_key\" : \"publickey\"," + EOL
+        + "      \"private_key\" : \"privatekey\"" + EOL
+        + "    }" + EOL
+        + "  }, {" + EOL
+        + "    \"keypair\" : { " + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"fingerprint\" : \"fingerprint\"," + EOL
+        + "      \"user_id\" : \"userid\"," + EOL
+        + "      \"public_key\" : \"publickey\"," + EOL
+        + "      \"private_key\" : \"privatekey\"" + EOL
+        + "    }" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    // This is test is ignored because The KeyPairs class does not
+    // serialize into JSON correctly.  It is probably not an operational
+    // issue because KeyPairs is only used to represent the response to
+    // the GET os-keypairs request.
+    @Ignore
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + KeyPairs.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        KeyPairs keypairs = objectMapper.readValue(JSON_FULL, KeyPairs.class);
+        String json = objectMapper.writeValueAsString(keypairs);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testGettersAndSetters() throws Exception {
+        KeyPairs keypairs = objectMapper.readValue(JSON_FULL, KeyPairs.class);
+        keypairs.toString();
+
+        List<KeyPair> list = keypairs.getList();
+        Assert.assertNotNull(list);
+
+        int cnt = 0;
+        for (@SuppressWarnings("unused") KeyPair x : keypairs) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/LimitEntryTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/LimitEntryTest.java
new file mode 100644 (file)
index 0000000..2396827
--- /dev/null
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Limits.RateLimit.LimitEntry;
+import java.util.Calendar;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class LimitEntryTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"unit\" : \"unit\"," + EOL
+        + "  \"verb\" : \"verb\"," + EOL
+        + "  \"remaining\" : 72," + EOL
+        + "  \"available\" : 47," + EOL
+        + "  \"value\" : 59," + EOL
+        + "  \"next-available\" : 1489320000000" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + LimitEntry.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        LimitEntry limitentry = objectMapper.readValue(JSON_FULL, LimitEntry.class);
+        String json = objectMapper.writeValueAsString(limitentry);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        LimitEntry limitentry = objectMapper.readValue(JSON_FULL, LimitEntry.class);
+        limitentry.toString();
+        
+        String unit = limitentry.getUnit();
+        Assert.assertNotNull(unit);
+        
+        String verb = limitentry.getVerb();
+        Assert.assertNotNull(verb);
+        
+        Integer available = limitentry.getAvailable();
+        Assert.assertNotNull(available);
+        
+        Calendar nextAvailable = limitentry.getNextAvailable();
+        Assert.assertNotNull(nextAvailable);
+        
+        Integer value = limitentry.getValue();
+        Assert.assertNotNull(value);
+        
+        Integer remaining = limitentry.getRemaining();
+        Assert.assertNotNull(remaining);
+    }
+}
index 2d65192..2977a3a 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
-import org.junit.Test;
-
-import java.util.Calendar;
+import com.woorea.openstack.nova.model.Limits;
+import com.woorea.openstack.nova.model.Limits.AbsoluteLimit;
+import com.woorea.openstack.nova.model.Limits.RateLimit;
 import java.util.List;
-
-import static org.junit.Assert.*;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class LimitsTest {
 
-    private Limits limits = new Limits();
-    private Limits.AbsoluteLimit aLimit = new Limits.AbsoluteLimit();
-    private Limits.RateLimit rLimit = new Limits.RateLimit();
-    private Limits.RateLimit.LimitEntry entry = new Limits.RateLimit.LimitEntry();
-
-    @Test
-    public void getNextAvailable() {
-         entry.getNextAvailable();
-    }
-
-    @Test
-    public void getUnit() {
-         entry.getUnit();
-    }
-
-    @Test
-    public void getVerb() {
-         entry.getVerb();
-    }
-
-    @Test
-    public void getRemaining() {
-         entry.getRemaining();
-    }
-
-    @Test
-    public void getAvailable() {
-         entry.getAvailable();
-    }
-
-    @Test
-    public void getValue() {
-         entry.getValue();
-    }
-
-    @Test
-    public void getRate() {
-        limits.getRate();
-    }
-
-    @Test
-    public void getAbsolute() {
-        limits.getAbsolute();
-    }
-
-    @Test
-    public void getRegex() {
-         rLimit.getRegex();
-    }
-
-    @Test
-    public void getUri() {
-         rLimit.getUri();
-    }
-
-    @Test
-    public void getLimit() {
-         rLimit.getLimit();
-    }
-
-    @Test
-    public void getMaxServerMeta() {
-        aLimit.getMaxServerMeta();
-    }
-
-    @Test
-    public void getMaxPersonality() {
-        aLimit.getMaxPersonality();
-    }
-
-    @Test
-    public void getMaxImageMeta() {
-        aLimit.getMaxImageMeta();
-    }
-
-    @Test
-    public void getMaxPersonalitySize() {
-         aLimit.getMaxPersonalitySize();
-    }
-
-    @Test
-    public void getMaxTotalCores() {
-         aLimit.getMaxTotalCores();
-    }
-
-    @Test
-    public void getMaxTotalInstances() {
-         aLimit.getMaxTotalInstances();
-    }
-
-    @Test
-    public void getMaxTotalRAMSize() {
-         aLimit.getMaxTotalRAMSize();
-    }
-
-    @Test
-    public void getTotalVolumesUsed() {
-         aLimit.getTotalVolumesUsed();
-    }
-
-    @Test
-    public void getMaxSecurityGroupRules() {
-         aLimit.getMaxSecurityGroupRules();
-    }
-
-    @Test
-    public void getMaxTotalKeypairs() {
-         aLimit.getMaxTotalKeypairs();
-    }
-
-    @Test
-    public void getTotalCoresUsed() {
-         aLimit.getTotalCoresUsed();
-    }
-
-    @Test
-    public void getMaxTotalVolumes() {
-         aLimit.getMaxTotalVolumes();
-    }
-
-    @Test
-    public void getTotalRAMUsed() {
-         aLimit.getTotalRAMUsed();
-    }
-
-    @Test
-    public void getTotalInstancesUsed() {
-         aLimit.getTotalInstancesUsed();
-    }
-
-    @Test
-    public void getMaxSecurityGroups() {
-         aLimit.getMaxSecurityGroups();
-    }
-
-    @Test
-    public void getTotalVolumeGigabytesUsed() {
-         aLimit.getTotalVolumeGigabytesUsed();
-    }
-
-    @Test
-    public void getTotalSecurityGroupsUsed() {
-         aLimit.getTotalSecurityGroupsUsed();
-    }
-
-    @Test
-    public void getMaxTotalFloatingIps() {
-         aLimit.getMaxTotalFloatingIps();
-    }
-
-    @Test
-    public void getTotalKeyPairsUsed() {
-         aLimit.getTotalKeyPairsUsed();
-    }
-
-    @Test
-    public void getMaxTotalVolumeGigabytes() {
-         aLimit.getMaxTotalVolumeGigabytes();
-    }
-
-    @Test
-    public void getServerMetaUsed() {
-         aLimit.getServerMetaUsed();
-    }
-
-    @Test
-    public void getPersonalityUsed() {
-         aLimit.getPersonalityUsed();
-    }
-
-    @Test
-    public void getImageMetaUsed() {
-         aLimit.getImageMetaUsed();
-    }
-
-    @Test
-    public void getPersonalitySizeUsed() {
-         aLimit.getPersonalitySizeUsed();
-    }
-
-    @Test
-    public void getSecurityGroupRulesUsed() {
-         aLimit.getSecurityGroupRulesUsed();
-    }
-
-    @Test
-    public void getTotalFloatingIpsUsed() {
-         aLimit.getTotalFloatingIpsUsed();
-    }
-
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"limits\" : {" + EOL
+        + "    \"rate\" : [ {" + EOL
+        + "      \"regex\" : \"regex\"," + EOL
+        + "      \"uri\" : \"uri\"," + EOL
+        + "      \"limit\" : [ {" + EOL
+        + "        \"unit\" : \"unit\"," + EOL
+        + "        \"verb\" : \"verb\"," + EOL
+        + "        \"remaining\" : 72," + EOL
+        + "        \"available\" : 47," + EOL
+        + "        \"value\" : 59," + EOL
+        + "        \"next-available\" : 1489320000000" + EOL
+        + "      }, {" + EOL
+        + "        \"unit\" : \"unit\"," + EOL
+        + "        \"verb\" : \"verb\"," + EOL
+        + "        \"remaining\" : 72," + EOL
+        + "        \"available\" : 47," + EOL
+        + "        \"value\" : 59," + EOL
+        + "        \"next-available\" : 1489320000000" + EOL
+        + "      } ]" + EOL
+        + "    }, {" + EOL
+        + "      \"regex\" : \"regex\"," + EOL
+        + "      \"uri\" : \"uri\"," + EOL
+        + "      \"limit\" : [ {" + EOL
+        + "        \"unit\" : \"unit\"," + EOL
+        + "        \"verb\" : \"verb\"," + EOL
+        + "        \"remaining\" : 72," + EOL
+        + "        \"available\" : 47," + EOL
+        + "        \"value\" : 59," + EOL
+        + "        \"next-available\" : 1489320000000" + EOL
+        + "      }, {" + EOL
+        + "        \"unit\" : \"unit\"," + EOL
+        + "        \"verb\" : \"verb\"," + EOL
+        + "        \"remaining\" : 72," + EOL
+        + "        \"available\" : 47," + EOL
+        + "        \"value\" : 59," + EOL
+        + "        \"next-available\" : 1489320000000" + EOL
+        + "      } ]" + EOL
+        + "    } ]," + EOL
+        + "    \"absolute\" : {" + EOL
+        + "      \"maxServerMeta\" : 30," + EOL
+        + "      \"serverMetaUsed\" : 37," + EOL
+        + "      \"maxPersonality\" : 54," + EOL
+        + "      \"personalityUsed\" : 61," + EOL
+        + "      \"maxImageMeta\" : 82," + EOL
+        + "      \"imageMetaUsed\" : 89," + EOL
+        + "      \"maxPersonalitySize\" : 97," + EOL
+        + "      \"personalitySizeUsed\" : 4," + EOL
+        + "      \"maxTotalCores\" : 32," + EOL
+        + "      \"totalCoresUsed\" : 39," + EOL
+        + "      \"maxTotalInstances\" : 60," + EOL
+        + "      \"totalInstancesUsed\" : 67," + EOL
+        + "      \"maxTotalRAMSize\" : 55," + EOL
+        + "      \"totalRAMUsed\" : 19," + EOL
+        + "      \"maxSecurityGroupRules\" : 44," + EOL
+        + "      \"securityGroupRulesUsed\" : 51," + EOL
+        + "      \"maxTotalKeypairs\" : 64," + EOL
+        + "      \"totalKeyPairsUsed\" : 71," + EOL
+        + "      \"maxTotalVolumes\" : 71," + EOL
+        + "      \"totalVolumesUsed\" : 78," + EOL
+        + "      \"maxSecurityGroups\" : 4," + EOL
+        + "      \"totalSecurityGroupsUsed\" : 59," + EOL
+        + "      \"maxTotalFloatingIps\" : 76," + EOL
+        + "      \"totalFloatingIpsUsed\" : 83," + EOL
+        + "      \"maxTotalVolumeGigabytes\" : 15," + EOL
+        + "      \"totalVolumeGigabytesUsed\" : 22" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Limits.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Limits limits = objectMapper.readValue(JSON_FULL, Limits.class);
+        String json = objectMapper.writeValueAsString(limits);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Limits limits = objectMapper.readValue(JSON_FULL, Limits.class);
+        limits.toString();
+        
+        List<RateLimit> rate = limits.getRate();
+        Assert.assertNotNull(rate);
+        Assert.assertEquals(2, rate.size());
+        
+        AbsoluteLimit absolute = limits.getAbsolute();
+        Assert.assertNotNull(absolute);
+    }
+}
index c1c12cf..81b91a8 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Link;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class LinkTest {
-    private Link link = new Link();
 
-    @Test
-    public void getRel() {
-        link.getRel();
-    }
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"rel\" : \"rel\"," + EOL
+        + "  \"href\" : \"href\"," + EOL
+        + "  \"type\" : \"type\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getHref() {
-        link.getHref();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Link.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Link link = objectMapper.readValue(JSON_FULL, Link.class);
+        String json = objectMapper.writeValueAsString(link);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getType() {
-        link.getType();
+    public void testMethods() throws Exception {
+        Link link = objectMapper.readValue(JSON_FULL, Link.class);
+        link.toString();
+        
+        String rel = link.getRel();
+        Assert.assertNotNull(rel);
+        
+        String href = link.getHref();
+        Assert.assertNotNull(href);
+        
+        String type = link.getType();
+        Assert.assertNotNull(type);
     }
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/LockTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/LockTest.java
new file mode 100644 (file)
index 0000000..aca120e
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Lock;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class LockTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"lock\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Lock.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Lock lock = objectMapper.readValue(JSON_FULL, Lock.class);
+        String json = objectMapper.writeValueAsString(lock);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Lock lock = objectMapper.readValue(JSON_FULL, Lock.class);
+        lock.toString();
+    }
+}
index 83c64e9..e5b379b 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.NetworkForCreate;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class NetworkForCreateTest {
 
-    private NetworkForCreate network = new NetworkForCreate();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() {
-        network.getId();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"uuid\" : \"id\"," + EOL
+        + "  \"fixed_ip\" : \"fixedip\"" + EOL
+        + "}";
 
-    @Test
-    public void getFixedIp() {
-        network.getFixedIp();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void setId() {
-        network.setId("123");
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + NetworkForCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        NetworkForCreate networkforcreate = objectMapper.readValue(JSON_FULL, NetworkForCreate.class);
+        String json = objectMapper.writeValueAsString(networkforcreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setFixedIp() {
-        network.setFixedIp("123");
+    public void testMethods() throws Exception {
+        NetworkForCreate networkforcreate = objectMapper.readValue(JSON_FULL, NetworkForCreate.class);
+        networkforcreate.toString();
+        
+        String fixedIp = networkforcreate.getFixedIp();
+        Assert.assertNotNull(fixedIp);
+        networkforcreate.setFixedIp(fixedIp);
+        
+        String id = networkforcreate.getId();
+        Assert.assertNotNull(id);
+        networkforcreate.setId(id);
     }
-}
\ No newline at end of file
+}
index 2c7a32e..ef4a683 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Network;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class NetworkTest {
 
-    private Network network = new Network();
-
-    @Test
-    public void getId() {
-        network.getId();
-    }
-
-    @Test
-    public void getVpnPublicAddress() {
-        network.getVpnPublicAddress();
-    }
-
-    @Test
-    public void getVpnPublicPort() {
-        network.getVpnPublicPort();
-    }
-
-    @Test
-    public void getDhcpStart() {
-        network.getDhcpStart();
-    }
-
-    @Test
-    public void getBridge() {
-        network.getBridge();
-    }
-
-    @Test
-    public void getBridgeInterface() {
-        network.getBridgeInterface();
-    }
-
-    @Test
-    public void getUpdatedAt() {
-        network.getUpdatedAt();
-    }
-
-    @Test
-    public void getDeleted() {
-        network.getDeleted();
-    }
-
-    @Test
-    public void getVlan() {
-        network.getVlan();
-    }
-
-    @Test
-    public void getBroadcast() {
-        network.getBroadcast();
-    }
-
-    @Test
-    public void getNetmask() {
-        network.getNetmask();
-    }
-
-    @Test
-    public void getInjected() {
-        network.getInjected();
-    }
-
-    @Test
-    public void getHost() {
-        network.getHost();
-    }
-
-    @Test
-    public void getMultiHost() {
-        network.getMultiHost();
-    }
-
-    @Test
-    public void getCreatedAt() {
-        network.getCreatedAt();
-    }
-
-    @Test
-    public void getDeletedAt() {
-        network.getDeletedAt();
-    }
-
-    @Test
-    public void getCidr() {
-        network.getCidr();
-    }
-
-    @Test
-    public void getCidrV6() {
-        network.getCidrV6();
-    }
-
-    @Test
-    public void getGateway() {
-        network.getGateway();
-    }
-
-    @Test
-    public void getGatewayV6() {
-        network.getGatewayV6();
-    }
-
-    @Test
-    public void getNetmaskV6() {
-        network.getNetmaskV6();
-    }
-
-    @Test
-    public void getProjectId() {
-        network.getProjectId();
-    }
-
-    @Test
-    public void getRxtxBase() {
-        network.getRxtxBase();
-    }
-
-    @Test
-    public void getDns1() {
-        network.getDns1();
-    }
-
-    @Test
-    public void getDns2() {
-        network.getDns2();
-    }
-
-    @Test
-    public void getLabel() {
-        network.getLabel();
-    }
-
-    @Test
-    public void getPriority() {
-        network.getPriority();
-    }
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"network\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"bridge\" : \"bridge\"," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"vlan\" : \"vlan\"," + EOL
+        + "    \"broadcast\" : \"broadcast\"," + EOL
+        + "    \"netmask\" : \"netmask\"," + EOL
+        + "    \"injected\" : true," + EOL
+        + "    \"host\" : \"host\"," + EOL
+        + "    \"cidr\" : \"cidr\"," + EOL
+        + "    \"gateway\" : \"gateway\"," + EOL
+        + "    \"dns1\" : \"dns1\"," + EOL
+        + "    \"dns2\" : \"dns2\"," + EOL
+        + "    \"label\" : \"label\"," + EOL
+        + "    \"priority\" : \"priority\"," + EOL
+        + "    \"vpn_public_address\" : \"vpnpublicaddress\"," + EOL
+        + "    \"vpn_private_address\" : \"vpnprivateaddress\"," + EOL
+        + "    \"vpn_public_port\" : \"vpnpublicport\"," + EOL
+        + "    \"dhcp_start\" : \"dhcpstart\"," + EOL
+        + "    \"bridge_interface\" : \"bridgeinterface\"," + EOL
+        + "    \"updated_at\" : \"updatedat\"," + EOL
+        + "    \"multi_host\" : false," + EOL
+        + "    \"created_at\" : \"createdat\"," + EOL
+        + "    \"deleted_at\" : \"deletedat\"," + EOL
+        + "    \"cidr_v6\" : \"cidrv6\"," + EOL
+        + "    \"gateway_v6\" : \"gatewayv6\"," + EOL
+        + "    \"netmask_v6\" : \"netmaskv6\"," + EOL
+        + "    \"project_id\" : \"projectid\"," + EOL
+        + "    \"rxtx_base\" : \"rxtxbase\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Network.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Network network = objectMapper.readValue(JSON_FULL, Network.class);
+        String json = objectMapper.writeValueAsString(network);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Network network = objectMapper.readValue(JSON_FULL, Network.class);
+        network.toString();
+        
+        String broadcast = network.getBroadcast();
+        Assert.assertNotNull(broadcast);
+        
+        String gatewayV6 = network.getGatewayV6();
+        Assert.assertNotNull(gatewayV6);
+        
+        String dns2 = network.getDns2();
+        Assert.assertNotNull(dns2);
+        
+        String bridgeInterface = network.getBridgeInterface();
+        Assert.assertNotNull(bridgeInterface);
+        
+        String dns1 = network.getDns1();
+        Assert.assertNotNull(dns1);
+        
+        String cidrV6 = network.getCidrV6();
+        Assert.assertNotNull(cidrV6);
+        
+        String deletedAt = network.getDeletedAt();
+        Assert.assertNotNull(deletedAt);
+        
+        String vlan = network.getVlan();
+        Assert.assertNotNull(vlan);
+        
+        String netmask = network.getNetmask();
+        Assert.assertNotNull(netmask);
+        
+        String netmaskV6 = network.getNetmaskV6();
+        Assert.assertNotNull(netmaskV6);
+        
+        Boolean injected = network.getInjected();
+        Assert.assertNotNull(injected);
+        
+        String host = network.getHost();
+        Assert.assertNotNull(host);
+        
+        String cidr = network.getCidr();
+        Assert.assertNotNull(cidr);
+        
+        String id = network.getId();
+        Assert.assertNotNull(id);
+        
+        String projectId = network.getProjectId();
+        Assert.assertNotNull(projectId);
+        
+        String vpnPublicAddress = network.getVpnPublicAddress();
+        Assert.assertNotNull(vpnPublicAddress);
+        
+        String label = network.getLabel();
+        Assert.assertNotNull(label);
+        
+        String priority = network.getPriority();
+        Assert.assertNotNull(priority);
+        
+        String vpnPublicPort = network.getVpnPublicPort();
+        Assert.assertNotNull(vpnPublicPort);
+        
+        String createdAt = network.getCreatedAt();
+        Assert.assertNotNull(createdAt);
+        
+        Boolean deleted = network.getDeleted();
+        Assert.assertNotNull(deleted);
+        
+        String rxtxBase = network.getRxtxBase();
+        Assert.assertNotNull(rxtxBase);
+        
+        String dhcpStart = network.getDhcpStart();
+        Assert.assertNotNull(dhcpStart);
+        
+        Boolean multiHost = network.getMultiHost();
+        Assert.assertNotNull(multiHost);
+        
+        String bridge = network.getBridge();
+        Assert.assertNotNull(bridge);
+        
+        String gateway = network.getGateway();
+        Assert.assertNotNull(gateway);
+        
+        String updatedAt = network.getUpdatedAt();
+        Assert.assertNotNull(updatedAt);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/NetworksTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/NetworksTest.java
new file mode 100644 (file)
index 0000000..9268445
--- /dev/null
@@ -0,0 +1,131 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Network;
+import com.woorea.openstack.nova.model.Networks;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class NetworksTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"networks\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"bridge\" : \"bridge\"," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"vlan\" : \"vlan\"," + EOL
+        + "    \"broadcast\" : \"broadcast\"," + EOL
+        + "    \"netmask\" : \"netmask\"," + EOL
+        + "    \"injected\" : true," + EOL
+        + "    \"host\" : \"host\"," + EOL
+        + "    \"cidr\" : \"cidr\"," + EOL
+        + "    \"gateway\" : \"gateway\"," + EOL
+        + "    \"dns1\" : \"dns1\"," + EOL
+        + "    \"dns2\" : \"dns2\"," + EOL
+        + "    \"label\" : \"label\"," + EOL
+        + "    \"priority\" : \"priority\"," + EOL
+        + "    \"vpn_public_address\" : \"vpnpublicaddress\"," + EOL
+        + "    \"vpn_private_address\" : \"vpnprivateaddress\"," + EOL
+        + "    \"vpn_public_port\" : \"vpnpublicport\"," + EOL
+        + "    \"dhcp_start\" : \"dhcpstart\"," + EOL
+        + "    \"bridge_interface\" : \"bridgeinterface\"," + EOL
+        + "    \"updated_at\" : \"updatedat\"," + EOL
+        + "    \"multi_host\" : false," + EOL
+        + "    \"created_at\" : \"createdat\"," + EOL
+        + "    \"deleted_at\" : \"deletedat\"," + EOL
+        + "    \"cidr_v6\" : \"cidrv6\"," + EOL
+        + "    \"gateway_v6\" : \"gatewayv6\"," + EOL
+        + "    \"netmask_v6\" : \"netmaskv6\"," + EOL
+        + "    \"project_id\" : \"projectid\"," + EOL
+        + "    \"rxtx_base\" : \"rxtxbase\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"bridge\" : \"bridge\"," + EOL
+        + "    \"deleted\" : false," + EOL
+        + "    \"vlan\" : \"vlan\"," + EOL
+        + "    \"broadcast\" : \"broadcast\"," + EOL
+        + "    \"netmask\" : \"netmask\"," + EOL
+        + "    \"injected\" : true," + EOL
+        + "    \"host\" : \"host\"," + EOL
+        + "    \"cidr\" : \"cidr\"," + EOL
+        + "    \"gateway\" : \"gateway\"," + EOL
+        + "    \"dns1\" : \"dns1\"," + EOL
+        + "    \"dns2\" : \"dns2\"," + EOL
+        + "    \"label\" : \"label\"," + EOL
+        + "    \"priority\" : \"priority\"," + EOL
+        + "    \"vpn_public_address\" : \"vpnpublicaddress\"," + EOL
+        + "    \"vpn_private_address\" : \"vpnprivateaddress\"," + EOL
+        + "    \"vpn_public_port\" : \"vpnpublicport\"," + EOL
+        + "    \"dhcp_start\" : \"dhcpstart\"," + EOL
+        + "    \"bridge_interface\" : \"bridgeinterface\"," + EOL
+        + "    \"updated_at\" : \"updatedat\"," + EOL
+        + "    \"multi_host\" : false," + EOL
+        + "    \"created_at\" : \"createdat\"," + EOL
+        + "    \"deleted_at\" : \"deletedat\"," + EOL
+        + "    \"cidr_v6\" : \"cidrv6\"," + EOL
+        + "    \"gateway_v6\" : \"gatewayv6\"," + EOL
+        + "    \"netmask_v6\" : \"netmaskv6\"," + EOL
+        + "    \"project_id\" : \"projectid\"," + EOL
+        + "    \"rxtx_base\" : \"rxtxbase\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Networks.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Networks networks = objectMapper.readValue(JSON_FULL, Networks.class);
+        String json = objectMapper.writeValueAsString(networks);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Networks networks = objectMapper.readValue(JSON_FULL, Networks.class);
+        networks.toString();
+        
+        List<Network> list = networks.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Network x : networks) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/PauseTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/PauseTest.java
new file mode 100644 (file)
index 0000000..a5ec89d
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Pause;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class PauseTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"pause\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Pause.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Pause pause = objectMapper.readValue(JSON_FULL, Pause.class);
+        String json = objectMapper.writeValueAsString(pause);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Pause pause = objectMapper.readValue(JSON_FULL, Pause.class);
+        pause.toString();
+    }
+}
index c735995..81cc6ac 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.PersonalityFile;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class PersonalityFileTest {
 
-    private PersonalityFile file = new PersonalityFile();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getPath() {
-        file.getPath();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"path\" : \"path\"," + EOL
+        + "  \"contents\" : \"contents\"" + EOL
+        + "}";
 
-    @Test
-    public void setPath() {
-        file.setPath("123");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getContents() {
-        file.getContents();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + PersonalityFile.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        PersonalityFile personalityfile = objectMapper.readValue(JSON_FULL, PersonalityFile.class);
+        String json = objectMapper.writeValueAsString(personalityfile);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setContents() {
-        file.setContents("123");
+    public void testMethods() throws Exception {
+        PersonalityFile personalityfile = objectMapper.readValue(JSON_FULL, PersonalityFile.class);
+        personalityfile.toString();
+        
+        String path = personalityfile.getPath();
+        Assert.assertNotNull(path);
+        personalityfile.setPath(path);
+        
+        String contents = personalityfile.getContents();
+        Assert.assertNotNull(contents);
+        personalityfile.setContents(contents);
     }
-}
\ No newline at end of file
+}
index 03b0a1f..0a424ed 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.QuotaSet;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class QuotaSetTest {
 
-    private QuotaSet set = new QuotaSet();
-
-    @Test
-    public void getId() {
-        set.getId();
-    }
-
-    @Test
-    public void setId() {
-        set.setId("123");
-    }
-
-    @Test
-    public void getMetadataItems() {
-        set.getMetadataItems();
-    }
-
-    @Test
-    public void setMetadataItems() {
-        set.setMetadataItems(123);
-    }
-
-    @Test
-    public void getInjectedFileContentBytes() {
-        set.getInjectedFileContentBytes();
-    }
-
-    @Test
-    public void setInjectedFileContentBytes() {
-        set.setInjectedFileContentBytes(123);
-    }
-
-    @Test
-    public void getInjectedFiles() {
-        set.getInjectedFiles();
-    }
-
-    @Test
-    public void setInjectedFiles() {
-        set.setInjectedFiles(123);
-    }
-
-    @Test
-    public void getGigabytes() {
-        set.getGigabytes();
-    }
-
-    @Test
-    public void setGigabytes() {
-        set.setGigabytes(123);
-    }
-
-    @Test
-    public void getRam() {
-        set.getRam();
-    }
-
-    @Test
-    public void setRam() {
-        set.setRam(123);
-    }
-
-    @Test
-    public void getFloatingIps() {
-        set.getFloatingIps();
-    }
-
-    @Test
-    public void setFloatingIps() {
-        set.setFloatingIps(123);
-    }
-
-    @Test
-    public void getInstances() {
-        set.getInstances();
-    }
-
-    @Test
-    public void setInstances() {
-        set.setInstances(123);
-    }
-
-    @Test
-    public void getVolumes() {
-        set.getVolumes();
-    }
-
-    @Test
-    public void setVolumes() {
-        set.setVolumes(123);
-    }
-
-    @Test
-    public void getCores() {
-        set.getCores();
-    }
-
-    @Test
-    public void setCores() {
-        set.setCores(123);
-    }
-
-    @Test
-    public void getSecurityGroups() {
-        set.getSecurityGroups();
-    }
-
-    @Test
-    public void setSecurityGroups() {
-        set.setSecurityGroups(123);
-    }
-
-    @Test
-    public void getSecurityGroupRules() {
-        set.getSecurityGroupRules();
-    }
-
-    @Test
-    public void setSecurityGroupRules() {
-        set.setSecurityGroupRules(123);
-    }
-
-    @Test
-    public void getKeyPairs() {
-        set.getKeyPairs();
-    }
-
-    @Test
-    public void setKeyPairs() {
-        set.setKeyPairs(123);
-    }
-
-    @Test
-    public void getInjectedFilePathBytes() {
-        set.getInjectedFilePathBytes();
-    }
-
-    @Test
-    public void setInjectedFilePathBytes() {
-        set.setInjectedFilePathBytes(123);
-    }
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"quota_set\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"gigabytes\" : 77," + EOL
+        + "    \"ram\" : 38," + EOL
+        + "    \"instances\" : 86," + EOL
+        + "    \"volumes\" : 97," + EOL
+        + "    \"cores\" : 58," + EOL
+        + "    \"metadata_items\" : 97," + EOL
+        + "    \"injected_file_content_bytes\" : 86," + EOL
+        + "    \"injected_files\" : 87," + EOL
+        + "    \"floating_ips\" : 2," + EOL
+        + "    \"security_groups\" : 78," + EOL
+        + "    \"security_group_rules\" : 18," + EOL
+        + "    \"injected_file_path_bytes\" : 52," + EOL
+        + "    \"key_pairs\" : 90" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + QuotaSet.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        QuotaSet quotaset = objectMapper.readValue(JSON_FULL, QuotaSet.class);
+        String json = objectMapper.writeValueAsString(quotaset);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        QuotaSet quotaset = objectMapper.readValue(JSON_FULL, QuotaSet.class);
+        quotaset.toString();
+        
+        Integer injectedFileContentBytes = quotaset.getInjectedFileContentBytes();
+        Assert.assertNotNull(injectedFileContentBytes);
+        quotaset.setInjectedFileContentBytes(injectedFileContentBytes);
+        
+        Integer injectedFiles = quotaset.getInjectedFiles();
+        Assert.assertNotNull(injectedFiles);
+        quotaset.setInjectedFiles(injectedFiles);
+        
+        Integer instances = quotaset.getInstances();
+        Assert.assertNotNull(instances);
+        quotaset.setInstances(instances);
+        
+        Integer gigabytes = quotaset.getGigabytes();
+        Assert.assertNotNull(gigabytes);
+        quotaset.setGigabytes(gigabytes);
+        
+        Integer metadataItems = quotaset.getMetadataItems();
+        Assert.assertNotNull(metadataItems);
+        quotaset.setMetadataItems(metadataItems);
+        
+        Integer volumes = quotaset.getVolumes();
+        Assert.assertNotNull(volumes);
+        quotaset.setVolumes(volumes);
+        
+        Integer injectedFilePathBytes = quotaset.getInjectedFilePathBytes();
+        Assert.assertNotNull(injectedFilePathBytes);
+        quotaset.setInjectedFilePathBytes(injectedFilePathBytes);
+        
+        Integer securityGroupRules = quotaset.getSecurityGroupRules();
+        Assert.assertNotNull(securityGroupRules);
+        quotaset.setSecurityGroupRules(securityGroupRules);
+        
+        Integer floatingIps = quotaset.getFloatingIps();
+        Assert.assertNotNull(floatingIps);
+        quotaset.setFloatingIps(floatingIps);
+        
+        Integer cores = quotaset.getCores();
+        Assert.assertNotNull(cores);
+        quotaset.setCores(cores);
+        
+        String id = quotaset.getId();
+        Assert.assertNotNull(id);
+        quotaset.setId(id);
+        
+        Integer securityGroups = quotaset.getSecurityGroups();
+        Assert.assertNotNull(securityGroups);
+        quotaset.setSecurityGroups(securityGroups);
+        
+        Integer ram = quotaset.getRam();
+        Assert.assertNotNull(ram);
+        quotaset.setRam(ram);
+        
+        Integer keyPairs = quotaset.getKeyPairs();
+        Assert.assertNotNull(keyPairs);
+        quotaset.setKeyPairs(keyPairs);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/RateLimitTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/RateLimitTest.java
new file mode 100644 (file)
index 0000000..24553a5
--- /dev/null
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Limits.RateLimit;
+import com.woorea.openstack.nova.model.Limits.RateLimit.LimitEntry;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RateLimitTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"regex\" : \"regex\"," + EOL
+        + "  \"uri\" : \"uri\"," + EOL
+        + "  \"limit\" : [ {" + EOL
+        + "    \"unit\" : \"unit\"," + EOL
+        + "    \"verb\" : \"verb\"," + EOL
+        + "    \"remaining\" : 72," + EOL
+        + "    \"available\" : 47," + EOL
+        + "    \"value\" : 59," + EOL
+        + "    \"next-available\" : 1489320000000" + EOL
+        + "  }, {" + EOL
+        + "    \"unit\" : \"unit\"," + EOL
+        + "    \"verb\" : \"verb\"," + EOL
+        + "    \"remaining\" : 72," + EOL
+        + "    \"available\" : 47," + EOL
+        + "    \"value\" : 59," + EOL
+        + "    \"next-available\" : 1489320000000" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + RateLimit.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        RateLimit ratelimit = objectMapper.readValue(JSON_FULL, RateLimit.class);
+        String json = objectMapper.writeValueAsString(ratelimit);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        RateLimit ratelimit = objectMapper.readValue(JSON_FULL, RateLimit.class);
+        ratelimit.toString();
+        
+        String regex = ratelimit.getRegex();
+        Assert.assertNotNull(regex);
+        
+        List<LimitEntry> limit = ratelimit.getLimit();
+        Assert.assertNotNull(limit);
+        Assert.assertEquals(2, limit.size());
+        
+        String uri = ratelimit.getUri();
+        Assert.assertNotNull(uri);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/RebootTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/RebootTest.java
new file mode 100644 (file)
index 0000000..1a9ea77
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Reboot;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RebootTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"reboot\" : {" + EOL
+        + "    \"type\" : \"type\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Reboot.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Reboot reboot = objectMapper.readValue(JSON_FULL, Reboot.class);
+        String json = objectMapper.writeValueAsString(reboot);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Reboot reboot = objectMapper.readValue(JSON_FULL, Reboot.class);
+        reboot.toString();
+        
+        String type = reboot.getType();
+        Assert.assertNotNull(type);
+        reboot.setType(type);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/RebuildTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/RebuildTest.java
new file mode 100644 (file)
index 0000000..1fb9e86
--- /dev/null
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.PersonalityFile;
+import com.woorea.openstack.nova.model.ServerAction.Rebuild;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RebuildTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"rebuild\" : {" + EOL
+        + "    \"imageRef\" : \"imageref\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"adminPass\" : \"adminpass\"," + EOL
+        + "    \"accessIPv4\" : \"accessipv4\"," + EOL
+        + "    \"accessIPv6\" : \"accessipv6\"," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"personality\" : [ {" + EOL
+        + "      \"path\" : \"path\"," + EOL
+        + "      \"contents\" : \"contents\"" + EOL
+        + "    }, {" + EOL
+        + "      \"path\" : \"path\"," + EOL
+        + "      \"contents\" : \"contents\"" + EOL
+        + "    } ]," + EOL
+        + "    \"OS-DCF:diskConfig\" : \"diskconfig\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Rebuild.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Rebuild rebuild = objectMapper.readValue(JSON_FULL, Rebuild.class);
+        String json = objectMapper.writeValueAsString(rebuild);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Rebuild rebuild = objectMapper.readValue(JSON_FULL, Rebuild.class);
+        rebuild.toString();
+        
+        Map<String,String> metadata = rebuild.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        rebuild.setMetadata(metadata);
+        
+        List<PersonalityFile> personality = rebuild.getPersonality();
+        Assert.assertNotNull(personality);
+        Assert.assertEquals(2, personality.size());
+        rebuild.setPersonality(personality);
+        
+        String name = rebuild.getName();
+        Assert.assertNotNull(name);
+        rebuild.setName(name);
+        
+        String adminPass = rebuild.getAdminPass();
+        Assert.assertNotNull(adminPass);
+        rebuild.setAdminPass(adminPass);
+        
+        String imageRef = rebuild.getImageRef();
+        Assert.assertNotNull(imageRef);
+        rebuild.setImageRef(imageRef);
+        
+        String accessIPv6 = rebuild.getAccessIPv6();
+        Assert.assertNotNull(accessIPv6);
+        rebuild.setAccessIPv6(accessIPv6);
+        
+        String diskConfig = rebuild.getDiskConfig();
+        Assert.assertNotNull(diskConfig);
+        rebuild.setDiskConfig(diskConfig);
+        
+        String accessIPv4 = rebuild.getAccessIPv4();
+        Assert.assertNotNull(accessIPv4);
+        rebuild.setAccessIPv4(accessIPv4);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/RescueResponseTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/RescueResponseTest.java
new file mode 100644 (file)
index 0000000..519e2a3
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.RescueResponse;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RescueResponseTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"adminPass\" : \"adminpass\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + RescueResponse.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        RescueResponse rescueresponse = objectMapper.readValue(JSON_FULL, RescueResponse.class);
+        String json = objectMapper.writeValueAsString(rescueresponse);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        RescueResponse rescueresponse = objectMapper.readValue(JSON_FULL, RescueResponse.class);
+        rescueresponse.toString();
+        
+        String adminPass = rescueresponse.getAdminPass();
+        Assert.assertNotNull(adminPass);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/RescueTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/RescueTest.java
new file mode 100644 (file)
index 0000000..ea14bd2
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Rescue;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RescueTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"rescue\" : {" + EOL
+        + "    \"adminPass\" : \"adminpass\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Rescue.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Rescue rescue = objectMapper.readValue(JSON_FULL, Rescue.class);
+        String json = objectMapper.writeValueAsString(rescue);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Rescue rescue = objectMapper.readValue(JSON_FULL, Rescue.class);
+        rescue.toString();
+        
+        String adminPass = rescue.getAdminPass();
+        Assert.assertNotNull(adminPass);
+        rescue.setAdminPass(adminPass);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ResizeTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ResizeTest.java
new file mode 100644 (file)
index 0000000..05aafd1
--- /dev/null
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Resize;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ResizeTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"resize\" : {" + EOL
+        + "    \"flavorRef\" : \"flavorref\"," + EOL
+        + "    \"OS-DCF:diskConfig\" : \"diskconfig\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Resize.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Resize resize = objectMapper.readValue(JSON_FULL, Resize.class);
+        String json = objectMapper.writeValueAsString(resize);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Resize resize = objectMapper.readValue(JSON_FULL, Resize.class);
+        resize.toString();
+        
+        String flavorRef = resize.getFlavorRef();
+        Assert.assertNotNull(flavorRef);
+        resize.setFlavorRef(flavorRef);
+        
+        String diskConfig = resize.getDiskConfig();
+        Assert.assertNotNull(diskConfig);
+        resize.setDiskConfig(diskConfig);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ResourceTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ResourceTest.java
new file mode 100644 (file)
index 0000000..b075071
--- /dev/null
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Host.ResourceWrapper.Resource;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ResourceTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"project\" : \"project\"," + EOL
+        + "  \"host\" : \"host\"," + EOL
+        + "  \"cpu\" : 46," + EOL
+        + "  \"memory_mb\" : 90," + EOL
+        + "  \"disk_gb\" : 46" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Resource.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Resource resource = objectMapper.readValue(JSON_FULL, Resource.class);
+        String json = objectMapper.writeValueAsString(resource);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Resource resource = objectMapper.readValue(JSON_FULL, Resource.class);
+        resource.toString();
+        
+        Integer memoryMb = resource.getMemoryMb();
+        Assert.assertNotNull(memoryMb);
+        
+        String host = resource.getHost();
+        Assert.assertNotNull(host);
+        
+        String project = resource.getProject();
+        Assert.assertNotNull(project);
+        
+        Integer cpu = resource.getCpu();
+        Assert.assertNotNull(cpu);
+        
+        Integer diskGb = resource.getDiskGb();
+        Assert.assertNotNull(diskGb);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ResourceWrapperTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ResourceWrapperTest.java
new file mode 100644 (file)
index 0000000..b9ab596
--- /dev/null
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.Host.ResourceWrapper;
+import com.woorea.openstack.nova.model.Host.ResourceWrapper.Resource;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ResourceWrapperTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"resource\" : {" + EOL
+        + "    \"project\" : \"project\"," + EOL
+        + "    \"host\" : \"host\"," + EOL
+        + "    \"cpu\" : 46," + EOL
+        + "    \"memory_mb\" : 90," + EOL
+        + "    \"disk_gb\" : 46" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ResourceWrapper.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ResourceWrapper resourcewrapper = objectMapper.readValue(JSON_FULL, ResourceWrapper.class);
+        String json = objectMapper.writeValueAsString(resourcewrapper);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ResourceWrapper resourcewrapper = objectMapper.readValue(JSON_FULL, ResourceWrapper.class);
+        resourcewrapper.toString();
+        
+        Resource resource = resourcewrapper.getResource();
+        Assert.assertNotNull(resource);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/RestoreTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/RestoreTest.java
new file mode 100644 (file)
index 0000000..1b78aac
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Restore;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RestoreTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"restore\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Restore.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Restore restore = objectMapper.readValue(JSON_FULL, Restore.class);
+        String json = objectMapper.writeValueAsString(restore);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Restore restore = objectMapper.readValue(JSON_FULL, Restore.class);
+        restore.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ResumeTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ResumeTest.java
new file mode 100644 (file)
index 0000000..e8b1ff3
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Resume;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ResumeTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"resume\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Resume.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Resume resume = objectMapper.readValue(JSON_FULL, Resume.class);
+        String json = objectMapper.writeValueAsString(resume);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Resume resume = objectMapper.readValue(JSON_FULL, Resume.class);
+        resume.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/RevertResizeTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/RevertResizeTest.java
new file mode 100644 (file)
index 0000000..b3d6d36
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.RevertResize;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RevertResizeTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"revertResize\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + RevertResize.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        RevertResize revertresize = objectMapper.readValue(JSON_FULL, RevertResize.class);
+        String json = objectMapper.writeValueAsString(revertresize);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        RevertResize revertresize = objectMapper.readValue(JSON_FULL, RevertResize.class);
+        revertresize.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/RuleTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/RuleTest.java
new file mode 100644 (file)
index 0000000..0ec78dc
--- /dev/null
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.SecurityGroup.Rule;
+import com.woorea.openstack.nova.model.SecurityGroup.Rule.Group;
+import com.woorea.openstack.nova.model.SecurityGroup.Rule.IpRange;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RuleTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"security_group_rule\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"group\" : {" + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"tenant_id\" : \"tenantid\"" + EOL
+        + "    }," + EOL
+        + "    \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "    \"from_port\" : 7," + EOL
+        + "    \"to_port\" : 98," + EOL
+        + "    \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "    \"ip_range\" : {" + EOL
+        + "      \"cidr\" : \"cidr\"" + EOL
+        + "    }" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Rule.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Rule rule = objectMapper.readValue(JSON_FULL, Rule.class);
+        String json = objectMapper.writeValueAsString(rule);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Rule rule = objectMapper.readValue(JSON_FULL, Rule.class);
+        rule.toString();
+        
+        String parentGroupId = rule.getParentGroupId();
+        Assert.assertNotNull(parentGroupId);
+        
+        String ipProtocol = rule.getIpProtocol();
+        Assert.assertNotNull(ipProtocol);
+        
+        IpRange ipRange = rule.getIpRange();
+        Assert.assertNotNull(ipRange);
+        
+        Integer fromPort = rule.getFromPort();
+        Assert.assertNotNull(fromPort);
+        
+        String name = rule.getName();
+        Assert.assertNotNull(name);
+        
+        String id = rule.getId();
+        Assert.assertNotNull(id);
+        
+        Integer toPort = rule.getToPort();
+        Assert.assertNotNull(toPort);
+        
+        Group group = rule.getGroup();
+        Assert.assertNotNull(group);
+    }
+}
index 9b3001f..71460b4 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.SecurityGroupForCreate;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SecurityGroupForCreateTest {
 
-    SecurityGroupForCreate securityGroupForCreate = new SecurityGroupForCreate();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getName() throws Exception {
-        securityGroupForCreate.getName();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"security_group\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void setName() throws Exception {
-        securityGroupForCreate.setName("test");
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getDescription() throws Exception {
-        securityGroupForCreate.getDescription();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SecurityGroupForCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SecurityGroupForCreate securitygroupforcreate = objectMapper.readValue(JSON_FULL, SecurityGroupForCreate.class);
+        String json = objectMapper.writeValueAsString(securitygroupforcreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setDescription() throws Exception {
-        securityGroupForCreate.setDescription("desc");
+    public void testMethods() throws Exception {
+        SecurityGroupForCreate securitygroupforcreate = objectMapper.readValue(JSON_FULL, SecurityGroupForCreate.class);
+        securitygroupforcreate.toString();
+        
+        String name = securitygroupforcreate.getName();
+        Assert.assertNotNull(name);
+        securitygroupforcreate.setName(name);
+        
+        String description = securitygroupforcreate.getDescription();
+        Assert.assertNotNull(description);
+        securitygroupforcreate.setDescription(description);
     }
-
-}
\ No newline at end of file
+}
index d72094b..ae1dbac 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.SecurityGroupRuleForCreate;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SecurityGroupRuleForCreateTest {
 
-    SecurityGroupRuleForCreate securityGroupRuleForCreate = new SecurityGroupRuleForCreate();
-
-    @Test
-    public void getParentGroupId() throws Exception {
-        securityGroupRuleForCreate.getParentGroupId();
-    }
-
-    @Test
-    public void setParentGroupId() throws Exception {
-        securityGroupRuleForCreate.setParentGroupId("parent");
-    }
-
-    @Test
-    public void setParentGroupId1() throws Exception {
-        securityGroupRuleForCreate.setParentGroupId(1);
-    }
-
-    @Test
-    public void getFromPort() throws Exception {
-        securityGroupRuleForCreate.getFromPort();
-    }
-
-    @Test
-    public void setFromPort() throws Exception {
-        securityGroupRuleForCreate.setFromPort(80);
-    }
-
-    @Test
-    public void getToPort() throws Exception {
-        securityGroupRuleForCreate.getToPort();
-    }
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"security_group_rule\" : {" + EOL
+        + "    \"cidr\" : \"cidr\"," + EOL
+        + "    \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "    \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "    \"from_port\" : 7," + EOL
+        + "    \"to_port\" : 98," + EOL
+        + "    \"group_id\" : \"groupid\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void setToPort() throws Exception {
-        securityGroupRuleForCreate.setToPort(80);
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SecurityGroupRuleForCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SecurityGroupRuleForCreate securitygroupruleforcreate = objectMapper.readValue(JSON_FULL, SecurityGroupRuleForCreate.class);
+        String json = objectMapper.writeValueAsString(securitygroupruleforcreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getIpProtocol() throws Exception {
-        securityGroupRuleForCreate.getIpProtocol();
+    public void testMethods() throws Exception {
+        SecurityGroupRuleForCreate securitygroupruleforcreate = objectMapper.readValue(JSON_FULL, SecurityGroupRuleForCreate.class);
+        securitygroupruleforcreate.toString();
+        
+        String parentGroupId = securitygroupruleforcreate.getParentGroupId();
+        Assert.assertNotNull(parentGroupId);
+        securitygroupruleforcreate.setParentGroupId(parentGroupId);
+        
+        String ipProtocol = securitygroupruleforcreate.getIpProtocol();
+        Assert.assertNotNull(ipProtocol);
+        securitygroupruleforcreate.setIpProtocol(ipProtocol);
+        
+        String groupId = securitygroupruleforcreate.getGroupId();
+        Assert.assertNotNull(groupId);
+        securitygroupruleforcreate.setGroupId(groupId);
+        
+        Integer fromPort = securitygroupruleforcreate.getFromPort();
+        Assert.assertNotNull(fromPort);
+        securitygroupruleforcreate.setFromPort(fromPort);
+        
+        String cidr = securitygroupruleforcreate.getCidr();
+        Assert.assertNotNull(cidr);
+        securitygroupruleforcreate.setCidr(cidr);
+        
+        Integer toPort = securitygroupruleforcreate.getToPort();
+        Assert.assertNotNull(toPort);
+        securitygroupruleforcreate.setToPort(toPort);
     }
-
-    @Test
-    public void setIpProtocol() throws Exception {
-        securityGroupRuleForCreate.setIpProtocol("test");
-    }
-
-    @Test
-    public void getCidr() throws Exception {
-        securityGroupRuleForCreate.getCidr();
-    }
-
-    @Test
-    public void setCidr() throws Exception {
-        securityGroupRuleForCreate.setCidr("test");
-    }
-
-    @Test
-    public void getGroupId() throws Exception {
-        securityGroupRuleForCreate.getGroupId();
-    }
-
-    @Test
-    public void setGroupId() throws Exception {
-        securityGroupRuleForCreate.setGroupId("test");
-    }
-
-    @Test
-    public void setGroupId1() throws Exception {
-        securityGroupRuleForCreate.setGroupId(1);
-    }
-
-}
\ No newline at end of file
+}
index e238c4e..5bcc32a 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.ServerForCreate.SecurityGroup;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SecurityGroupTest {
 
-    SecurityGroup securityGroup = new SecurityGroup();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getId() throws Exception {
-        securityGroup.getId();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"name\" : \"name\"" + EOL
+        + "}";
 
-    @Test
-    public void getName() throws Exception {
-        securityGroup.getName();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getDescription() throws Exception {
-        securityGroup.getDescription();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SecurityGroup.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SecurityGroup securitygroup = objectMapper.readValue(JSON_FULL, SecurityGroup.class);
+        String json = objectMapper.writeValueAsString(securitygroup);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getTenantId() throws Exception {
-        securityGroup.getTenantId();
+    public void testMethods() throws Exception {
+        SecurityGroup securitygroup = objectMapper.readValue(JSON_FULL, SecurityGroup.class);
+        securitygroup.toString();
+        
+        String name = securitygroup.getName();
+        Assert.assertNotNull(name);
+        securitygroup.setName(name);
     }
-
-    @Test
-    public void getRules() throws Exception {
-        securityGroup.getRules();
-    }
-
-    @Test
-    public void getLinks() throws Exception {
-        securityGroup.getLinks();
-    }
-
-}
\ No newline at end of file
+}
index c5ecf89..f3446f2 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.SecurityGroup;
+import com.woorea.openstack.nova.model.SecurityGroups;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SecurityGroupsTest {
 
-    SecurityGroups securityGroups = new SecurityGroups();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"security_groups\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"rules\" : [ {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"group\" : {" + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"tenant_id\" : \"tenantid\"" + EOL
+        + "      }," + EOL
+        + "      \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "      \"from_port\" : 7," + EOL
+        + "      \"to_port\" : 98," + EOL
+        + "      \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "      \"ip_range\" : {" + EOL
+        + "        \"cidr\" : \"cidr\"" + EOL
+        + "      }" + EOL
+        + "    }, {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"group\" : {" + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"tenant_id\" : \"tenantid\"" + EOL
+        + "      }," + EOL
+        + "      \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "      \"from_port\" : 7," + EOL
+        + "      \"to_port\" : 98," + EOL
+        + "      \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "      \"ip_range\" : {" + EOL
+        + "        \"cidr\" : \"cidr\"" + EOL
+        + "      }" + EOL
+        + "    } ]," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"tenant_id\" : \"tenantid\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"description\" : \"description\"," + EOL
+        + "    \"rules\" : [ {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"group\" : {" + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"tenant_id\" : \"tenantid\"" + EOL
+        + "      }," + EOL
+        + "      \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "      \"from_port\" : 7," + EOL
+        + "      \"to_port\" : 98," + EOL
+        + "      \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "      \"ip_range\" : {" + EOL
+        + "        \"cidr\" : \"cidr\"" + EOL
+        + "      }" + EOL
+        + "    }, {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"group\" : {" + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"tenant_id\" : \"tenantid\"" + EOL
+        + "      }," + EOL
+        + "      \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "      \"from_port\" : 7," + EOL
+        + "      \"to_port\" : 98," + EOL
+        + "      \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "      \"ip_range\" : {" + EOL
+        + "        \"cidr\" : \"cidr\"" + EOL
+        + "      }" + EOL
+        + "    } ]," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"tenant_id\" : \"tenantid\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        securityGroups.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SecurityGroups.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SecurityGroups securitygroups = objectMapper.readValue(JSON_FULL, SecurityGroups.class);
+        String json = objectMapper.writeValueAsString(securitygroups);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        securityGroups.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        SecurityGroups securitygroups = objectMapper.readValue(JSON_FULL, SecurityGroups.class);
+        securitygroups.toString();
+        
+        List<SecurityGroup> list = securitygroups.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") SecurityGroup x : securitygroups) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index ce7b4a2..2653f02 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.NetworkForCreate;
+import com.woorea.openstack.nova.model.PersonalityFile;
+import com.woorea.openstack.nova.model.ServerForCreate;
+import com.woorea.openstack.nova.model.ServerForCreate.SecurityGroup;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import java.util.Collections;
-import java.util.HashMap;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ServerForCreateTest {
 
-    ServerForCreate serverForCreate = new ServerForCreate();
-
-    @Test
-    public void getName() throws Exception {
-        serverForCreate.getName();
-    }
-
-    @Test
-    public void setName() throws Exception {
-        serverForCreate.setName("test");
-    }
-
-    @Test
-    public void getAdminPass() throws Exception {
-        serverForCreate.getAdminPass();
-    }
-
-    @Test
-    public void setAdminPass() throws Exception {
-        serverForCreate.setAdminPass("adminpass");
-    }
-
-    @Test
-    public void getImageRef() throws Exception {
-        serverForCreate.getImageRef();
-    }
-
-    @Test
-    public void setImageRef() throws Exception {
-        serverForCreate.setImageRef("image");
-    }
-
-    @Test
-    public void getFlavorRef() throws Exception {
-        serverForCreate.getFlavorRef();
-    }
-
-    @Test
-    public void setFlavorRef() throws Exception {
-        serverForCreate.setFlavorRef("test");
-    }
-
-    @Test
-    public void getAccessIPv4() throws Exception {
-        serverForCreate.getAccessIPv4();
-    }
-
-    @Test
-    public void setAccessIPv4() throws Exception {
-        serverForCreate.setAccessIPv4("test");
-    }
-
-    @Test
-    public void getAccessIPv6() throws Exception {
-        serverForCreate.getAccessIPv6();
-    }
-
-    @Test
-    public void setAccessIPv6() throws Exception {
-        serverForCreate.setAccessIPv6("ipv6");
-    }
-
-    @Test
-    public void getMin() throws Exception {
-        serverForCreate.getMin();
-    }
-
-    @Test
-    public void setMin() throws Exception {
-        serverForCreate.setMin(1);
-    }
-
-    @Test
-    public void getMax() throws Exception {
-        serverForCreate.setMax(2);
-    }
-
-    @Test
-    public void setMax() throws Exception {
-        serverForCreate.setMax(2);
-    }
-
-    @Test
-    public void getDiskConfig() throws Exception {
-        serverForCreate.getDiskConfig();
-    }
-
-    @Test
-    public void setDiskConfig() throws Exception {
-        serverForCreate.setDiskConfig("config");
-    }
-
-    @Test
-    public void getKeyName() throws Exception {
-        serverForCreate.getKeyName();
-    }
-
-    @Test
-    public void setKeyName() throws Exception {
-        serverForCreate.setKeyName("test");
-    }
-
-    @Test
-    public void getPersonality() throws Exception {
-        serverForCreate.getPersonality();
-    }
-
-    @Test
-    public void setPersonality() throws Exception {
-        serverForCreate.setPersonality(Collections.<PersonalityFile>emptyList());
-    }
-
-    @Test
-    public void getMetadata() throws Exception {
-        serverForCreate.getMetadata();
-    }
-
-    @Test
-    public void setMetadata() throws Exception {
-        serverForCreate.setMetadata(new HashMap<String, String>());
-    }
-
-    @Test
-    public void getSecurityGroups() throws Exception {
-        serverForCreate.getSecurityGroups();
-    }
-
-    @Test
-    public void getUserData() throws Exception {
-        serverForCreate.getUserData();
-    }
-
-    @Test
-    public void setUserData() throws Exception {
-        serverForCreate.setUserData("test");
-    }
-
-    @Test
-    public void getAvailabilityZone() throws Exception {
-        serverForCreate.getAvailabilityZone();
-    }
-
-    @Test
-    public void setAvailabilityZone() throws Exception {
-        serverForCreate.setAvailabilityZone("test");
-    }
-
-    @Test
-    public void isConfigDrive() throws Exception {
-        serverForCreate.isConfigDrive();
-    }
-
-    @Test
-    public void setConfigDrive() throws Exception {
-        serverForCreate.setConfigDrive(true);
-    }
-
-    @Test
-    public void getNetworks() throws Exception {
-        serverForCreate.getNetworks();
-    }
-
-    @Test
-    public void setNetworks() throws Exception {
-        serverForCreate.setNetworks(Collections.<NetworkForCreate>emptyList());
-    }
-
-    @Test
-    public void addNetworks() throws Exception {
-        serverForCreate.addNetworks("test", "localhost");
-    }
-
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"server\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"adminPass\" : \"adminpass\"," + EOL
+        + "    \"imageRef\" : \"imageref\"," + EOL
+        + "    \"flavorRef\" : \"flavorref\"," + EOL
+        + "    \"accessIPv4\" : \"accessipv4\"," + EOL
+        + "    \"accessIPv6\" : \"accessipv6\"," + EOL
+        + "    \"min\" : 42," + EOL
+        + "    \"max\" : 44," + EOL
+        + "    \"diskConfig\" : \"diskconfig\"," + EOL
+        + "    \"personality\" : [ {" + EOL
+        + "      \"path\" : \"path\"," + EOL
+        + "      \"contents\" : \"contents\"" + EOL
+        + "    }, {" + EOL
+        + "      \"path\" : \"path\"," + EOL
+        + "      \"contents\" : \"contents\"" + EOL
+        + "    } ]," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"networks\" : [ {" + EOL
+        + "      \"uuid\" : \"id\"," + EOL
+        + "      \"fixed_ip\" : \"fixedip\"" + EOL
+        + "    }, {" + EOL
+        + "      \"uuid\" : \"id\"," + EOL
+        + "      \"fixed_ip\" : \"fixedip\"" + EOL
+        + "    } ]," + EOL
+        + "    \"key_name\" : \"keyname\"," + EOL
+        + "    \"security_groups\" : [ {" + EOL
+        + "      \"name\" : \"name\"" + EOL
+        + "    }, {" + EOL
+        + "      \"name\" : \"name\"" + EOL
+        + "    } ]," + EOL
+        + "    \"user_data\" : \"userdata\"," + EOL
+        + "    \"availability_zone\" : \"availabilityzone\"," + EOL
+        + "    \"config_drive\" : true" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ServerForCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ServerForCreate serverforcreate = objectMapper.readValue(JSON_FULL, ServerForCreate.class);
+        String json = objectMapper.writeValueAsString(serverforcreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ServerForCreate serverforcreate = objectMapper.readValue(JSON_FULL, ServerForCreate.class);
+        serverforcreate.toString();
+        
+        Map<String,String> metadata = serverforcreate.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        serverforcreate.setMetadata(metadata);
+        
+        Integer max = serverforcreate.getMax();
+        Assert.assertNotNull(max);
+        serverforcreate.setMax(max);
+        
+        List<NetworkForCreate> networks = serverforcreate.getNetworks();
+        Assert.assertNotNull(networks);
+        Assert.assertEquals(2, networks.size());
+        serverforcreate.setNetworks(networks);
+        
+        String userData = serverforcreate.getUserData();
+        Assert.assertNotNull(userData);
+        serverforcreate.setUserData(userData);
+        
+        Integer min = serverforcreate.getMin();
+        Assert.assertNotNull(min);
+        serverforcreate.setMin(min);
+        
+        List<PersonalityFile> personality = serverforcreate.getPersonality();
+        Assert.assertNotNull(personality);
+        Assert.assertEquals(2, personality.size());
+        serverforcreate.setPersonality(personality);
+        
+        String name = serverforcreate.getName();
+        Assert.assertNotNull(name);
+        serverforcreate.setName(name);
+        
+        String flavorRef = serverforcreate.getFlavorRef();
+        Assert.assertNotNull(flavorRef);
+        serverforcreate.setFlavorRef(flavorRef);
+        
+        String keyName = serverforcreate.getKeyName();
+        Assert.assertNotNull(keyName);
+        serverforcreate.setKeyName(keyName);
+        
+        String adminPass = serverforcreate.getAdminPass();
+        Assert.assertNotNull(adminPass);
+        serverforcreate.setAdminPass(adminPass);
+        
+        String imageRef = serverforcreate.getImageRef();
+        Assert.assertNotNull(imageRef);
+        serverforcreate.setImageRef(imageRef);
+        
+        String accessIPv6 = serverforcreate.getAccessIPv6();
+        Assert.assertNotNull(accessIPv6);
+        serverforcreate.setAccessIPv6(accessIPv6);
+        
+        String diskConfig = serverforcreate.getDiskConfig();
+        Assert.assertNotNull(diskConfig);
+        serverforcreate.setDiskConfig(diskConfig);
+        
+        List<SecurityGroup> securityGroups = serverforcreate.getSecurityGroups();
+        Assert.assertNotNull(securityGroups);
+        Assert.assertEquals(2, securityGroups.size());
+        
+        String availabilityZone = serverforcreate.getAvailabilityZone();
+        Assert.assertNotNull(availabilityZone);
+        serverforcreate.setAvailabilityZone(availabilityZone);
+        
+        String accessIPv4 = serverforcreate.getAccessIPv4();
+        Assert.assertNotNull(accessIPv4);
+        serverforcreate.setAccessIPv4(accessIPv4);
+    }
+}
index e7658c1..3aa4833 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Flavor;
+import com.woorea.openstack.nova.model.Image;
+import com.woorea.openstack.nova.model.Link;
+import com.woorea.openstack.nova.model.SecurityGroup;
+import com.woorea.openstack.nova.model.Server;
+import com.woorea.openstack.nova.model.Server.Addresses;
+import com.woorea.openstack.nova.model.Server.Fault;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ServerTest {
 
-    Server server = new Server();
-
-    @Test
-    public void getId() throws Exception {
-        server.getId();
-    }
-
-    @Test
-    public void getName() throws Exception {
-        server.getName();
-    }
-
-    @Test
-    public void getAddresses() throws Exception {
-        server.getAddresses();
-    }
-
-    @Test
-    public void getLinks() throws Exception {
-        server.getLinks();
-    }
-
-    @Test
-    public void getImage() throws Exception {
-        server.getImage();
-    }
-
-    @Test
-    public void setImage() throws Exception {
-        server.setImage(new Image());
-    }
-
-    @Test
-    public void getFlavor() throws Exception {
-        server.getFlavor();
-    }
-
-    @Test
-    public void setFlavor() throws Exception {
-        server.setFlavor(new Flavor());
-    }
-
-    @Test
-    public void getAccessIPv4() throws Exception {
-        server.getAccessIPv4();
-    }
-
-    @Test
-    public void getAccessIPv6() throws Exception {
-        server.getAccessIPv6();
-    }
-
-    @Test
-    public void getConfigDrive() throws Exception {
-        server.getConfigDrive();
-    }
-
-    @Test
-    public void getStatus() throws Exception {
-        server.getStatus();
-    }
-
-    @Test
-    public void getProgress() throws Exception {
-        server.getProgress();
-    }
-
-    @Test
-    public void getFault() throws Exception {
-        server.getFault();
-    }
-
-    @Test
-    public void getTenantId() throws Exception {
-        server.getTenantId();
-    }
-
-    @Test
-    public void getUserId() throws Exception {
-        server.getUserId();
-    }
-
-    @Test
-    public void getKeyName() throws Exception {
-        server.getKeyName();
-    }
-
-    @Test
-    public void getHostId() throws Exception {
-        server.getHostId();
-    }
-
-    @Test
-    public void getUpdated() throws Exception {
-        server.getUpdated();
-    }
-
-    @Test
-    public void getCreated() throws Exception {
-        server.getCreated();
-    }
-
-    @Test
-    public void getMetadata() throws Exception {
-        server.getMetadata();
-    }
-
-    @Test
-    public void getSecurityGroups() throws Exception {
-        server.getSecurityGroups();
-    }
-
-    @Test
-    public void getTaskState() throws Exception {
-        server.getTaskState();
-    }
-
-    @Test
-    public void getPowerState() throws Exception {
-        server.getPowerState();
-    }
-
-    @Test
-    public void getVmState() throws Exception {
-        server.getVmState();
-    }
-
-    @Test
-    public void getHost() throws Exception {
-        server.getHost();
-    }
-
-    @Test
-    public void getInstanceName() throws Exception {
-        server.getInstanceName();
-    }
-
-    @Test
-    public void getHypervisorHostname() throws Exception {
-        server.getHypervisorHostname();
-    }
-
-    @Test
-    public void getDiskConfig() throws Exception {
-        server.getDiskConfig();
-    }
-
-    @Test
-    public void getAvailabilityZone() throws Exception {
-        server.getAvailabilityZone();
-    }
-
-    @Test
-    public void getLaunchedAt() throws Exception {
-        server.getLaunchedAt();
-    }
-
-    @Test
-    public void getTerminatedAt() throws Exception {
-        server.getTerminatedAt();
-    }
-
-    @Test
-    public void getOsExtendedVolumesAttached() throws Exception {
-        server.getOsExtendedVolumesAttached();
-    }
-
-    @Test
-    public void getUuid() throws Exception {
-        server.getUuid();
-    }
-
-    @Test
-    public void getAdminPass() throws Exception {
-        server.getAdminPass();
-    }
-
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"server\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"addresses\" : {" + EOL
+        + "      \"addresses\" : {" + EOL
+        + "        \"addresses-k1\" : [ {" + EOL
+        + "          \"version\" : \"version\"," + EOL
+        + "          \"addr\" : \"addr\"," + EOL
+        + "          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "          \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "        }, {" + EOL
+        + "          \"version\" : \"version\"," + EOL
+        + "          \"addr\" : \"addr\"," + EOL
+        + "          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "          \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "        } ]," + EOL
+        + "        \"addresses-k2\" : [ {" + EOL
+        + "          \"version\" : \"version\"," + EOL
+        + "          \"addr\" : \"addr\"," + EOL
+        + "          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "          \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "        }, {" + EOL
+        + "          \"version\" : \"version\"," + EOL
+        + "          \"addr\" : \"addr\"," + EOL
+        + "          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL
+        + "          \"OS-EXT-IPS:type\" : \"type\"" + EOL
+        + "        } ]" + EOL
+        + "      }" + EOL
+        + "    }," + EOL
+        + "    \"links\" : [ {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    }, {" + EOL
+        + "      \"rel\" : \"rel\"," + EOL
+        + "      \"href\" : \"href\"," + EOL
+        + "      \"type\" : \"type\"" + EOL
+        + "    } ]," + EOL
+        + "    \"image\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"status\" : \"status\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"progress\" : 3," + EOL
+        + "      \"minRam\" : 62," + EOL
+        + "      \"minDisk\" : 69," + EOL
+        + "      \"created\" : 1485172800000," + EOL
+        + "      \"updated\" : 1486468800000," + EOL
+        + "      \"metadata\" : {" + EOL
+        + "        \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "        \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "      }," + EOL
+        + "      \"server\" : {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"links\" : [ {" + EOL
+        + "          \"rel\" : \"rel\"," + EOL
+        + "          \"href\" : \"href\"," + EOL
+        + "          \"type\" : \"type\"" + EOL
+        + "        }, {" + EOL
+        + "          \"rel\" : \"rel\"," + EOL
+        + "          \"href\" : \"href\"," + EOL
+        + "          \"type\" : \"type\"" + EOL
+        + "        } ]" + EOL
+        + "      }," + EOL
+        + "      \"links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]," + EOL
+        + "      \"OS-EXT-IMG-SIZE:size\" : 43" + EOL
+        + "    }," + EOL
+        + "    \"flavor\" : {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"vcpus\" : 79," + EOL
+        + "      \"ram\" : 38," + EOL
+        + "      \"disk\" : 45," + EOL
+        + "      \"swap\" : \"swap\"," + EOL
+        + "      \"links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]," + EOL
+        + "      \"public\" : false," + EOL
+        + "      \"OS-FLV-EXT-DATA:ephemeral\" : 65," + EOL
+        + "      \"rxtx_factor\" : 11.0," + EOL
+        + "      \"OS-FLV-DISABLED:disabled\" : true," + EOL
+        + "      \"rxtx_quota\" : 42," + EOL
+        + "      \"rxtx_cap\" : 96," + EOL
+        + "      \"os-flavor-access:is_public\" : false" + EOL
+        + "    }," + EOL
+        + "    \"accessIPv4\" : \"accessipv4\"," + EOL
+        + "    \"accessIPv6\" : \"accessipv6\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"progress\" : 3," + EOL
+        + "    \"fault\" : {" + EOL
+        + "      \"code\" : 29," + EOL
+        + "      \"message\" : \"message\"," + EOL
+        + "      \"details\" : \"details\"," + EOL
+        + "      \"created\" : 1485172800000" + EOL
+        + "    }," + EOL
+        + "    \"hostId\" : \"hostid\"," + EOL
+        + "    \"updated\" : \"updated\"," + EOL
+        + "    \"created\" : \"created\"," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"uuid\" : \"uuid\"," + EOL
+        + "    \"adminPass\" : \"adminpass\"," + EOL
+        + "    \"config_drive\" : \"configdrive\"," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"user_id\" : \"userid\"," + EOL
+        + "    \"key_name\" : \"keyname\"," + EOL
+        + "    \"security_groups\" : [ {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"description\" : \"description\"," + EOL
+        + "      \"rules\" : [ {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"group\" : {" + EOL
+        + "          \"name\" : \"name\"," + EOL
+        + "          \"tenant_id\" : \"tenantid\"" + EOL
+        + "        }," + EOL
+        + "        \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "        \"from_port\" : 7," + EOL
+        + "        \"to_port\" : 98," + EOL
+        + "        \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "        \"ip_range\" : {" + EOL
+        + "          \"cidr\" : \"cidr\"" + EOL
+        + "        }" + EOL
+        + "      }, {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"group\" : {" + EOL
+        + "          \"name\" : \"name\"," + EOL
+        + "          \"tenant_id\" : \"tenantid\"" + EOL
+        + "        }," + EOL
+        + "        \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "        \"from_port\" : 7," + EOL
+        + "        \"to_port\" : 98," + EOL
+        + "        \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "        \"ip_range\" : {" + EOL
+        + "          \"cidr\" : \"cidr\"" + EOL
+        + "        }" + EOL
+        + "      } ]," + EOL
+        + "      \"links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]," + EOL
+        + "      \"tenant_id\" : \"tenantid\"" + EOL
+        + "    }, {" + EOL
+        + "      \"id\" : \"id\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"description\" : \"description\"," + EOL
+        + "      \"rules\" : [ {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"group\" : {" + EOL
+        + "          \"name\" : \"name\"," + EOL
+        + "          \"tenant_id\" : \"tenantid\"" + EOL
+        + "        }," + EOL
+        + "        \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "        \"from_port\" : 7," + EOL
+        + "        \"to_port\" : 98," + EOL
+        + "        \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "        \"ip_range\" : {" + EOL
+        + "          \"cidr\" : \"cidr\"" + EOL
+        + "        }" + EOL
+        + "      }, {" + EOL
+        + "        \"id\" : \"id\"," + EOL
+        + "        \"name\" : \"name\"," + EOL
+        + "        \"group\" : {" + EOL
+        + "          \"name\" : \"name\"," + EOL
+        + "          \"tenant_id\" : \"tenantid\"" + EOL
+        + "        }," + EOL
+        + "        \"parent_group_id\" : \"parentgroupid\"," + EOL
+        + "        \"from_port\" : 7," + EOL
+        + "        \"to_port\" : 98," + EOL
+        + "        \"ip_protocol\" : \"ipprotocol\"," + EOL
+        + "        \"ip_range\" : {" + EOL
+        + "          \"cidr\" : \"cidr\"" + EOL
+        + "        }" + EOL
+        + "      } ]," + EOL
+        + "      \"links\" : [ {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      }, {" + EOL
+        + "        \"rel\" : \"rel\"," + EOL
+        + "        \"href\" : \"href\"," + EOL
+        + "        \"type\" : \"type\"" + EOL
+        + "      } ]," + EOL
+        + "      \"tenant_id\" : \"tenantid\"" + EOL
+        + "    } ]," + EOL
+        + "    \"OS-EXT-STS:task_state\" : \"taskstate\"," + EOL
+        + "    \"OS-EXT-STS:power_state\" : \"powerstate\"," + EOL
+        + "    \"OS-EXT-STS:vm_state\" : \"vmstate\"," + EOL
+        + "    \"OS-EXT-SRV-ATTR:host\" : \"host\"," + EOL
+        + "    \"OS-EXT-SRV-ATTR:instance_name\" : \"instancename\"," + EOL
+        + "    \"OS-EXT-SRV-ATTR:hypervisor_hostname\" : \"hypervisorhostname\"," + EOL
+        + "    \"OS-DCF:diskConfig\" : \"diskconfig\"," + EOL
+        + "    \"OS-EXT-AZ:availability_zone\" : \"availabilityzone\"," + EOL
+        + "    \"OS-SRV-USG:launched_at\" : \"launchedat\"," + EOL
+        + "    \"OS-SRV-USG:terminated_at\" : \"terminatedat\"," + EOL
+        + "    \"os-extended-volumes:volumes_attached\" : [ \"osextendedvolumesattached-v1\", \"osextendedvolumesattached-v2\" ]" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Server.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Server server = objectMapper.readValue(JSON_FULL, Server.class);
+        String json = objectMapper.writeValueAsString(server);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Server server = objectMapper.readValue(JSON_FULL, Server.class);
+        server.toString();
+        
+        Addresses addresses = server.getAddresses();
+        Assert.assertNotNull(addresses);
+        
+        Map<String,String> metadata = server.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        
+        String hostId = server.getHostId();
+        Assert.assertNotNull(hostId);
+        
+        String uuid = server.getUuid();
+        Assert.assertNotNull(uuid);
+        
+        String userId = server.getUserId();
+        Assert.assertNotNull(userId);
+        
+        String taskState = server.getTaskState();
+        Assert.assertNotNull(taskState);
+        
+        String powerState = server.getPowerState();
+        Assert.assertNotNull(powerState);
+        
+        String vmState = server.getVmState();
+        Assert.assertNotNull(vmState);
+        
+        String tenantId = server.getTenantId();
+        Assert.assertNotNull(tenantId);
+        
+        String configDrive = server.getConfigDrive();
+        Assert.assertNotNull(configDrive);
+        
+        String host = server.getHost();
+        Assert.assertNotNull(host);
+        
+        String keyName = server.getKeyName();
+        Assert.assertNotNull(keyName);
+        
+        List<Link> links = server.getLinks();
+        Assert.assertNotNull(links);
+        Assert.assertEquals(2, links.size());
+        
+        String id = server.getId();
+        Assert.assertNotNull(id);
+        
+        String launchedAt = server.getLaunchedAt();
+        Assert.assertNotNull(launchedAt);
+        
+        Image image = server.getImage();
+        Assert.assertNotNull(image);
+        server.setImage(image);
+        
+        String terminatedAt = server.getTerminatedAt();
+        Assert.assertNotNull(terminatedAt);
+        
+        String created = server.getCreated();
+        Assert.assertNotNull(created);
+        
+        Fault fault = server.getFault();
+        Assert.assertNotNull(fault);
+        
+        String hypervisorHostname = server.getHypervisorHostname();
+        Assert.assertNotNull(hypervisorHostname);
+        
+        Flavor flavor = server.getFlavor();
+        Assert.assertNotNull(flavor);
+        server.setFlavor(flavor);
+        
+        String instanceName = server.getInstanceName();
+        Assert.assertNotNull(instanceName);
+        
+        List<String> osExtendedVolumesAttached = server.getOsExtendedVolumesAttached();
+        Assert.assertNotNull(osExtendedVolumesAttached);
+        Assert.assertEquals(2, osExtendedVolumesAttached.size());
+        
+        String name = server.getName();
+        Assert.assertNotNull(name);
+        
+        Integer progress = server.getProgress();
+        Assert.assertNotNull(progress);
+        
+        String adminPass = server.getAdminPass();
+        Assert.assertNotNull(adminPass);
+        
+        String accessIPv6 = server.getAccessIPv6();
+        Assert.assertNotNull(accessIPv6);
+        
+        String diskConfig = server.getDiskConfig();
+        Assert.assertNotNull(diskConfig);
+        
+        List<SecurityGroup> securityGroups = server.getSecurityGroups();
+        Assert.assertNotNull(securityGroups);
+        Assert.assertEquals(2, securityGroups.size());
+        
+        String updated = server.getUpdated();
+        Assert.assertNotNull(updated);
+        
+        String availabilityZone = server.getAvailabilityZone();
+        Assert.assertNotNull(availabilityZone);
+        
+        String accessIPv4 = server.getAccessIPv4();
+        Assert.assertNotNull(accessIPv4);
+        
+        String status = server.getStatus();
+        Assert.assertNotNull(status);
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/ServerUsageTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/ServerUsageTest.java
new file mode 100644 (file)
index 0000000..4b7f683
--- /dev/null
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.SimpleTenantUsage.ServerUsage;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class ServerUsageTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"uptime\" : 78," + EOL
+        + "  \"state\" : \"state\"," + EOL
+        + "  \"hours\" : 64.0," + EOL
+        + "  \"vcpus\" : 79," + EOL
+        + "  \"flavor\" : \"flavor\"," + EOL
+        + "  \"name\" : \"name\"," + EOL
+        + "  \"instance_id\" : \"instanceid\"," + EOL
+        + "  \"started_at\" : \"startedat\"," + EOL
+        + "  \"ended_at\" : \"endedat\"," + EOL
+        + "  \"memory_mb\" : 90," + EOL
+        + "  \"tenant_id\" : \"tenantid\"," + EOL
+        + "  \"local_gb\" : 11" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + ServerUsage.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        ServerUsage serverusage = objectMapper.readValue(JSON_FULL, ServerUsage.class);
+        String json = objectMapper.writeValueAsString(serverusage);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        ServerUsage serverusage = objectMapper.readValue(JSON_FULL, ServerUsage.class);
+        serverusage.toString();
+        
+        String flavor = serverusage.getFlavor();
+        Assert.assertNotNull(flavor);
+        
+        Integer memoryMb = serverusage.getMemoryMb();
+        Assert.assertNotNull(memoryMb);
+        
+        Double hours = serverusage.getHours();
+        Assert.assertNotNull(hours);
+        
+        String instanceId = serverusage.getInstanceId();
+        Assert.assertNotNull(instanceId);
+        
+        Integer localDiskSize = serverusage.getLocalDiskSize();
+        Assert.assertNotNull(localDiskSize);
+        
+        String endedAt = serverusage.getEndedAt();
+        Assert.assertNotNull(endedAt);
+        
+        String name = serverusage.getName();
+        Assert.assertNotNull(name);
+        
+        String tenantId = serverusage.getTenantId();
+        Assert.assertNotNull(tenantId);
+        
+        String startedAt = serverusage.getStartedAt();
+        Assert.assertNotNull(startedAt);
+        
+        String state = serverusage.getState();
+        Assert.assertNotNull(state);
+        
+        Integer vcpus = serverusage.getVcpus();
+        Assert.assertNotNull(vcpus);
+        
+        Integer uptime = serverusage.getUptime();
+        Assert.assertNotNull(uptime);
+    }
+}
index 313f6f7..7f45acc 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Server;
+import com.woorea.openstack.nova.model.Servers;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class ServersTest {
 
-    Servers servers = new Servers();
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getList() throws Exception {
-        servers.getList();
+    private static final String JSON_FULL;
+
+    static {
+        // StringBuilder is used because extremely long concatenations
+        // can cause compiler stack overflow
+        StringBuilder sb = new StringBuilder();
+        sb.append("{" + EOL);
+        sb.append("  \"servers\" : [ {" + EOL);
+        sb.append("    \"id\" : \"id\"," + EOL);
+        sb.append("    \"name\" : \"name\"," + EOL);
+        sb.append("    \"addresses\" : {" + EOL);
+        sb.append("      \"addresses\" : {" + EOL);
+        sb.append("        \"addresses-k1\" : [ {" + EOL);
+        sb.append("          \"version\" : \"version\"," + EOL);
+        sb.append("          \"addr\" : \"addr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS:type\" : \"type\"" + EOL);
+        sb.append("        }, {" + EOL);
+        sb.append("          \"version\" : \"version\"," + EOL);
+        sb.append("          \"addr\" : \"addr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS:type\" : \"type\"" + EOL);
+        sb.append("        } ]," + EOL);
+        sb.append("        \"addresses-k2\" : [ {" + EOL);
+        sb.append("          \"version\" : \"version\"," + EOL);
+        sb.append("          \"addr\" : \"addr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS:type\" : \"type\"" + EOL);
+        sb.append("        }, {" + EOL);
+        sb.append("          \"version\" : \"version\"," + EOL);
+        sb.append("          \"addr\" : \"addr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS:type\" : \"type\"" + EOL);
+        sb.append("        } ]" + EOL);
+        sb.append("      }" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"links\" : [ {" + EOL);
+        sb.append("      \"rel\" : \"rel\"," + EOL);
+        sb.append("      \"href\" : \"href\"," + EOL);
+        sb.append("      \"type\" : \"type\"" + EOL);
+        sb.append("    }, {" + EOL);
+        sb.append("      \"rel\" : \"rel\"," + EOL);
+        sb.append("      \"href\" : \"href\"," + EOL);
+        sb.append("      \"type\" : \"type\"" + EOL);
+        sb.append("    } ]," + EOL);
+        sb.append("    \"image\" : {" + EOL);
+        sb.append("      \"id\" : \"id\"," + EOL);
+        sb.append("      \"status\" : \"status\"," + EOL);
+        sb.append("      \"name\" : \"name\"," + EOL);
+        sb.append("      \"progress\" : 3," + EOL);
+        sb.append("      \"minRam\" : 62," + EOL);
+        sb.append("      \"minDisk\" : 69," + EOL);
+        sb.append("      \"created\" : 1485172800000," + EOL);
+        sb.append("      \"updated\" : 1486468800000," + EOL);
+        sb.append("      \"metadata\" : {" + EOL);
+        sb.append("        \"metadata-k1\" : \"metadata-v1\"," + EOL);
+        sb.append("        \"metadata-k2\" : \"metadata-v2\"" + EOL);
+        sb.append("      }," + EOL);
+        sb.append("      \"server\" : {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"links\" : [ {" + EOL);
+        sb.append("          \"rel\" : \"rel\"," + EOL);
+        sb.append("          \"href\" : \"href\"," + EOL);
+        sb.append("          \"type\" : \"type\"" + EOL);
+        sb.append("        }, {" + EOL);
+        sb.append("          \"rel\" : \"rel\"," + EOL);
+        sb.append("          \"href\" : \"href\"," + EOL);
+        sb.append("          \"type\" : \"type\"" + EOL);
+        sb.append("        } ]" + EOL);
+        sb.append("      }," + EOL);
+        sb.append("      \"links\" : [ {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"OS-EXT-IMG-SIZE:size\" : 43" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"flavor\" : {" + EOL);
+        sb.append("      \"id\" : \"id\"," + EOL);
+        sb.append("      \"name\" : \"name\"," + EOL);
+        sb.append("      \"vcpus\" : 79," + EOL);
+        sb.append("      \"ram\" : 38," + EOL);
+        sb.append("      \"disk\" : 45," + EOL);
+        sb.append("      \"swap\" : \"swap\"," + EOL);
+        sb.append("      \"links\" : [ {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"public\" : false," + EOL);
+        sb.append("      \"OS-FLV-EXT-DATA:ephemeral\" : 65," + EOL);
+        sb.append("      \"rxtx_factor\" : 11.0," + EOL);
+        sb.append("      \"OS-FLV-DISABLED:disabled\" : true," + EOL);
+        sb.append("      \"rxtx_quota\" : 42," + EOL);
+        sb.append("      \"rxtx_cap\" : 96," + EOL);
+        sb.append("      \"os-flavor-access:is_public\" : false" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"accessIPv4\" : \"accessipv4\"," + EOL);
+        sb.append("    \"accessIPv6\" : \"accessipv6\"," + EOL);
+        sb.append("    \"status\" : \"status\"," + EOL);
+        sb.append("    \"progress\" : 3," + EOL);
+        sb.append("    \"fault\" : {" + EOL);
+        sb.append("      \"code\" : 29," + EOL);
+        sb.append("      \"message\" : \"message\"," + EOL);
+        sb.append("      \"details\" : \"details\"," + EOL);
+        sb.append("      \"created\" : 1485172800000" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"hostId\" : \"hostid\"," + EOL);
+        sb.append("    \"updated\" : \"updated\"," + EOL);
+        sb.append("    \"created\" : \"created\"," + EOL);
+        sb.append("    \"metadata\" : {" + EOL);
+        sb.append("      \"metadata-k1\" : \"metadata-v1\"," + EOL);
+        sb.append("      \"metadata-k2\" : \"metadata-v2\"" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"uuid\" : \"uuid\"," + EOL);
+        sb.append("    \"adminPass\" : \"adminpass\"," + EOL);
+        sb.append("    \"config_drive\" : \"configdrive\"," + EOL);
+        sb.append("    \"tenant_id\" : \"tenantid\"," + EOL);
+        sb.append("    \"user_id\" : \"userid\"," + EOL);
+        sb.append("    \"key_name\" : \"keyname\"," + EOL);
+        sb.append("    \"security_groups\" : [ {" + EOL);
+        sb.append("      \"id\" : \"id\"," + EOL);
+        sb.append("      \"name\" : \"name\"," + EOL);
+        sb.append("      \"description\" : \"description\"," + EOL);
+        sb.append("      \"rules\" : [ {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"name\" : \"name\"," + EOL);
+        sb.append("        \"group\" : {" + EOL);
+        sb.append("          \"name\" : \"name\"," + EOL);
+        sb.append("          \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("        }," + EOL);
+        sb.append("        \"parent_group_id\" : \"parentgroupid\"," + EOL);
+        sb.append("        \"from_port\" : 7," + EOL);
+        sb.append("        \"to_port\" : 98," + EOL);
+        sb.append("        \"ip_protocol\" : \"ipprotocol\"," + EOL);
+        sb.append("        \"ip_range\" : {" + EOL);
+        sb.append("          \"cidr\" : \"cidr\"" + EOL);
+        sb.append("        }" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"name\" : \"name\"," + EOL);
+        sb.append("        \"group\" : {" + EOL);
+        sb.append("          \"name\" : \"name\"," + EOL);
+        sb.append("          \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("        }," + EOL);
+        sb.append("        \"parent_group_id\" : \"parentgroupid\"," + EOL);
+        sb.append("        \"from_port\" : 7," + EOL);
+        sb.append("        \"to_port\" : 98," + EOL);
+        sb.append("        \"ip_protocol\" : \"ipprotocol\"," + EOL);
+        sb.append("        \"ip_range\" : {" + EOL);
+        sb.append("          \"cidr\" : \"cidr\"" + EOL);
+        sb.append("        }" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"links\" : [ {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("    }, {" + EOL);
+        sb.append("      \"id\" : \"id\"," + EOL);
+        sb.append("      \"name\" : \"name\"," + EOL);
+        sb.append("      \"description\" : \"description\"," + EOL);
+        sb.append("      \"rules\" : [ {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"name\" : \"name\"," + EOL);
+        sb.append("        \"group\" : {" + EOL);
+        sb.append("          \"name\" : \"name\"," + EOL);
+        sb.append("          \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("        }," + EOL);
+        sb.append("        \"parent_group_id\" : \"parentgroupid\"," + EOL);
+        sb.append("        \"from_port\" : 7," + EOL);
+        sb.append("        \"to_port\" : 98," + EOL);
+        sb.append("        \"ip_protocol\" : \"ipprotocol\"," + EOL);
+        sb.append("        \"ip_range\" : {" + EOL);
+        sb.append("          \"cidr\" : \"cidr\"" + EOL);
+        sb.append("        }" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"name\" : \"name\"," + EOL);
+        sb.append("        \"group\" : {" + EOL);
+        sb.append("          \"name\" : \"name\"," + EOL);
+        sb.append("          \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("        }," + EOL);
+        sb.append("        \"parent_group_id\" : \"parentgroupid\"," + EOL);
+        sb.append("        \"from_port\" : 7," + EOL);
+        sb.append("        \"to_port\" : 98," + EOL);
+        sb.append("        \"ip_protocol\" : \"ipprotocol\"," + EOL);
+        sb.append("        \"ip_range\" : {" + EOL);
+        sb.append("          \"cidr\" : \"cidr\"" + EOL);
+        sb.append("        }" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"links\" : [ {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("    } ]," + EOL);
+        sb.append("    \"OS-EXT-STS:task_state\" : \"taskstate\"," + EOL);
+        sb.append("    \"OS-EXT-STS:power_state\" : \"powerstate\"," + EOL);
+        sb.append("    \"OS-EXT-STS:vm_state\" : \"vmstate\"," + EOL);
+        sb.append("    \"OS-EXT-SRV-ATTR:host\" : \"host\"," + EOL);
+        sb.append("    \"OS-EXT-SRV-ATTR:instance_name\" : \"instancename\"," + EOL);
+        sb.append("    \"OS-EXT-SRV-ATTR:hypervisor_hostname\" : \"hypervisorhostname\"," + EOL);
+        sb.append("    \"OS-DCF:diskConfig\" : \"diskconfig\"," + EOL);
+        sb.append("    \"OS-EXT-AZ:availability_zone\" : \"availabilityzone\"," + EOL);
+        sb.append("    \"OS-SRV-USG:launched_at\" : \"launchedat\"," + EOL);
+        sb.append("    \"OS-SRV-USG:terminated_at\" : \"terminatedat\"," + EOL);
+        sb.append("    \"os-extended-volumes:volumes_attached\" : [ \"osextendedvolumesattached-v1\", \"osextendedvolumesattached-v2\" ]" + EOL);
+        sb.append("  }, {" + EOL);
+        sb.append("    \"id\" : \"id\"," + EOL);
+        sb.append("    \"name\" : \"name\"," + EOL);
+        sb.append("    \"addresses\" : {" + EOL);
+        sb.append("      \"addresses\" : {" + EOL);
+        sb.append("        \"addresses-k1\" : [ {" + EOL);
+        sb.append("          \"version\" : \"version\"," + EOL);
+        sb.append("          \"addr\" : \"addr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS:type\" : \"type\"" + EOL);
+        sb.append("        }, {" + EOL);
+        sb.append("          \"version\" : \"version\"," + EOL);
+        sb.append("          \"addr\" : \"addr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS:type\" : \"type\"" + EOL);
+        sb.append("        } ]," + EOL);
+        sb.append("        \"addresses-k2\" : [ {" + EOL);
+        sb.append("          \"version\" : \"version\"," + EOL);
+        sb.append("          \"addr\" : \"addr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS:type\" : \"type\"" + EOL);
+        sb.append("        }, {" + EOL);
+        sb.append("          \"version\" : \"version\"," + EOL);
+        sb.append("          \"addr\" : \"addr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS-MAC:mac_addr\" : \"macaddr\"," + EOL);
+        sb.append("          \"OS-EXT-IPS:type\" : \"type\"" + EOL);
+        sb.append("        } ]" + EOL);
+        sb.append("      }" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"links\" : [ {" + EOL);
+        sb.append("      \"rel\" : \"rel\"," + EOL);
+        sb.append("      \"href\" : \"href\"," + EOL);
+        sb.append("      \"type\" : \"type\"" + EOL);
+        sb.append("    }, {" + EOL);
+        sb.append("      \"rel\" : \"rel\"," + EOL);
+        sb.append("      \"href\" : \"href\"," + EOL);
+        sb.append("      \"type\" : \"type\"" + EOL);
+        sb.append("    } ]," + EOL);
+        sb.append("    \"image\" : {" + EOL);
+        sb.append("      \"id\" : \"id\"," + EOL);
+        sb.append("      \"status\" : \"status\"," + EOL);
+        sb.append("      \"name\" : \"name\"," + EOL);
+        sb.append("      \"progress\" : 3," + EOL);
+        sb.append("      \"minRam\" : 62," + EOL);
+        sb.append("      \"minDisk\" : 69," + EOL);
+        sb.append("      \"created\" : 1485172800000," + EOL);
+        sb.append("      \"updated\" : 1486468800000," + EOL);
+        sb.append("      \"metadata\" : {" + EOL);
+        sb.append("        \"metadata-k1\" : \"metadata-v1\"," + EOL);
+        sb.append("        \"metadata-k2\" : \"metadata-v2\"" + EOL);
+        sb.append("      }," + EOL);
+        sb.append("      \"server\" : {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"links\" : [ {" + EOL);
+        sb.append("          \"rel\" : \"rel\"," + EOL);
+        sb.append("          \"href\" : \"href\"," + EOL);
+        sb.append("          \"type\" : \"type\"" + EOL);
+        sb.append("        }, {" + EOL);
+        sb.append("          \"rel\" : \"rel\"," + EOL);
+        sb.append("          \"href\" : \"href\"," + EOL);
+        sb.append("          \"type\" : \"type\"" + EOL);
+        sb.append("        } ]" + EOL);
+        sb.append("      }," + EOL);
+        sb.append("      \"links\" : [ {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"OS-EXT-IMG-SIZE:size\" : 43" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"flavor\" : {" + EOL);
+        sb.append("      \"id\" : \"id\"," + EOL);
+        sb.append("      \"name\" : \"name\"," + EOL);
+        sb.append("      \"vcpus\" : 79," + EOL);
+        sb.append("      \"ram\" : 38," + EOL);
+        sb.append("      \"disk\" : 45," + EOL);
+        sb.append("      \"swap\" : \"swap\"," + EOL);
+        sb.append("      \"links\" : [ {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"public\" : false," + EOL);
+        sb.append("      \"OS-FLV-EXT-DATA:ephemeral\" : 65," + EOL);
+        sb.append("      \"rxtx_factor\" : 11.0," + EOL);
+        sb.append("      \"OS-FLV-DISABLED:disabled\" : true," + EOL);
+        sb.append("      \"rxtx_quota\" : 42," + EOL);
+        sb.append("      \"rxtx_cap\" : 96," + EOL);
+        sb.append("      \"os-flavor-access:is_public\" : false" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"accessIPv4\" : \"accessipv4\"," + EOL);
+        sb.append("    \"accessIPv6\" : \"accessipv6\"," + EOL);
+        sb.append("    \"status\" : \"status\"," + EOL);
+        sb.append("    \"progress\" : 3," + EOL);
+        sb.append("    \"fault\" : {" + EOL);
+        sb.append("      \"code\" : 29," + EOL);
+        sb.append("      \"message\" : \"message\"," + EOL);
+        sb.append("      \"details\" : \"details\"," + EOL);
+        sb.append("      \"created\" : 1485172800000" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"hostId\" : \"hostid\"," + EOL);
+        sb.append("    \"updated\" : \"updated\"," + EOL);
+        sb.append("    \"created\" : \"created\"," + EOL);
+        sb.append("    \"metadata\" : {" + EOL);
+        sb.append("      \"metadata-k1\" : \"metadata-v1\"," + EOL);
+        sb.append("      \"metadata-k2\" : \"metadata-v2\"" + EOL);
+        sb.append("    }," + EOL);
+        sb.append("    \"uuid\" : \"uuid\"," + EOL);
+        sb.append("    \"adminPass\" : \"adminpass\"," + EOL);
+        sb.append("    \"config_drive\" : \"configdrive\"," + EOL);
+        sb.append("    \"tenant_id\" : \"tenantid\"," + EOL);
+        sb.append("    \"user_id\" : \"userid\"," + EOL);
+        sb.append("    \"key_name\" : \"keyname\"," + EOL);
+        sb.append("    \"security_groups\" : [ {" + EOL);
+        sb.append("      \"id\" : \"id\"," + EOL);
+        sb.append("      \"name\" : \"name\"," + EOL);
+        sb.append("      \"description\" : \"description\"," + EOL);
+        sb.append("      \"rules\" : [ {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"name\" : \"name\"," + EOL);
+        sb.append("        \"group\" : {" + EOL);
+        sb.append("          \"name\" : \"name\"," + EOL);
+        sb.append("          \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("        }," + EOL);
+        sb.append("        \"parent_group_id\" : \"parentgroupid\"," + EOL);
+        sb.append("        \"from_port\" : 7," + EOL);
+        sb.append("        \"to_port\" : 98," + EOL);
+        sb.append("        \"ip_protocol\" : \"ipprotocol\"," + EOL);
+        sb.append("        \"ip_range\" : {" + EOL);
+        sb.append("          \"cidr\" : \"cidr\"" + EOL);
+        sb.append("        }" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"name\" : \"name\"," + EOL);
+        sb.append("        \"group\" : {" + EOL);
+        sb.append("          \"name\" : \"name\"," + EOL);
+        sb.append("          \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("        }," + EOL);
+        sb.append("        \"parent_group_id\" : \"parentgroupid\"," + EOL);
+        sb.append("        \"from_port\" : 7," + EOL);
+        sb.append("        \"to_port\" : 98," + EOL);
+        sb.append("        \"ip_protocol\" : \"ipprotocol\"," + EOL);
+        sb.append("        \"ip_range\" : {" + EOL);
+        sb.append("          \"cidr\" : \"cidr\"" + EOL);
+        sb.append("        }" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"links\" : [ {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("    }, {" + EOL);
+        sb.append("      \"id\" : \"id\"," + EOL);
+        sb.append("      \"name\" : \"name\"," + EOL);
+        sb.append("      \"description\" : \"description\"," + EOL);
+        sb.append("      \"rules\" : [ {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"name\" : \"name\"," + EOL);
+        sb.append("        \"group\" : {" + EOL);
+        sb.append("          \"name\" : \"name\"," + EOL);
+        sb.append("          \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("        }," + EOL);
+        sb.append("        \"parent_group_id\" : \"parentgroupid\"," + EOL);
+        sb.append("        \"from_port\" : 7," + EOL);
+        sb.append("        \"to_port\" : 98," + EOL);
+        sb.append("        \"ip_protocol\" : \"ipprotocol\"," + EOL);
+        sb.append("        \"ip_range\" : {" + EOL);
+        sb.append("          \"cidr\" : \"cidr\"" + EOL);
+        sb.append("        }" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"id\" : \"id\"," + EOL);
+        sb.append("        \"name\" : \"name\"," + EOL);
+        sb.append("        \"group\" : {" + EOL);
+        sb.append("          \"name\" : \"name\"," + EOL);
+        sb.append("          \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("        }," + EOL);
+        sb.append("        \"parent_group_id\" : \"parentgroupid\"," + EOL);
+        sb.append("        \"from_port\" : 7," + EOL);
+        sb.append("        \"to_port\" : 98," + EOL);
+        sb.append("        \"ip_protocol\" : \"ipprotocol\"," + EOL);
+        sb.append("        \"ip_range\" : {" + EOL);
+        sb.append("          \"cidr\" : \"cidr\"" + EOL);
+        sb.append("        }" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"links\" : [ {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      }, {" + EOL);
+        sb.append("        \"rel\" : \"rel\"," + EOL);
+        sb.append("        \"href\" : \"href\"," + EOL);
+        sb.append("        \"type\" : \"type\"" + EOL);
+        sb.append("      } ]," + EOL);
+        sb.append("      \"tenant_id\" : \"tenantid\"" + EOL);
+        sb.append("    } ]," + EOL);
+        sb.append("    \"OS-EXT-STS:task_state\" : \"taskstate\"," + EOL);
+        sb.append("    \"OS-EXT-STS:power_state\" : \"powerstate\"," + EOL);
+        sb.append("    \"OS-EXT-STS:vm_state\" : \"vmstate\"," + EOL);
+        sb.append("    \"OS-EXT-SRV-ATTR:host\" : \"host\"," + EOL);
+        sb.append("    \"OS-EXT-SRV-ATTR:instance_name\" : \"instancename\"," + EOL);
+        sb.append("    \"OS-EXT-SRV-ATTR:hypervisor_hostname\" : \"hypervisorhostname\"," + EOL);
+        sb.append("    \"OS-DCF:diskConfig\" : \"diskconfig\"," + EOL);
+        sb.append("    \"OS-EXT-AZ:availability_zone\" : \"availabilityzone\"," + EOL);
+        sb.append("    \"OS-SRV-USG:launched_at\" : \"launchedat\"," + EOL);
+        sb.append("    \"OS-SRV-USG:terminated_at\" : \"terminatedat\"," + EOL);
+        sb.append("    \"os-extended-volumes:volumes_attached\" : [ \"osextendedvolumesattached-v1\", \"osextendedvolumesattached-v2\" ]" + EOL);
+        sb.append("  } ]" + EOL);
+        sb.append("}");
+        JSON_FULL = sb.toString();
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        servers.iterator();
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Servers.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Servers servers = objectMapper.readValue(JSON_FULL, Servers.class);
+        String json = objectMapper.writeValueAsString(servers);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-}
\ No newline at end of file
+    @Test
+    public void testMethods() throws Exception {
+        Servers servers = objectMapper.readValue(JSON_FULL, Servers.class);
+        servers.toString();
+        
+        List<Server> list = servers.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Server x : servers) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
index 91ac200..8303e33 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package com.woorea.openstack.nova.model;
 
-import org.junit.Test;
+package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.SimpleTenantUsage;
+import com.woorea.openstack.nova.model.SimpleTenantUsage.ServerUsage;
 import java.math.BigDecimal;
-import java.util.Collections;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SimpleTenantUsageTest {
 
-    SimpleTenantUsage simpleTenantUsage = new SimpleTenantUsage();
-
-    @Test
-    public void getTotalMemoryMbUsage() throws Exception {
-        simpleTenantUsage.getTotalMemoryMbUsage();
-    }
-
-    @Test
-    public void setTotalMemoryMbUsage() throws Exception {
-        simpleTenantUsage.setTotalMemoryMbUsage(new BigDecimal(1));
-    }
-
-    @Test
-    public void getTotalVcpusUsage() throws Exception {
-        simpleTenantUsage.getTotalVcpusUsage();
-    }
-
-    @Test
-    public void setTotalVcpusUsage() throws Exception {
-        simpleTenantUsage.setTotalVcpusUsage(new BigDecimal(1));
-    }
-
-    @Test
-    public void getTotalLocalGbUsage() throws Exception {
-        simpleTenantUsage.getTotalLocalGbUsage();
-    }
-
-    @Test
-    public void setTotalLocalGbUsage() throws Exception {
-        simpleTenantUsage.setTotalLocalGbUsage(BigDecimal.ONE);
-    }
-
-    @Test
-    public void getStart() throws Exception {
-        simpleTenantUsage.getStart();
-    }
-
-    @Test
-    public void setStart() throws Exception {
-        simpleTenantUsage.setStart("test");
-    }
-
-    @Test
-    public void getStop() throws Exception {
-        simpleTenantUsage.getStop();
-    }
-
-    @Test
-    public void setStop() throws Exception {
-        simpleTenantUsage.setStop("test");
-    }
-
-    @Test
-    public void getTenantId() throws Exception {
-        simpleTenantUsage.getTenantId();
-    }
-
-    @Test
-    public void setTenantId() throws Exception {
-        simpleTenantUsage.setTenantId("test");
-    }
-
-    @Test
-    public void getTotalHours() throws Exception {
-        simpleTenantUsage.getTotalHours();
-    }
-
-    @Test
-    public void setTotalHours() throws Exception {
-        simpleTenantUsage.setTotalHours("test");
-    }
-
-    @Test
-    public void getServerUsages() throws Exception {
-        simpleTenantUsage.getServerUsages();
-    }
-
-    @Test
-    public void setServerUsages() throws Exception {
-        simpleTenantUsage.setServerUsages(Collections.<SimpleTenantUsage.ServerUsage>emptyList());
-    }
-
-}
\ No newline at end of file
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"tenant_usage\" : {" + EOL
+        + "    \"start\" : \"start\"," + EOL
+        + "    \"stop\" : \"stop\"," + EOL
+        + "    \"total_memory_mb_usage\" : 14," + EOL
+        + "    \"total_vcpus_usage\" : 3," + EOL
+        + "    \"total_local_gb_usage\" : 66," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"total_hours\" : \"totalhours\"," + EOL
+        + "    \"server_usages\" : [ {" + EOL
+        + "      \"uptime\" : 78," + EOL
+        + "      \"state\" : \"state\"," + EOL
+        + "      \"hours\" : 64.0," + EOL
+        + "      \"vcpus\" : 79," + EOL
+        + "      \"flavor\" : \"flavor\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"instance_id\" : \"instanceid\"," + EOL
+        + "      \"started_at\" : \"startedat\"," + EOL
+        + "      \"ended_at\" : \"endedat\"," + EOL
+        + "      \"memory_mb\" : 90," + EOL
+        + "      \"tenant_id\" : \"tenantid\"," + EOL
+        + "      \"local_gb\" : 11" + EOL
+        + "    }, {" + EOL
+        + "      \"uptime\" : 78," + EOL
+        + "      \"state\" : \"state\"," + EOL
+        + "      \"hours\" : 64.0," + EOL
+        + "      \"vcpus\" : 79," + EOL
+        + "      \"flavor\" : \"flavor\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"instance_id\" : \"instanceid\"," + EOL
+        + "      \"started_at\" : \"startedat\"," + EOL
+        + "      \"ended_at\" : \"endedat\"," + EOL
+        + "      \"memory_mb\" : 90," + EOL
+        + "      \"tenant_id\" : \"tenantid\"," + EOL
+        + "      \"local_gb\" : 11" + EOL
+        + "    } ]" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SimpleTenantUsage.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SimpleTenantUsage simpletenantusage = objectMapper.readValue(JSON_FULL, SimpleTenantUsage.class);
+        String json = objectMapper.writeValueAsString(simpletenantusage);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        SimpleTenantUsage simpletenantusage = objectMapper.readValue(JSON_FULL, SimpleTenantUsage.class);
+        simpletenantusage.toString();
+        
+        BigDecimal totalMemoryMbUsage = simpletenantusage.getTotalMemoryMbUsage();
+        Assert.assertNotNull(totalMemoryMbUsage);
+        simpletenantusage.setTotalMemoryMbUsage(totalMemoryMbUsage);
+        
+        String stop = simpletenantusage.getStop();
+        Assert.assertNotNull(stop);
+        simpletenantusage.setStop(stop);
+        
+        BigDecimal totalVcpusUsage = simpletenantusage.getTotalVcpusUsage();
+        Assert.assertNotNull(totalVcpusUsage);
+        simpletenantusage.setTotalVcpusUsage(totalVcpusUsage);
+        
+        String tenantId = simpletenantusage.getTenantId();
+        Assert.assertNotNull(tenantId);
+        simpletenantusage.setTenantId(tenantId);
+        
+        String start = simpletenantusage.getStart();
+        Assert.assertNotNull(start);
+        simpletenantusage.setStart(start);
+        
+        List<ServerUsage> serverUsages = simpletenantusage.getServerUsages();
+        Assert.assertNotNull(serverUsages);
+        Assert.assertEquals(2, serverUsages.size());
+        simpletenantusage.setServerUsages(serverUsages);
+        
+        BigDecimal totalLocalGbUsage = simpletenantusage.getTotalLocalGbUsage();
+        Assert.assertNotNull(totalLocalGbUsage);
+        simpletenantusage.setTotalLocalGbUsage(totalLocalGbUsage);
+        
+        String totalHours = simpletenantusage.getTotalHours();
+        Assert.assertNotNull(totalHours);
+        simpletenantusage.setTotalHours(totalHours);
+    }
+}
index d1e9bfa..523a9ab 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.SimpleTenantUsage;
+import com.woorea.openstack.nova.model.SimpleTenantUsages;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SimpleTenantUsagesTest {
 
-    SimpleTenantUsages simpleTenantUsages = new SimpleTenantUsages();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"tenant_usages\" : [ {" + EOL
+        + "    \"start\" : \"start\"," + EOL
+        + "    \"stop\" : \"stop\"," + EOL
+        + "    \"total_memory_mb_usage\" : 14," + EOL
+        + "    \"total_vcpus_usage\" : 3," + EOL
+        + "    \"total_local_gb_usage\" : 66," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"total_hours\" : \"totalhours\"," + EOL
+        + "    \"server_usages\" : [ {" + EOL
+        + "      \"uptime\" : 78," + EOL
+        + "      \"state\" : \"state\"," + EOL
+        + "      \"hours\" : 64.0," + EOL
+        + "      \"vcpus\" : 79," + EOL
+        + "      \"flavor\" : \"flavor\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"instance_id\" : \"instanceid\"," + EOL
+        + "      \"started_at\" : \"startedat\"," + EOL
+        + "      \"ended_at\" : \"endedat\"," + EOL
+        + "      \"memory_mb\" : 90," + EOL
+        + "      \"tenant_id\" : \"tenantid\"," + EOL
+        + "      \"local_gb\" : 11" + EOL
+        + "    }, {" + EOL
+        + "      \"uptime\" : 78," + EOL
+        + "      \"state\" : \"state\"," + EOL
+        + "      \"hours\" : 64.0," + EOL
+        + "      \"vcpus\" : 79," + EOL
+        + "      \"flavor\" : \"flavor\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"instance_id\" : \"instanceid\"," + EOL
+        + "      \"started_at\" : \"startedat\"," + EOL
+        + "      \"ended_at\" : \"endedat\"," + EOL
+        + "      \"memory_mb\" : 90," + EOL
+        + "      \"tenant_id\" : \"tenantid\"," + EOL
+        + "      \"local_gb\" : 11" + EOL
+        + "    } ]" + EOL
+        + "  }, {" + EOL
+        + "    \"start\" : \"start\"," + EOL
+        + "    \"stop\" : \"stop\"," + EOL
+        + "    \"total_memory_mb_usage\" : 14," + EOL
+        + "    \"total_vcpus_usage\" : 3," + EOL
+        + "    \"total_local_gb_usage\" : 66," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"total_hours\" : \"totalhours\"," + EOL
+        + "    \"server_usages\" : [ {" + EOL
+        + "      \"uptime\" : 78," + EOL
+        + "      \"state\" : \"state\"," + EOL
+        + "      \"hours\" : 64.0," + EOL
+        + "      \"vcpus\" : 79," + EOL
+        + "      \"flavor\" : \"flavor\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"instance_id\" : \"instanceid\"," + EOL
+        + "      \"started_at\" : \"startedat\"," + EOL
+        + "      \"ended_at\" : \"endedat\"," + EOL
+        + "      \"memory_mb\" : 90," + EOL
+        + "      \"tenant_id\" : \"tenantid\"," + EOL
+        + "      \"local_gb\" : 11" + EOL
+        + "    }, {" + EOL
+        + "      \"uptime\" : 78," + EOL
+        + "      \"state\" : \"state\"," + EOL
+        + "      \"hours\" : 64.0," + EOL
+        + "      \"vcpus\" : 79," + EOL
+        + "      \"flavor\" : \"flavor\"," + EOL
+        + "      \"name\" : \"name\"," + EOL
+        + "      \"instance_id\" : \"instanceid\"," + EOL
+        + "      \"started_at\" : \"startedat\"," + EOL
+        + "      \"ended_at\" : \"endedat\"," + EOL
+        + "      \"memory_mb\" : 90," + EOL
+        + "      \"tenant_id\" : \"tenantid\"," + EOL
+        + "      \"local_gb\" : 11" + EOL
+        + "    } ]" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        simpleTenantUsages.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SimpleTenantUsages.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SimpleTenantUsages simpletenantusages = objectMapper.readValue(JSON_FULL, SimpleTenantUsages.class);
+        String json = objectMapper.writeValueAsString(simpletenantusages);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        simpleTenantUsages.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        SimpleTenantUsages simpletenantusages = objectMapper.readValue(JSON_FULL, SimpleTenantUsages.class);
+        simpletenantusages.toString();
+        
+        List<SimpleTenantUsage> list = simpletenantusages.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") SimpleTenantUsage x : simpletenantusages) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 39abc2c..edcca0f 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.SnapshotForCreate;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SnapshotForCreateTest {
 
-    SnapshotForCreate snapshotForCreate = new SnapshotForCreate();
-
-    @Test
-    public void getVolumeId() throws Exception {
-        snapshotForCreate.getVolumeId();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void setVolumeId() throws Exception {
-        snapshotForCreate.setVolumeId("Test");
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"snapshot\" : {" + EOL
+        + "    \"force\" : false," + EOL
+        + "    \"volume_id\" : \"volumeid\"," + EOL
+        + "    \"display_name\" : \"name\"," + EOL
+        + "    \"display_description\" : \"description\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getForce() throws Exception {
-        snapshotForCreate.getForce();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void setForce() throws Exception {
-        snapshotForCreate.setForce(true);
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + SnapshotForCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        SnapshotForCreate snapshotforcreate = objectMapper.readValue(JSON_FULL, SnapshotForCreate.class);
+        String json = objectMapper.writeValueAsString(snapshotforcreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getName() throws Exception {
-        snapshotForCreate.getName();
+    public void testMethods() throws Exception {
+        SnapshotForCreate snapshotforcreate = objectMapper.readValue(JSON_FULL, SnapshotForCreate.class);
+        snapshotforcreate.toString();
+        
+        String name = snapshotforcreate.getName();
+        Assert.assertNotNull(name);
+        snapshotforcreate.setName(name);
+        
+        String volumeId = snapshotforcreate.getVolumeId();
+        Assert.assertNotNull(volumeId);
+        snapshotforcreate.setVolumeId(volumeId);
+        
+        String description = snapshotforcreate.getDescription();
+        Assert.assertNotNull(description);
+        snapshotforcreate.setDescription(description);
+        
+        Boolean force = snapshotforcreate.getForce();
+        Assert.assertNotNull(force);
+        snapshotforcreate.setForce(force);
     }
-
-    @Test
-    public void setName() throws Exception {
-        snapshotForCreate.setName("Test");
-    }
-
-    @Test
-    public void getDescription() throws Exception {
-        snapshotForCreate.getDescription();
-    }
-
-    @Test
-    public void setDescription() throws Exception {
-        snapshotForCreate.setDescription("test");
-    }
-
-}
\ No newline at end of file
+}
index 816f9c9..d62f730 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Snapshot;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SnapshotTest {
 
-    Snapshot snapshot = new Snapshot();
-
-    @Test
-    public void getId() throws Exception {
-        snapshot.getId();
-    }
-
-    @Test
-    public void getStatus() throws Exception {
-        snapshot.getStatus();
-    }
-
-    @Test
-    public void getName() throws Exception {
-        snapshot.getName();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getDescription() throws Exception {
-        snapshot.getDescription();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"snapshot\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"volumeId\" : \"volumeid\"," + EOL
+        + "    \"size\" : 61," + EOL
+        + "    \"createdAt\" : \"createdat\"," + EOL
+        + "    \"displayName\" : \"name\"," + EOL
+        + "    \"displayDescription\" : \"description\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getVolumeId() throws Exception {
-        snapshot.getVolumeId();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getSize() throws Exception {
-        snapshot.getSize();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Snapshot.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Snapshot snapshot = objectMapper.readValue(JSON_FULL, Snapshot.class);
+        String json = objectMapper.writeValueAsString(snapshot);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getCreatedAt() throws Exception {
-        snapshot.getCreatedAt();
+    public void testMethods() throws Exception {
+        Snapshot snapshot = objectMapper.readValue(JSON_FULL, Snapshot.class);
+        snapshot.toString();
+        
+        String createdAt = snapshot.getCreatedAt();
+        Assert.assertNotNull(createdAt);
+        
+        Integer size = snapshot.getSize();
+        Assert.assertNotNull(size);
+        
+        String name = snapshot.getName();
+        Assert.assertNotNull(name);
+        
+        String volumeId = snapshot.getVolumeId();
+        Assert.assertNotNull(volumeId);
+        
+        String description = snapshot.getDescription();
+        Assert.assertNotNull(description);
+        
+        String id = snapshot.getId();
+        Assert.assertNotNull(id);
+        
+        String status = snapshot.getStatus();
+        Assert.assertNotNull(status);
     }
-
-}
\ No newline at end of file
+}
index 3c7ec60..9bf525b 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Snapshot;
+import com.woorea.openstack.nova.model.Snapshots;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SnapshotsTest {
 
-    Snapshots snapshots = new Snapshots();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"snapshots\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"volumeId\" : \"volumeid\"," + EOL
+        + "    \"size\" : 61," + EOL
+        + "    \"createdAt\" : \"createdat\"," + EOL
+        + "    \"displayName\" : \"name\"," + EOL
+        + "    \"displayDescription\" : \"description\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"volumeId\" : \"volumeid\"," + EOL
+        + "    \"size\" : 61," + EOL
+        + "    \"createdAt\" : \"createdat\"," + EOL
+        + "    \"displayName\" : \"name\"," + EOL
+        + "    \"displayDescription\" : \"description\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        snapshots.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Snapshots.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Snapshots snapshots = objectMapper.readValue(JSON_FULL, Snapshots.class);
+        String json = objectMapper.writeValueAsString(snapshots);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        snapshots.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Snapshots snapshots = objectMapper.readValue(JSON_FULL, Snapshots.class);
+        snapshots.toString();
+        
+        List<Snapshot> list = snapshots.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Snapshot x : snapshots) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/StartTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/StartTest.java
new file mode 100644 (file)
index 0000000..c96b74a
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Start;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class StartTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"os-start\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Start.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Start start = objectMapper.readValue(JSON_FULL, Start.class);
+        String json = objectMapper.writeValueAsString(start);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Start start = objectMapper.readValue(JSON_FULL, Start.class);
+        start.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/StopTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/StopTest.java
new file mode 100644 (file)
index 0000000..2abb35e
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Stop;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class StopTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"os-stop\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Stop.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Stop stop = objectMapper.readValue(JSON_FULL, Stop.class);
+        String json = objectMapper.writeValueAsString(stop);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Stop stop = objectMapper.readValue(JSON_FULL, Stop.class);
+        stop.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/SuspendTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/SuspendTest.java
new file mode 100644 (file)
index 0000000..bcbb0da
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Suspend;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class SuspendTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"suspend\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Suspend.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Suspend suspend = objectMapper.readValue(JSON_FULL, Suspend.class);
+        String json = objectMapper.writeValueAsString(suspend);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Suspend suspend = objectMapper.readValue(JSON_FULL, Suspend.class);
+        suspend.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/UnlockTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/UnlockTest.java
new file mode 100644 (file)
index 0000000..43ad515
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Unlock;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class UnlockTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"unlock\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Unlock.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Unlock unlock = objectMapper.readValue(JSON_FULL, Unlock.class);
+        String json = objectMapper.writeValueAsString(unlock);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Unlock unlock = objectMapper.readValue(JSON_FULL, Unlock.class);
+        unlock.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/UnpauseTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/UnpauseTest.java
new file mode 100644 (file)
index 0000000..f180b96
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Unpause;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class UnpauseTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"unpause\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Unpause.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Unpause unpause = objectMapper.readValue(JSON_FULL, Unpause.class);
+        String json = objectMapper.writeValueAsString(unpause);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Unpause unpause = objectMapper.readValue(JSON_FULL, Unpause.class);
+        unpause.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/UnrescueTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/UnrescueTest.java
new file mode 100644 (file)
index 0000000..6e92807
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.Unrescue;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class UnrescueTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"unrescue\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Unrescue.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Unrescue unrescue = objectMapper.readValue(JSON_FULL, Unrescue.class);
+        String json = objectMapper.writeValueAsString(unrescue);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Unrescue unrescue = objectMapper.readValue(JSON_FULL, Unrescue.class);
+        unrescue.toString();
+    }
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/VncConsoleTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/VncConsoleTest.java
new file mode 100644 (file)
index 0000000..8582bca
--- /dev/null
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.ServerAction.VncConsole;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class VncConsoleTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"console\" : {" + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"url\" : \"url\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + VncConsole.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        VncConsole vncconsole = objectMapper.readValue(JSON_FULL, VncConsole.class);
+        String json = objectMapper.writeValueAsString(vncconsole);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        VncConsole vncconsole = objectMapper.readValue(JSON_FULL, VncConsole.class);
+        vncconsole.toString();
+        
+        String type = vncconsole.getType();
+        Assert.assertNotNull(type);
+        
+        String url = vncconsole.getUrl();
+        Assert.assertNotNull(url);
+    }
+}
index 008e047..c51efe7 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.VolumeAttachment;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class VolumeAttachmentTest {
 
-    VolumeAttachment volumeAttachment = new VolumeAttachment();
-
-    @Test
-    public void getId() throws Exception {
-        volumeAttachment.getId();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void setId() throws Exception {
-        volumeAttachment.setId("Test");
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"volumeAttachment\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"volumeId\" : \"volumeid\"," + EOL
+        + "    \"serverId\" : \"serverid\"," + EOL
+        + "    \"device\" : \"device\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getVolumeId() throws Exception {
-        volumeAttachment.getVolumeId();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void setVolumeId() throws Exception {
-        volumeAttachment.setVolumeId("test");
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + VolumeAttachment.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        VolumeAttachment volumeattachment = objectMapper.readValue(JSON_FULL, VolumeAttachment.class);
+        String json = objectMapper.writeValueAsString(volumeattachment);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getServerId() throws Exception {
-        volumeAttachment.getServerId();
+    public void testMethods() throws Exception {
+        VolumeAttachment volumeattachment = objectMapper.readValue(JSON_FULL, VolumeAttachment.class);
+        volumeattachment.toString();
+        
+        String volumeId = volumeattachment.getVolumeId();
+        Assert.assertNotNull(volumeId);
+        volumeattachment.setVolumeId(volumeId);
+        
+        String id = volumeattachment.getId();
+        Assert.assertNotNull(id);
+        volumeattachment.setId(id);
+        
+        String device = volumeattachment.getDevice();
+        Assert.assertNotNull(device);
+        volumeattachment.setDevice(device);
+        
+        String serverId = volumeattachment.getServerId();
+        Assert.assertNotNull(serverId);
+        volumeattachment.setServerId(serverId);
     }
-
-    @Test
-    public void setServerId() throws Exception {
-        volumeAttachment.setServerId("test");
-    }
-
-    @Test
-    public void getDevice() throws Exception {
-        volumeAttachment.getDevice();
-    }
-
-    @Test
-    public void setDevice() throws Exception {
-        volumeAttachment.setDevice("test");
-    }
-
-}
\ No newline at end of file
+}
index 34b8e51..b84389b 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.VolumeAttachment;
+import com.woorea.openstack.nova.model.VolumeAttachments;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class VolumeAttachmentsTest {
 
-    VolumeAttachments volumeAttachments = new VolumeAttachments();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"volumeAttachments\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"volumeId\" : \"volumeid\"," + EOL
+        + "    \"serverId\" : \"serverid\"," + EOL
+        + "    \"device\" : \"device\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"volumeId\" : \"volumeid\"," + EOL
+        + "    \"serverId\" : \"serverid\"," + EOL
+        + "    \"device\" : \"device\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        volumeAttachments.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + VolumeAttachments.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        VolumeAttachments volumeattachments = objectMapper.readValue(JSON_FULL, VolumeAttachments.class);
+        String json = objectMapper.writeValueAsString(volumeattachments);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        volumeAttachments.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        VolumeAttachments volumeattachments = objectMapper.readValue(JSON_FULL, VolumeAttachments.class);
+        volumeattachments.toString();
+        
+        List<VolumeAttachment> list = volumeattachments.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") VolumeAttachment x : volumeattachments) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
index 1c44c34..5caf86d 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.VolumeForCreate;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import java.util.HashMap;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class VolumeForCreateTest {
 
-    VolumeForCreate volumeForCreate = new VolumeForCreate();
-
-    @Test
-    public void getSize() throws Exception {
-        volumeForCreate.getSize();
-    }
-
-    @Test
-    public void setSize() throws Exception {
-        volumeForCreate.setSize(1);
-    }
-
-    @Test
-    public void getAvailabilityZone() throws Exception {
-        volumeForCreate.getAvailabilityZone();
-    }
-
-    @Test
-    public void setAvailabilityZone() throws Exception {
-        volumeForCreate.setAvailabilityZone("test");
-    }
-
-    @Test
-    public void getName() throws Exception {
-        volumeForCreate.getName();
-    }
-
-    @Test
-    public void setName() throws Exception {
-        volumeForCreate.setName("test");
-    }
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"volume\" : {" + EOL
+        + "    \"size\" : 61," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"availability_zone\" : \"availabilityzone\"," + EOL
+        + "    \"display_name\" : \"name\"," + EOL
+        + "    \"display_description\" : \"description\"," + EOL
+        + "    \"snapshot_id\" : 3" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getDescription() throws Exception {
-        volumeForCreate.getDescription();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + VolumeForCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        VolumeForCreate volumeforcreate = objectMapper.readValue(JSON_FULL, VolumeForCreate.class);
+        String json = objectMapper.writeValueAsString(volumeforcreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void setDescription() throws Exception {
-        volumeForCreate.setDescription("test");
+    public void testMethods() throws Exception {
+        VolumeForCreate volumeforcreate = objectMapper.readValue(JSON_FULL, VolumeForCreate.class);
+        volumeforcreate.toString();
+        
+        Map<String,String> metadata = volumeforcreate.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        volumeforcreate.setMetadata(metadata);
+        
+        Integer snapshotId = volumeforcreate.getSnapshotId();
+        Assert.assertNotNull(snapshotId);
+        volumeforcreate.setSnapshotId(snapshotId);
+        
+        Integer size = volumeforcreate.getSize();
+        Assert.assertNotNull(size);
+        volumeforcreate.setSize(size);
+        
+        String name = volumeforcreate.getName();
+        Assert.assertNotNull(name);
+        volumeforcreate.setName(name);
+        
+        String description = volumeforcreate.getDescription();
+        Assert.assertNotNull(description);
+        volumeforcreate.setDescription(description);
+        
+        String availabilityZone = volumeforcreate.getAvailabilityZone();
+        Assert.assertNotNull(availabilityZone);
+        volumeforcreate.setAvailabilityZone(availabilityZone);
     }
-
-    @Test
-    public void getSnapshotId() throws Exception {
-        volumeForCreate.getSnapshotId();
-    }
-
-    @Test
-    public void setSnapshotId() throws Exception {
-        volumeForCreate.setSnapshotId(1);
-    }
-
-    @Test
-    public void getMetadata() throws Exception {
-        volumeForCreate.getMetadata();
-    }
-
-    @Test
-    public void setMetadata() throws Exception {
-        volumeForCreate.setMetadata(new HashMap<String, String>());
-    }
-
-}
\ No newline at end of file
+}
index a86c021..eae93e5 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.VolumeForImageCreate;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class VolumeForImageCreateTest {
 
-    VolumeForImageCreate volumeForImageCreate = new VolumeForImageCreate();
-
-    @Test
-    public void getTenantId() throws Exception {
-        volumeForImageCreate.getTenantId();
-    }
-
-    @Test
-    public void setTenantId() throws Exception {
-        volumeForImageCreate.setTenantId("Test");
-    }
-
-    @Test
-    public void getForce() throws Exception {
-        volumeForImageCreate.getForce();
-    }
-
-    @Test
-    public void setForce() throws Exception {
-        volumeForImageCreate.setForce(true);
-    }
-
-    @Test
-    public void getVolumeId() throws Exception {
-        volumeForImageCreate.getVolumeId();
-    }
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"os-volume_upload_image\" : {" + EOL
+        + "    \"volumeId\" : \"volumeid\"," + EOL
+        + "    \"tenantId\" : \"tenantid\"," + EOL
+        + "    \"force\" : false," + EOL
+        + "    \"container_format\" : \"container_format\"," + EOL
+        + "    \"disk_format\" : \"disk_format\"," + EOL
+        + "    \"image_name\" : \"image_name\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void setVolumeId() throws Exception {
-        volumeForImageCreate.setVolumeId("testid");
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + VolumeForImageCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        VolumeForImageCreate volumeforimagecreate = objectMapper.readValue(JSON_FULL, VolumeForImageCreate.class);
+        String json = objectMapper.writeValueAsString(volumeforimagecreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getContainer_format() throws Exception {
-        volumeForImageCreate.getContainer_format();
+    public void testMethods() throws Exception {
+        VolumeForImageCreate volumeforimagecreate = objectMapper.readValue(JSON_FULL, VolumeForImageCreate.class);
+        volumeforimagecreate.toString();
+        
+        String image_name = volumeforimagecreate.getImage_name();
+        Assert.assertNotNull(image_name);
+        volumeforimagecreate.setImage_name(image_name);
+        
+        String tenantId = volumeforimagecreate.getTenantId();
+        Assert.assertNotNull(tenantId);
+        volumeforimagecreate.setTenantId(tenantId);
+        
+        String volumeId = volumeforimagecreate.getVolumeId();
+        Assert.assertNotNull(volumeId);
+        volumeforimagecreate.setVolumeId(volumeId);
+        
+        String disk_format = volumeforimagecreate.getDisk_format();
+        Assert.assertNotNull(disk_format);
+        volumeforimagecreate.setDisk_format(disk_format);
+        
+        Boolean force = volumeforimagecreate.getForce();
+        Assert.assertNotNull(force);
+        volumeforimagecreate.setForce(force);
+        
+        String container_format = volumeforimagecreate.getContainer_format();
+        Assert.assertNotNull(container_format);
+        volumeforimagecreate.setContainer_format(container_format);
     }
-
-    @Test
-    public void setContainer_format() throws Exception {
-        volumeForImageCreate.setContainer_format("test");
-    }
-
-    @Test
-    public void getDisk_format() throws Exception {
-        volumeForImageCreate.getDisk_format();
-    }
-
-    @Test
-    public void setDisk_format() throws Exception {
-        volumeForImageCreate.setDisk_format("test");
-    }
-
-    @Test
-    public void getImage_name() throws Exception {
-        volumeForImageCreate.getImage_name();
-    }
-
-    @Test
-    public void setImage_name() throws Exception {
-        volumeForImageCreate.setImage_name("test");
-    }
-
-}
\ No newline at end of file
+}
index ede7d29..7a8d058 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Volume;
+import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class VolumeTest {
 
-    Volume volume = new Volume();
-
-    @Test
-    public void getId() throws Exception {
-        volume.getId();
-    }
-
-    @Test
-    public void getStatus() throws Exception {
-        volume.getStatus();
-    }
-
-    @Test
-    public void getName() throws Exception {
-        volume.getName();
-    }
-
-    @Test
-    public void getDescription() throws Exception {
-        volume.getDescription();
-    }
-
-    @Test
-    public void getAvailabilityZone() throws Exception {
-        volume.getAvailabilityZone();
-    }
-
-    @Test
-    public void getVolumeType() throws Exception {
-        volume.getVolumeType();
-    }
-
-    @Test
-    public void getSnapshotId() throws Exception {
-        volume.getSnapshotId();
-    }
+    private static final String EOL = System.lineSeparator();
 
-    @Test
-    public void getAttachments() throws Exception {
-        volume.getAttachments();
-    }
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"volume\" : {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"availabilityZone\" : \"availabilityzone\"," + EOL
+        + "    \"volumeType\" : \"volumetype\"," + EOL
+        + "    \"snapshotId\" : \"snapshotid\"," + EOL
+        + "    \"attachments\" : [ {" + EOL
+        + "      \"attachments-v1-k1\" : \"attachments-v1-v1\"," + EOL
+        + "      \"attachments-v1-k2\" : \"attachments-v1-v2\"" + EOL
+        + "    }, {" + EOL
+        + "      \"attachments-v2-k1\" : \"attachments-v2-v1\"," + EOL
+        + "      \"attachments-v2-k2\" : \"attachments-v2-v2\"" + EOL
+        + "    } ]," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"createdAt\" : \"createdat\"," + EOL
+        + "    \"size\" : 61," + EOL
+        + "    \"displayName\" : \"name\"," + EOL
+        + "    \"displayDescription\" : \"description\"" + EOL
+        + "  }" + EOL
+        + "}";
 
-    @Test
-    public void getMetadata() throws Exception {
-        volume.getMetadata();
-    }
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getCreatedAt() throws Exception {
-        volume.getCreatedAt();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Volume.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Volume volume = objectMapper.readValue(JSON_FULL, Volume.class);
+        String json = objectMapper.writeValueAsString(volume);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void getSize() throws Exception {
-        volume.getSize();
+    public void testMethods() throws Exception {
+        Volume volume = objectMapper.readValue(JSON_FULL, Volume.class);
+        volume.toString();
+        
+        String volumeType = volume.getVolumeType();
+        Assert.assertNotNull(volumeType);
+        
+        String createdAt = volume.getCreatedAt();
+        Assert.assertNotNull(createdAt);
+        
+        Map<String,String> metadata = volume.getMetadata();
+        Assert.assertNotNull(metadata);
+        Assert.assertEquals(2, metadata.size());
+        
+        List<Map<String,Object>> attachments = volume.getAttachments();
+        Assert.assertNotNull(attachments);
+        Assert.assertEquals(2, attachments.size());
+        
+        String snapshotId = volume.getSnapshotId();
+        Assert.assertNotNull(snapshotId);
+        
+        Integer size = volume.getSize();
+        Assert.assertNotNull(size);
+        
+        String name = volume.getName();
+        Assert.assertNotNull(name);
+        
+        String description = volume.getDescription();
+        Assert.assertNotNull(description);
+        
+        String id = volume.getId();
+        Assert.assertNotNull(id);
+        
+        String availabilityZone = volume.getAvailabilityZone();
+        Assert.assertNotNull(availabilityZone);
+        
+        String status = volume.getStatus();
+        Assert.assertNotNull(status);
     }
-
-}
\ No newline at end of file
+}
diff --git a/nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeTypeTest.java b/nova-model/src/test/java/com/woorea/openstack/nova/model/VolumeTypeTest.java
new file mode 100644 (file)
index 0000000..b485dbb
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.nova.model;
+
+import com.woorea.openstack.nova.model.VolumeType;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class VolumeTypeTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"volume-type\" : { }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + VolumeType.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        VolumeType volumetype = objectMapper.readValue(JSON_FULL, VolumeType.class);
+        String json = objectMapper.writeValueAsString(volumetype);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        VolumeType volumetype = objectMapper.readValue(JSON_FULL, VolumeType.class);
+        volumetype.toString();
+    }
+}
index 75fe600..903b67d 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.VolumeType;
+import com.woorea.openstack.nova.model.VolumeTypes;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class VolumeTypesTest {
 
-    VolumeTypes volumeTypes = new VolumeTypes();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"volume-types\" : [ { }, { } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        volumeTypes.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + VolumeTypes.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        VolumeTypes volumetypes = objectMapper.readValue(JSON_FULL, VolumeTypes.class);
+        String json = objectMapper.writeValueAsString(volumetypes);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-}
\ No newline at end of file
+    @Test
+    public void testMethods() throws Exception {
+        VolumeTypes volumetypes = objectMapper.readValue(JSON_FULL, VolumeTypes.class);
+        volumetypes.toString();
+        
+        List<VolumeType> list = volumetypes.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") VolumeType x : volumetypes) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
index fae5f1b..4c2d5b1 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package com.woorea.openstack.nova.model;
 
+import com.woorea.openstack.nova.model.Volume;
+import com.woorea.openstack.nova.model.Volumes;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class VolumesTest {
 
-    Volumes volumes = new Volumes();
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"volumes\" : [ {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"availabilityZone\" : \"availabilityzone\"," + EOL
+        + "    \"volumeType\" : \"volumetype\"," + EOL
+        + "    \"snapshotId\" : \"snapshotid\"," + EOL
+        + "    \"attachments\" : [ {" + EOL
+        + "      \"attachments-v1-k1\" : \"attachments-v1-v1\"," + EOL
+        + "      \"attachments-v1-k2\" : \"attachments-v1-v2\"" + EOL
+        + "    }, {" + EOL
+        + "      \"attachments-v2-k1\" : \"attachments-v2-v1\"," + EOL
+        + "      \"attachments-v2-k2\" : \"attachments-v2-v2\"" + EOL
+        + "    } ]," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"createdAt\" : \"createdat\"," + EOL
+        + "    \"size\" : 61," + EOL
+        + "    \"displayName\" : \"name\"," + EOL
+        + "    \"displayDescription\" : \"description\"" + EOL
+        + "  }, {" + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"availabilityZone\" : \"availabilityzone\"," + EOL
+        + "    \"volumeType\" : \"volumetype\"," + EOL
+        + "    \"snapshotId\" : \"snapshotid\"," + EOL
+        + "    \"attachments\" : [ {" + EOL
+        + "      \"attachments-v1-k1\" : \"attachments-v1-v1\"," + EOL
+        + "      \"attachments-v1-k2\" : \"attachments-v1-v2\"" + EOL
+        + "    }, {" + EOL
+        + "      \"attachments-v2-k1\" : \"attachments-v2-v1\"," + EOL
+        + "      \"attachments-v2-k2\" : \"attachments-v2-v2\"" + EOL
+        + "    } ]," + EOL
+        + "    \"metadata\" : {" + EOL
+        + "      \"metadata-k1\" : \"metadata-v1\"," + EOL
+        + "      \"metadata-k2\" : \"metadata-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"createdAt\" : \"createdat\"," + EOL
+        + "    \"size\" : 61," + EOL
+        + "    \"displayName\" : \"name\"," + EOL
+        + "    \"displayDescription\" : \"description\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
-    public void getList() throws Exception {
-        volumes.getList();
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Volumes.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Volumes volumes = objectMapper.readValue(JSON_FULL, Volumes.class);
+        String json = objectMapper.writeValueAsString(volumes);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void iterator() throws Exception {
-        volumes.iterator();
+    @Test
+    public void testMethods() throws Exception {
+        Volumes volumes = objectMapper.readValue(JSON_FULL, Volumes.class);
+        volumes.toString();
+        
+        List<Volume> list = volumes.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Volume x : volumes) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
     }
-
-}
\ No newline at end of file
+}
diff --git a/pom.xml b/pom.xml
index 676584c..ba123f8 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,6 @@
                <nexusproxy>https://nexus.onap.org</nexusproxy>
                <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
                <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
-               <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
                <siteNexusPath>/content/sites/site/org/onap/so/libs/${project.version}</siteNexusPath>
        </properties>
        <distributionManagement>
        </licenses>
        <inceptionYear>2012</inceptionYear>
        <repositories>
+               <repository>
+                       <id>ecomp-public</id>
+                       <url>https://nexus.onap.org/content/repositories/public/</url>
+                       <snapshots>
+                               <enabled>false</enabled>
+                       </snapshots>
+               </repository>
+               <repository>
+                       <id>ecomp-releases</id>
+                       <url>https://nexus.onap.org/content/repositories/releases/</url>
+                       <snapshots>
+                               <enabled>false</enabled>
+                       </snapshots>
+               </repository>
+               <repository>
+                       <id>ecomp-snapshots</id>
+                       <url>https://nexus.onap.org/content/repositories/snapshots/</url>
+                       <releases>
+                               <enabled>false</enabled>
+                       </releases>
+               </repository>
                <repository>
                        <id>central</id>
                        <name>Maven 2 repository</name>
                        <dependency>
                                <groupId>junit</groupId>
                                <artifactId>junit</artifactId>
-                               <version>4.11</version>
+                               <version>4.12</version>
                                <scope>test</scope>
                        </dependency>
                                <dependency>
                                <version>1.6.2</version>
                                <scope>test</scope>
                        </dependency>
+                       <dependency>
+                               <groupId>org.skyscreamer</groupId>
+                               <artifactId>jsonassert</artifactId>
+                               <version>1.4.0</version>
+                               <scope>test</scope>
+                       </dependency>
                        <dependency>
                                <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
                                <artifactId>openstack-client</artifactId>
index 7100fb0..fd0a173 100644 (file)
        <name>OpenStack Quantum Model</name>
        <description>OpenStack Quantum Model</description>
        <dependencies>
-           <dependency>
+               <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
-                       <version>4.11</version>
                        <scope>test</scope>
-           </dependency>
-  </dependencies>
+               </dependency>
+               <dependency>
+                       <groupId>org.skyscreamer</groupId>
+                       <artifactId>jsonassert</artifactId>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
 </project>
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/BindingTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/BindingTest.java
new file mode 100644 (file)
index 0000000..b99c167
--- /dev/null
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Port.Binding;
+import java.util.Map;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class BindingTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"binding:host_id\" : \"hostid\"," + EOL
+        + "  \"binding:vif_type\" : \"viftype\"," + EOL
+        + "  \"binding:vnic_type\" : \"vnictype\"," + EOL
+        + "  \"binding:vif_details\" : {" + EOL
+        + "    \"vifdetails-k1\" : \"vifdetails-v1\"," + EOL
+        + "    \"vifdetails-k2\" : \"vifdetails-v2\"" + EOL
+        + "  }," + EOL
+        + "  \"binding:profile\" : {" + EOL
+        + "    \"profile-k1\" : \"profile-v1\"," + EOL
+        + "    \"profile-k2\" : \"profile-v2\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Binding.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Binding binding = objectMapper.readValue(JSON_FULL, Binding.class);
+        String json = objectMapper.writeValueAsString(binding);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Binding binding = objectMapper.readValue(JSON_FULL, Binding.class);
+        binding.toString();
+        
+        String vnicType = binding.getVnicType();
+        Assert.assertNotNull(vnicType);
+        binding.setVnicType(vnicType);
+        
+        Map<String,String> vifDetails = binding.getVifDetails();
+        Assert.assertNotNull(vifDetails);
+        Assert.assertEquals(2, vifDetails.size());
+        binding.setVifDetails(vifDetails);
+        
+        Map<String,String> profile = binding.getProfile();
+        Assert.assertNotNull(profile);
+        Assert.assertEquals(2, profile.size());
+        binding.setProfile(profile);
+        
+        String hostId = binding.getHostId();
+        Assert.assertNotNull(hostId);
+        binding.setHostId(hostId);
+        
+        String vifType = binding.getVifType();
+        Assert.assertNotNull(vifType);
+        binding.setVifType(vifType);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/GatewayInfoTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/GatewayInfoTest.java
new file mode 100644 (file)
index 0000000..3e8c37f
--- /dev/null
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.GatewayInfo;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class GatewayInfoTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"network_id\" : \"networkid\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + GatewayInfo.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        GatewayInfo gatewayinfo = objectMapper.readValue(JSON_FULL, GatewayInfo.class);
+        String json = objectMapper.writeValueAsString(gatewayinfo);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        GatewayInfo gatewayinfo = objectMapper.readValue(JSON_FULL, GatewayInfo.class);
+        gatewayinfo.toString();
+        
+        String networkId = gatewayinfo.getNetworkId();
+        Assert.assertNotNull(networkId);
+        gatewayinfo.setNetworkId(networkId);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/HostRouteTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/HostRouteTest.java
new file mode 100644 (file)
index 0000000..bfa7280
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.HostRoute;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class HostRouteTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"destination\" : \"destination\"," + EOL
+        + "  \"nexthop\" : \"nexthop\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + HostRoute.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        HostRoute hostroute = objectMapper.readValue(JSON_FULL, HostRoute.class);
+        String json = objectMapper.writeValueAsString(hostroute);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        HostRoute hostroute = objectMapper.readValue(JSON_FULL, HostRoute.class);
+        hostroute.toString();
+        
+        String destination = hostroute.getDestination();
+        Assert.assertNotNull(destination);
+        hostroute.setDestination(destination);
+        
+        String nexthop = hostroute.getNexthop();
+        Assert.assertNotNull(nexthop);
+        hostroute.setNexthop(nexthop);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/IpTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/IpTest.java
new file mode 100644 (file)
index 0000000..79fbff5
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Port.Ip;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class IpTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"ip_address\" : \"address\"," + EOL
+        + "  \"subnet_id\" : \"subnetid\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Ip.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Ip ip = objectMapper.readValue(JSON_FULL, Ip.class);
+        String json = objectMapper.writeValueAsString(ip);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Ip ip = objectMapper.readValue(JSON_FULL, Ip.class);
+        ip.toString();
+        
+        String subnetId = ip.getSubnetId();
+        Assert.assertNotNull(subnetId);
+        ip.setSubnetId(subnetId);
+        
+        String address = ip.getAddress();
+        Assert.assertNotNull(address);
+        ip.setAddress(address);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/IpVersionTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/IpVersionTest.java
new file mode 100644 (file)
index 0000000..b2a8604
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Subnet.IpVersion;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class IpVersionTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "4";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + IpVersion.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        IpVersion ipversion = objectMapper.readValue(JSON_FULL, IpVersion.class);
+        String json = objectMapper.writeValueAsString(ipversion);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        IpVersion ipversion = objectMapper.readValue(JSON_FULL, IpVersion.class);
+    }
+}
index e736359..b9d5b37 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.quantum.model;
 
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
-
-import java.util.Arrays;
-
+import com.woorea.openstack.quantum.model.Network;
+import com.woorea.openstack.quantum.model.Segment;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
 import org.codehaus.jackson.map.ObjectMapper;
-import org.junit.Before;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class NetworkTest {
 
-    private static final String ID = "testId";
-
-    private static final boolean ADMIN_STATE_UP = true;
-
-    private static final String NAME = "name";
-
-    private static final String TENANT_ID = "tenantId";
-
-    private static final String SHARED = "shared";
-
-    private static final String STATUS = "status";
-
-    private static final String SUBNET = "subnet";
-
-    private static final String PROVIDER_NETWORK_TYPE = "vlan";
-
-    private static final String PROVIDER_PHYSICAL_NETWORK = "physicalNetwork";
-
-    private static final int PROVIDER_SEGMENTATION_ID = 100;
-
-    private static final String ROUTER_EXTERNAL = "routerExternal";
-
-    /**
-     * JSON with read only attributes.
-     */
-    private static final String NETWORK_JSON = "{"
-            + "  \"network\" : {"
-            + "    \"id\" : \"" + ID + "\","
-            + "    \"status\" : \"" + STATUS + "\","
-            + "    \"subnets\" : [ \"" + SUBNET + "\" ]"
-            + "  }"
-            + "}";
-
-    private ObjectMapper objectMapper;
-
-    private String serializedNetwork;
-
-    @Before
-    public void setUp() throws Exception {
-        objectMapper = PortTest.initializeObjectMapper();
-    }
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"network\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"shared\" : \"shared\"," + EOL
+        + "    \"segments\" : [ {" + EOL
+        + "      \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "      \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "      \"provider:segmentation_id\" : 92" + EOL
+        + "    }, {" + EOL
+        + "      \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "      \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "      \"provider:segmentation_id\" : 92" + EOL
+        + "    } ]," + EOL
+        + "    \"admin_state_up\" : false," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "    \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "    \"provider:segmentation_id\" : 92," + EOL
+        + "    \"router:external\" : \"routerexternal\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
     public void testSerialization() throws Exception {
-        Network network = new Network();
-        network.setId(ID);
-        network.setProviderNetworkType(PROVIDER_NETWORK_TYPE);
-        network.setProviderPhysicalNetwork(PROVIDER_PHYSICAL_NETWORK);
-        network.setProviderSegmentationId(PROVIDER_SEGMENTATION_ID);
-        network.setAdminStateUp(ADMIN_STATE_UP);
-        network.setSubnets(Arrays.asList(SUBNET));
-        network.setRouterExternal(ROUTER_EXTERNAL);
-        network.setName(NAME);
-        network.setShared(SHARED);
-        network.setTenantId(TENANT_ID);
-
-        serializedNetwork = objectMapper.writeValueAsString(network);
-        assertThat(serializedNetwork, not(containsString(ID)));
-        assertThat(serializedNetwork, not(containsString(STATUS)));
-        assertThat(serializedNetwork, not(containsString(SUBNET)));
-        assertThat(serializedNetwork, containsString("\"admin_state_up\" : " + ADMIN_STATE_UP));
-        assertThat(serializedNetwork, containsString(NAME));
-        assertThat(serializedNetwork, containsString(SHARED));
-        assertThat(serializedNetwork, containsString(TENANT_ID));
-        assertThat(serializedNetwork, containsString(ROUTER_EXTERNAL));
-        assertThat(serializedNetwork, containsString(PROVIDER_NETWORK_TYPE));
-        assertThat(serializedNetwork, containsString(PROVIDER_PHYSICAL_NETWORK));
-        assertThat(serializedNetwork, containsString(Integer.toString(PROVIDER_SEGMENTATION_ID)));
-    }
-
-    @Test
-    public void testSerializationEmpty() throws Exception {
-        Network network = new Network();
-        serializedNetwork = objectMapper.writeValueAsString(network);
-
-        assertThat(serializedNetwork, containsString("\"network\" : { }"));
+        System.out.println("CLASS: " + Network.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Network network = objectMapper.readValue(JSON_FULL, Network.class);
+        String json = objectMapper.writeValueAsString(network);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void testDeserializationReadOnlyFields() throws Exception {
-        Network network = objectMapper.readValue(NETWORK_JSON, Network.class);
-
-        assertThat(network.getId(), is(equalTo(ID)));
-        assertThat(network.getSubnets(), hasItem(equalTo(SUBNET)));
-        assertThat(network.getStatus(), is(equalTo(STATUS)));
-    }
-
-    @Test
-    public void testDeserialization() throws Exception {
-        testSerialization();
-        Network network = objectMapper.readValue(serializedNetwork, Network.class);
-
-        assertThat(network.getName(), is(equalTo(NAME)));
-        assertThat(network.isAdminStateUp(), is(equalTo(ADMIN_STATE_UP)));
-        assertThat(network.getShared(), is(equalTo(SHARED)));
-        assertThat(network.getTenantId(), is(equalTo(TENANT_ID)));
-        assertThat(network.getRouterExternal(), is(equalTo(ROUTER_EXTERNAL)));
-        assertThat(network.getProviderNetworkType(), is(equalTo(PROVIDER_NETWORK_TYPE)));
-        assertThat(network.getProviderPhysicalNetwork(), is(equalTo(PROVIDER_PHYSICAL_NETWORK)));
-        assertThat(network.getProviderSegmentationId(), is(equalTo(PROVIDER_SEGMENTATION_ID)));
+    public void testMethods() throws Exception {
+        Network network = objectMapper.readValue(JSON_FULL, Network.class);
+        network.toString();
+        
+        String shared = network.getShared();
+        Assert.assertNotNull(shared);
+        network.setShared(shared);
+        
+        String providerNetworkType = network.getProviderNetworkType();
+        Assert.assertNotNull(providerNetworkType);
+        network.setProviderNetworkType(providerNetworkType);
+        
+        String routerExternal = network.getRouterExternal();
+        Assert.assertNotNull(routerExternal);
+        network.setRouterExternal(routerExternal);
+        
+        Integer providerSegmentationId = network.getProviderSegmentationId();
+        Assert.assertNotNull(providerSegmentationId);
+        network.setProviderSegmentationId(providerSegmentationId);
+        
+        List<Segment> segments = network.getSegments();
+        Assert.assertNotNull(segments);
+        Assert.assertEquals(2, segments.size());
+        network.setSegments(segments);
+        
+        Boolean adminStateUp = network.getAdminStateUp();
+        Assert.assertNotNull(adminStateUp);
+        network.setAdminStateUp(adminStateUp);
+        
+        String tenantId = network.getTenantId();
+        Assert.assertNotNull(tenantId);
+        network.setTenantId(tenantId);
+        
+        String name = network.getName();
+        Assert.assertNotNull(name);
+        network.setName(name);
+        
+        String providerPhysicalNetwork = network.getProviderPhysicalNetwork();
+        Assert.assertNotNull(providerPhysicalNetwork);
+        network.setProviderPhysicalNetwork(providerPhysicalNetwork);
     }
 }
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworksTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworksTest.java
new file mode 100644 (file)
index 0000000..dd39cf5
--- /dev/null
@@ -0,0 +1,110 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Network;
+import com.woorea.openstack.quantum.model.Networks;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class NetworksTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"networks\" : [ {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"shared\" : \"shared\"," + EOL
+        + "    \"segments\" : [ {" + EOL
+        + "      \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "      \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "      \"provider:segmentation_id\" : 92" + EOL
+        + "    }, {" + EOL
+        + "      \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "      \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "      \"provider:segmentation_id\" : 92" + EOL
+        + "    } ]," + EOL
+        + "    \"admin_state_up\" : false," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "    \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "    \"provider:segmentation_id\" : 92," + EOL
+        + "    \"router:external\" : \"routerexternal\"" + EOL
+        + "  }, {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"shared\" : \"shared\"," + EOL
+        + "    \"segments\" : [ {" + EOL
+        + "      \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "      \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "      \"provider:segmentation_id\" : 92" + EOL
+        + "    }, {" + EOL
+        + "      \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "      \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "      \"provider:segmentation_id\" : 92" + EOL
+        + "    } ]," + EOL
+        + "    \"admin_state_up\" : false," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "    \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "    \"provider:segmentation_id\" : 92," + EOL
+        + "    \"router:external\" : \"routerexternal\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Networks.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Networks networks = objectMapper.readValue(JSON_FULL, Networks.class);
+        String json = objectMapper.writeValueAsString(networks);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Networks networks = objectMapper.readValue(JSON_FULL, Networks.class);
+        networks.toString();
+        
+        List<Network> list = networks.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        networks.setList(list);
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Network x : networks) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NeutronErrorTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NeutronErrorTest.java
new file mode 100644 (file)
index 0000000..a0031ee
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.NeutronError;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class NeutronErrorTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"NeutronError\" : {" + EOL
+        + "    \"type\" : \"type\"," + EOL
+        + "    \"message\" : \"message\"," + EOL
+        + "    \"detail\" : \"detail\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + NeutronError.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        NeutronError neutronerror = objectMapper.readValue(JSON_FULL, NeutronError.class);
+        String json = objectMapper.writeValueAsString(neutronerror);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        NeutronError neutronerror = objectMapper.readValue(JSON_FULL, NeutronError.class);
+        neutronerror.toString();
+        
+        String detail = neutronerror.getDetail();
+        Assert.assertNotNull(detail);
+        
+        String type = neutronerror.getType();
+        Assert.assertNotNull(type);
+        
+        String message = neutronerror.getMessage();
+        Assert.assertNotNull(message);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PoolTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PoolTest.java
new file mode 100644 (file)
index 0000000..c2cf38e
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Pool;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class PoolTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"start\" : \"start\"," + EOL
+        + "  \"end\" : \"end\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Pool.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Pool pool = objectMapper.readValue(JSON_FULL, Pool.class);
+        String json = objectMapper.writeValueAsString(pool);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Pool pool = objectMapper.readValue(JSON_FULL, Pool.class);
+        pool.toString();
+        
+        String start = pool.getStart();
+        Assert.assertNotNull(start);
+        pool.setStart(start);
+        
+        String end = pool.getEnd();
+        Assert.assertNotNull(end);
+        pool.setEnd(end);
+    }
+}
index 7baa8d9..756753d 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.quantum.model;
 
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
-
-import java.util.ArrayList;
-import java.util.Arrays;
+import com.woorea.openstack.quantum.model.Port;
+import com.woorea.openstack.quantum.model.Port.Binding;
+import com.woorea.openstack.quantum.model.Port.Ip;
 import java.util.List;
-
 import org.codehaus.jackson.map.DeserializationConfig;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
 import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
-import org.hamcrest.CustomMatcher;
-import org.junit.Before;
+import org.junit.Assert;
 import org.junit.Test;
-
-import com.woorea.openstack.quantum.model.Port.Ip;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class PortTest {
 
-    private static final String TENANT_ID = "tenantId";
-
-    private static final String STATUS = "status";
-
-    private static final String NETWORK_ID = "networkId";
-
-    private static final String NAME = "name";
-
-    private static final String MAC_ADDRESS = "macAddress";
-
-    private static final String DEVICE_OWNER = "deviceOwner";
-
-    private static final String DEVICE_ID = "deviceId";
-
-    private static final String IP_SUBNET_ID = "ipSubnetId";
-
-    private static final String IP_ADDRESS = "10.0.0.1";
-
-    private static final boolean ADMIN_STATE_UP = true;
-
-    private static final String SEC_GROUP = "secGroup";
-
-    private static final String ID = "testId";
-
-    /**
-     * JSON with read only attributes.
-     */
-    private static final String PORT_JSON = "{"
-            + "  \"port\" : {"
-            + "    \"id\" : \"" + ID + "\","
-            + "    \"status\" : \"" + STATUS + "\""
-            + "  }"
-            + "}";
-
-    private ObjectMapper objectMapper;
-
-    private String serializedPort;
-
-    @Before
-    public void setUp() throws Exception {
-        objectMapper = initializeObjectMapper();
-    }
-
-    public static ObjectMapper initializeObjectMapper() {
-        ObjectMapper objectMapper = new ObjectMapper();
-        objectMapper.setSerializationInclusion(Inclusion.NON_NULL)
-                .enable(SerializationConfig.Feature.INDENT_OUTPUT)
-                .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
-                .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
-                .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
-        return objectMapper;
-    }
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"port\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"binding:host_id\" : \"hostid\"," + EOL
+        + "    \"binding:vif_type\" : \"viftype\"," + EOL
+        + "    \"binding:vnic_type\" : \"vnictype\"," + EOL
+        + "    \"binding:vif_details\" : {" + EOL
+        + "      \"vifdetails-k1\" : \"vifdetails-v1\"," + EOL
+        + "      \"vifdetails-k2\" : \"vifdetails-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"binding:profile\" : {" + EOL
+        + "      \"profile-k1\" : \"profile-v1\"," + EOL
+        + "      \"profile-k2\" : \"profile-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"admin_state_up\" : false," + EOL
+        + "    \"device_id\" : \"deviceid\"," + EOL
+        + "    \"device_owner\" : \"deviceowner\"," + EOL
+        + "    \"fixed_ips\" : [ {" + EOL
+        + "      \"ip_address\" : \"address\"," + EOL
+        + "      \"subnet_id\" : \"subnetid\"" + EOL
+        + "    }, {" + EOL
+        + "      \"ip_address\" : \"address\"," + EOL
+        + "      \"subnet_id\" : \"subnetid\"" + EOL
+        + "    } ]," + EOL
+        + "    \"mac_address\" : \"macaddress\"," + EOL
+        + "    \"network_id\" : \"networkid\"," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"security_groups\" : [ \"securitygroups-v1\", \"securitygroups-v2\" ]" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
     public void testSerialization() throws Exception {
-        Port port = new Port();
-        port.setId(ID);
-        port.setAdminStateUp(ADMIN_STATE_UP);
-        port.setSecurityGroups(Arrays.asList(SEC_GROUP));
-        port.setDeviceId(DEVICE_ID);
-        port.setDeviceOwner(DEVICE_OWNER);
-        port.setMacAddress(MAC_ADDRESS);
-        port.setName(NAME);
-        port.setNetworkId(NETWORK_ID);
-        port.setStatus(STATUS);
-        port.setTenantId(TENANT_ID);
-
-        List<Ip> ips = new ArrayList<Port.Ip>();
-        Ip ip = new Ip();
-        ip.setAddress(IP_ADDRESS);
-        ip.setSubnetId(IP_SUBNET_ID);
-        ips.add(ip);
-        port.setList(ips);
-
-        serializedPort = objectMapper.writeValueAsString(port);
-        assertThat(serializedPort, not(containsString(ID)));
-        assertThat(serializedPort, not(containsString(STATUS)));
-        assertThat(serializedPort, containsString("\"admin_state_up\" : " + ADMIN_STATE_UP));
-        assertThat(serializedPort, containsString(SEC_GROUP));
-        assertThat(serializedPort, containsString(IP_ADDRESS));
-        assertThat(serializedPort, containsString(DEVICE_ID));
-        assertThat(serializedPort, containsString(DEVICE_OWNER));
-        assertThat(serializedPort, containsString(MAC_ADDRESS));
-        assertThat(serializedPort, containsString(NAME));
-        assertThat(serializedPort, containsString(NETWORK_ID));
-        assertThat(serializedPort, containsString(TENANT_ID));
-    }
-
-    @Test
-    public void testSerializationEmpty() throws Exception {
-        Port port = new Port();
-        serializedPort = objectMapper.writeValueAsString(port);
-
-        assertThat(serializedPort, containsString("\"port\" : { }"));
+        System.out.println("CLASS: " + Port.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Port port = objectMapper.readValue(JSON_FULL, Port.class);
+        String json = objectMapper.writeValueAsString(port);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void testDeserializationReadOnlyFields() throws Exception {
-        Port port = objectMapper.readValue(PORT_JSON, Port.class);
-
-        assertThat(port.getId(), is(equalTo(ID)));
-        assertThat(port.getStatus(), is(equalTo(STATUS)));
-    }
-
-    @Test
-    public void testDeserializationAfterSerialization() throws Exception {
-        testSerialization();
-        Port port = objectMapper.readValue(serializedPort, Port.class);
-
-        assertThat(port.getAdminStateUp(), is(equalTo(ADMIN_STATE_UP)));
-        assertThat(port.getDeviceId(), is(equalTo(DEVICE_ID)));
-        assertThat(port.getDeviceOwner(), is(equalTo(DEVICE_OWNER)));
-        assertThat(port.getMacAddress(), is(equalTo(MAC_ADDRESS)));
-        assertThat(port.getName(), is(equalTo(NAME)));
-        assertThat(port.getNetworkId(), is(equalTo(NETWORK_ID)));
-        assertThat(port.getTenantId(), is(equalTo(TENANT_ID)));
-
-        assertThat(port.getSecurityGroups(), hasItem(equalTo(SEC_GROUP)));
-        assertThat(port.getList(), hasItem(new CustomMatcher<Ip>(
-                "an Ip object with address " + IP_ADDRESS + " and subnet id " + IP_SUBNET_ID) {
-
-            @Override
-            public boolean matches(Object ip) {
-                return ip instanceof Ip
-                        && IP_ADDRESS.equals(((Ip) ip).getAddress())
-                        && IP_SUBNET_ID.equals(((Ip) ip).getSubnetId());
-            }
-        }));
+    public void testMethods() throws Exception {
+        Port port = objectMapper.readValue(JSON_FULL, Port.class);
+        port.toString();
+        
+        String deviceOwner = port.getDeviceOwner();
+        Assert.assertNotNull(deviceOwner);
+        port.setDeviceOwner(deviceOwner);
+        
+        Boolean adminStateUp = port.getAdminStateUp();
+        Assert.assertNotNull(adminStateUp);
+        port.setAdminStateUp(adminStateUp);
+        
+        String name = port.getName();
+        Assert.assertNotNull(name);
+        port.setName(name);
+        
+        String tenantId = port.getTenantId();
+        Assert.assertNotNull(tenantId);
+        port.setTenantId(tenantId);
+        
+        Binding binding = port.getBinding();
+        Assert.assertNotNull(binding);
+        port.setBinding(binding);
+        
+        String macAddress = port.getMacAddress();
+        Assert.assertNotNull(macAddress);
+        port.setMacAddress(macAddress);
+        
+        String networkId = port.getNetworkId();
+        Assert.assertNotNull(networkId);
+        port.setNetworkId(networkId);
+        
+        List<Ip> list = port.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        port.setList(list);
+        
+        List<String> securityGroups = port.getSecurityGroups();
+        Assert.assertNotNull(securityGroups);
+        Assert.assertEquals(2, securityGroups.size());
+        port.setSecurityGroups(securityGroups);
+        
+        String deviceId = port.getDeviceId();
+        Assert.assertNotNull(deviceId);
+        port.setDeviceId(deviceId);
     }
 }
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortsTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortsTest.java
new file mode 100644 (file)
index 0000000..860ea7c
--- /dev/null
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Port;
+import com.woorea.openstack.quantum.model.Ports;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class PortsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"ports\" : [ {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"binding:host_id\" : \"hostid\"," + EOL
+        + "    \"binding:vif_type\" : \"viftype\"," + EOL
+        + "    \"binding:vnic_type\" : \"vnictype\"," + EOL
+        + "    \"binding:vif_details\" : {" + EOL
+        + "      \"vifdetails-k1\" : \"vifdetails-v1\"," + EOL
+        + "      \"vifdetails-k2\" : \"vifdetails-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"binding:profile\" : {" + EOL
+        + "      \"profile-k1\" : \"profile-v1\"," + EOL
+        + "      \"profile-k2\" : \"profile-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"admin_state_up\" : false," + EOL
+        + "    \"device_id\" : \"deviceid\"," + EOL
+        + "    \"device_owner\" : \"deviceowner\"," + EOL
+        + "    \"fixed_ips\" : [ {" + EOL
+        + "      \"ip_address\" : \"address\"," + EOL
+        + "      \"subnet_id\" : \"subnetid\"" + EOL
+        + "    }, {" + EOL
+        + "      \"ip_address\" : \"address\"," + EOL
+        + "      \"subnet_id\" : \"subnetid\"" + EOL
+        + "    } ]," + EOL
+        + "    \"mac_address\" : \"macaddress\"," + EOL
+        + "    \"network_id\" : \"networkid\"," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"security_groups\" : [ \"securitygroups-v1\", \"securitygroups-v2\" ]" + EOL
+        + "  }, {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"binding:host_id\" : \"hostid\"," + EOL
+        + "    \"binding:vif_type\" : \"viftype\"," + EOL
+        + "    \"binding:vnic_type\" : \"vnictype\"," + EOL
+        + "    \"binding:vif_details\" : {" + EOL
+        + "      \"vifdetails-k1\" : \"vifdetails-v1\"," + EOL
+        + "      \"vifdetails-k2\" : \"vifdetails-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"binding:profile\" : {" + EOL
+        + "      \"profile-k1\" : \"profile-v1\"," + EOL
+        + "      \"profile-k2\" : \"profile-v2\"" + EOL
+        + "    }," + EOL
+        + "    \"admin_state_up\" : false," + EOL
+        + "    \"device_id\" : \"deviceid\"," + EOL
+        + "    \"device_owner\" : \"deviceowner\"," + EOL
+        + "    \"fixed_ips\" : [ {" + EOL
+        + "      \"ip_address\" : \"address\"," + EOL
+        + "      \"subnet_id\" : \"subnetid\"" + EOL
+        + "    }, {" + EOL
+        + "      \"ip_address\" : \"address\"," + EOL
+        + "      \"subnet_id\" : \"subnetid\"" + EOL
+        + "    } ]," + EOL
+        + "    \"mac_address\" : \"macaddress\"," + EOL
+        + "    \"network_id\" : \"networkid\"," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"security_groups\" : [ \"securitygroups-v1\", \"securitygroups-v2\" ]" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Ports.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Ports ports = objectMapper.readValue(JSON_FULL, Ports.class);
+        String json = objectMapper.writeValueAsString(ports);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Ports ports = objectMapper.readValue(JSON_FULL, Ports.class);
+        ports.toString();
+        
+        List<Port> list = ports.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        ports.setList(list);
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Port x : ports) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForAddInterfaceTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForAddInterfaceTest.java
new file mode 100644 (file)
index 0000000..148637f
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.RouterForAddInterface;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RouterForAddInterfaceTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"routerId\" : \"routerid\"," + EOL
+        + "  \"subnet_id\" : \"subnetid\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + RouterForAddInterface.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        RouterForAddInterface routerforaddinterface = objectMapper.readValue(JSON_FULL, RouterForAddInterface.class);
+        String json = objectMapper.writeValueAsString(routerforaddinterface);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        RouterForAddInterface routerforaddinterface = objectMapper.readValue(JSON_FULL, RouterForAddInterface.class);
+        routerforaddinterface.toString();
+        
+        String subnetId = routerforaddinterface.getSubnetId();
+        Assert.assertNotNull(subnetId);
+        routerforaddinterface.setSubnetId(subnetId);
+        
+        String routerId = routerforaddinterface.getRouterId();
+        Assert.assertNotNull(routerId);
+        routerforaddinterface.setRouterId(routerId);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForCreateTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterForCreateTest.java
new file mode 100644 (file)
index 0000000..f7df840
--- /dev/null
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.GatewayInfo;
+import com.woorea.openstack.quantum.model.HostRoute;
+import com.woorea.openstack.quantum.model.RouterForCreate;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RouterForCreateTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"router\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"routes\" : [ {" + EOL
+        + "      \"destination\" : \"destination\"," + EOL
+        + "      \"nexthop\" : \"nexthop\"" + EOL
+        + "    }, {" + EOL
+        + "      \"destination\" : \"destination\"," + EOL
+        + "      \"nexthop\" : \"nexthop\"" + EOL
+        + "    } ]," + EOL
+        + "    \"admin_state_up\" : \"admin_state_up\"," + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"external_gateway_info\" : {" + EOL
+        + "      \"network_id\" : \"networkid\"" + EOL
+        + "    }," + EOL
+        + "    \"tenant_id\" : \"tenantid\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + RouterForCreate.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        RouterForCreate routerforcreate = objectMapper.readValue(JSON_FULL, RouterForCreate.class);
+        String json = objectMapper.writeValueAsString(routerforcreate);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        RouterForCreate routerforcreate = objectMapper.readValue(JSON_FULL, RouterForCreate.class);
+        routerforcreate.toString();
+        
+        List<HostRoute> routes = routerforcreate.getRoutes();
+        Assert.assertNotNull(routes);
+        Assert.assertEquals(2, routes.size());
+        routerforcreate.setRoutes(routes);
+        
+        String admin_state_up = routerforcreate.getAdmin_state_up();
+        Assert.assertNotNull(admin_state_up);
+        routerforcreate.setAdmin_state_up(admin_state_up);
+        
+        String name = routerforcreate.getName();
+        Assert.assertNotNull(name);
+        routerforcreate.setName(name);
+        
+        String tenantId = routerforcreate.getTenantId();
+        Assert.assertNotNull(tenantId);
+        routerforcreate.setTenantId(tenantId);
+        
+        GatewayInfo externalGatewayInfo = routerforcreate.getExternalGatewayInfo();
+        Assert.assertNotNull(externalGatewayInfo);
+        routerforcreate.setExternalGatewayInfo(externalGatewayInfo);
+        
+        String id = routerforcreate.getId();
+        Assert.assertNotNull(id);
+        routerforcreate.setId(id);
+        
+        String status = routerforcreate.getStatus();
+        Assert.assertNotNull(status);
+        routerforcreate.setStatus(status);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterInterfaceTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterInterfaceTest.java
new file mode 100644 (file)
index 0000000..24713b7
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.RouterInterface;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RouterInterfaceTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"id\" : \"id\"," + EOL
+        + "  \"subnet_id\" : \"subnetid\"," + EOL
+        + "  \"port_id\" : \"portid\"," + EOL
+        + "  \"tenant_id\" : \"tenantid\"" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + RouterInterface.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        RouterInterface routerinterface = objectMapper.readValue(JSON_FULL, RouterInterface.class);
+        String json = objectMapper.writeValueAsString(routerinterface);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        RouterInterface routerinterface = objectMapper.readValue(JSON_FULL, RouterInterface.class);
+        routerinterface.toString();
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RouterTest.java
new file mode 100644 (file)
index 0000000..2ad549c
--- /dev/null
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.GatewayInfo;
+import com.woorea.openstack.quantum.model.HostRoute;
+import com.woorea.openstack.quantum.model.Router;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RouterTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"router\" : {" + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"admin_state_up\" : \"admin_state_up\"," + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"routes\" : [ {" + EOL
+        + "      \"destination\" : \"destination\"," + EOL
+        + "      \"nexthop\" : \"nexthop\"" + EOL
+        + "    }, {" + EOL
+        + "      \"destination\" : \"destination\"," + EOL
+        + "      \"nexthop\" : \"nexthop\"" + EOL
+        + "    } ]," + EOL
+        + "    \"external_gateway_info\" : {" + EOL
+        + "      \"network_id\" : \"networkid\"" + EOL
+        + "    }," + EOL
+        + "    \"tenant_id\" : \"tenantid\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Router.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Router router = objectMapper.readValue(JSON_FULL, Router.class);
+        String json = objectMapper.writeValueAsString(router);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Router router = objectMapper.readValue(JSON_FULL, Router.class);
+        router.toString();
+        
+        List<HostRoute> routes = router.getRoutes();
+        Assert.assertNotNull(routes);
+        Assert.assertEquals(2, routes.size());
+        router.setRoutes(routes);
+        
+        String admin_state_up = router.getAdmin_state_up();
+        Assert.assertNotNull(admin_state_up);
+        router.setAdmin_state_up(admin_state_up);
+        
+        String name = router.getName();
+        Assert.assertNotNull(name);
+        router.setName(name);
+        
+        String tenantId = router.getTenantId();
+        Assert.assertNotNull(tenantId);
+        router.setTenantId(tenantId);
+        
+        GatewayInfo externalGatewayInfo = router.getExternalGatewayInfo();
+        Assert.assertNotNull(externalGatewayInfo);
+        router.setExternalGatewayInfo(externalGatewayInfo);
+        
+        String id = router.getId();
+        Assert.assertNotNull(id);
+        router.setId(id);
+        
+        String status = router.getStatus();
+        Assert.assertNotNull(status);
+        router.setStatus(status);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RoutersTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/RoutersTest.java
new file mode 100644 (file)
index 0000000..ad955c8
--- /dev/null
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Router;
+import com.woorea.openstack.quantum.model.Routers;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class RoutersTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"routers\" : [ {" + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"admin_state_up\" : \"admin_state_up\"," + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"routes\" : [ {" + EOL
+        + "      \"destination\" : \"destination\"," + EOL
+        + "      \"nexthop\" : \"nexthop\"" + EOL
+        + "    }, {" + EOL
+        + "      \"destination\" : \"destination\"," + EOL
+        + "      \"nexthop\" : \"nexthop\"" + EOL
+        + "    } ]," + EOL
+        + "    \"external_gateway_info\" : {" + EOL
+        + "      \"network_id\" : \"networkid\"" + EOL
+        + "    }," + EOL
+        + "    \"tenant_id\" : \"tenantid\"" + EOL
+        + "  }, {" + EOL
+        + "    \"status\" : \"status\"," + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"admin_state_up\" : \"admin_state_up\"," + EOL
+        + "    \"id\" : \"id\"," + EOL
+        + "    \"routes\" : [ {" + EOL
+        + "      \"destination\" : \"destination\"," + EOL
+        + "      \"nexthop\" : \"nexthop\"" + EOL
+        + "    }, {" + EOL
+        + "      \"destination\" : \"destination\"," + EOL
+        + "      \"nexthop\" : \"nexthop\"" + EOL
+        + "    } ]," + EOL
+        + "    \"external_gateway_info\" : {" + EOL
+        + "      \"network_id\" : \"networkid\"" + EOL
+        + "    }," + EOL
+        + "    \"tenant_id\" : \"tenantid\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Routers.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Routers routers = objectMapper.readValue(JSON_FULL, Routers.class);
+        String json = objectMapper.writeValueAsString(routers);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Routers routers = objectMapper.readValue(JSON_FULL, Routers.class);
+        routers.toString();
+        
+        List<Router> list = routers.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        routers.setList(list);
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Router x : routers) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SegmentTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SegmentTest.java
new file mode 100644 (file)
index 0000000..9bc7fd7
--- /dev/null
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Segment;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class SegmentTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"provider:physical_network\" : \"providerphysicalnetwork\"," + EOL
+        + "  \"provider:network_type\" : \"providernetworktype\"," + EOL
+        + "  \"provider:segmentation_id\" : 92" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Segment.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Segment segment = objectMapper.readValue(JSON_FULL, Segment.class);
+        String json = objectMapper.writeValueAsString(segment);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Segment segment = objectMapper.readValue(JSON_FULL, Segment.class);
+        segment.toString();
+        
+        String providerNetworkType = segment.getProviderNetworkType();
+        Assert.assertNotNull(providerNetworkType);
+        segment.setProviderNetworkType(providerNetworkType);
+        
+        Integer providerSegmentationId = segment.getProviderSegmentationId();
+        Assert.assertNotNull(providerSegmentationId);
+        segment.setProviderSegmentationId(providerSegmentationId);
+        
+        String providerPhysicalNetwork = segment.getProviderPhysicalNetwork();
+        Assert.assertNotNull(providerPhysicalNetwork);
+        segment.setProviderPhysicalNetwork(providerPhysicalNetwork);
+    }
+}
index db27bf2..5e1c7e1 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP - SO
  * ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
- * ================================================================================ 
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package com.woorea.openstack.quantum.model;
 
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
-
-import java.util.Arrays;
-
+import com.woorea.openstack.quantum.model.Pool;
+import com.woorea.openstack.quantum.model.Subnet;
+import com.woorea.openstack.quantum.model.Subnet.IpVersion;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
 import org.codehaus.jackson.map.ObjectMapper;
-import org.hamcrest.CustomMatcher;
-import org.junit.Before;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
 import org.junit.Test;
-
-import com.woorea.openstack.quantum.model.Subnet.IpVersion;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
 
 public class SubnetTest {
 
-    private static final String POOL_END = "poolEnd";
-
-    private static final String POOL_START = "poolStart";
-
-    private static final String TENANT_ID = "tenantId";
-
-    private static final String NETWORK_ID = "networkId";
-
-    private static final String NAME = "name";
-
-    private static final String HOST_ROUTE = "hostRoute";
-
-    private static final String GATEWAY = "gw";
-
-    private static final boolean ENABLE_DHCP = true;
-
-    private static final String ID = "testId";
-
-    private static final String CIDR = "10.0.0.0/8";
-
-    private static final String DNS_SERVER = "dnsServer";
-
-    private static final IpVersion IP_VERSION = IpVersion.IPV4;
-
-    /**
-     * JSON with read only attributes.
-     */
-    private static final String SUBNET_JSON = "{"
-            + "  \"subnet\" : {"
-            + "    \"id\" : \"" + ID + "\""
-            + "  }"
-            + "}";
-
-    private ObjectMapper objectMapper;
-
-    private String serializedSubnet;
-
-    @Before
-    public void setUp() throws Exception {
-        objectMapper = PortTest.initializeObjectMapper();
-    }
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"subnet\" : {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"cidr\" : \"cidr\"," + EOL
+        + "    \"enable_dhcp\" : true," + EOL
+        + "    \"network_id\" : \"networkid\"," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"dns_nameservers\" : [ \"dnsnames-v1\", \"dnsnames-v2\" ]," + EOL
+        + "    \"allocation_pools\" : [ {" + EOL
+        + "      \"start\" : \"start\"," + EOL
+        + "      \"end\" : \"end\"" + EOL
+        + "    }, {" + EOL
+        + "      \"start\" : \"start\"," + EOL
+        + "      \"end\" : \"end\"" + EOL
+        + "    } ]," + EOL
+        + "    \"host_routes\" : [ \"hostroutes-v1\", \"hostroutes-v2\" ]," + EOL
+        + "    \"ip_version\" : 4," + EOL
+        + "    \"gateway_ip\" : \"gw\"" + EOL
+        + "  }" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(SerializationConfig.Feature.WRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
 
     @Test
     public void testSerialization() throws Exception {
-        Subnet subnet = new Subnet();
-        subnet.setId(ID);
-        subnet.setCidr(CIDR);
-        subnet.setDnsNames(Arrays.asList(DNS_SERVER));
-        subnet.setEnableDHCP(ENABLE_DHCP);
-        subnet.setIpversion(IP_VERSION);
-        subnet.setGw(GATEWAY);
-        subnet.setHostRoutes(Arrays.asList(HOST_ROUTE));
-        subnet.setName(NAME);
-        subnet.setNetworkId(NETWORK_ID);
-        subnet.setTenantId(TENANT_ID);
-
-        Pool pool = new Pool();
-        pool.setStart(POOL_START);
-        pool.setEnd(POOL_END);
-        subnet.setList(Arrays.asList(pool));
-
-        serializedSubnet = objectMapper.writeValueAsString(subnet);
-        assertThat(serializedSubnet, not(containsString(ID)));
-        assertThat(serializedSubnet, containsString(CIDR));
-        assertThat(serializedSubnet, containsString(DNS_SERVER));
-        assertThat(serializedSubnet, containsString("\"enable_dhcp\" : " + ENABLE_DHCP));
-        assertThat(serializedSubnet, containsString(Integer.toString(IP_VERSION.code())));
-        assertThat(serializedSubnet, containsString(GATEWAY));
-        assertThat(serializedSubnet, containsString(HOST_ROUTE));
-        assertThat(serializedSubnet, containsString(NAME));
-        assertThat(serializedSubnet, containsString(NETWORK_ID));
-        assertThat(serializedSubnet, containsString(TENANT_ID));
-        assertThat(serializedSubnet, containsString(POOL_START));
-        assertThat(serializedSubnet, containsString(POOL_END));
+        System.out.println("CLASS: " + Subnet.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Subnet subnet = objectMapper.readValue(JSON_FULL, Subnet.class);
+        String json = objectMapper.writeValueAsString(subnet);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
     }
 
     @Test
-    public void testSerializationEmpty() throws Exception {
-        Subnet subnet = new Subnet();
-        serializedSubnet = objectMapper.writeValueAsString(subnet);
-
-        assertThat(serializedSubnet, containsString("\"subnet\" : { }"));
-    }
-
-    @Test
-    public void testDeserializationReadOnlyFields() throws Exception {
-        Subnet subnet = objectMapper.readValue(SUBNET_JSON, Subnet.class);
-
-        assertThat(subnet.getId(), is(equalTo(ID)));
-    }
-
-    @Test
-    public void testDeserializationAfterSerialization() throws Exception {
-        testSerialization();
-        Subnet subnet = objectMapper.readValue(serializedSubnet, Subnet.class);
-
-        assertThat(subnet.getCidr(), is(equalTo(CIDR)));
-        assertThat(subnet.getDnsNames(), hasItem(equalTo(DNS_SERVER)));
-        assertThat(subnet.isEnableDHCP(), is(equalTo(ENABLE_DHCP)));
-        assertThat(subnet.getIpversion(), is(equalTo(IP_VERSION)));
-        assertThat(subnet.getGw(), is(equalTo(GATEWAY)));
-        assertThat(subnet.getHostRoutes(), hasItem(equalTo(HOST_ROUTE)));
-        assertThat(subnet.getName(), is(equalTo(NAME)));
-        assertThat(subnet.getNetworkId(), is(equalTo(NETWORK_ID)));
-        assertThat(subnet.getTenantId(), is(equalTo(TENANT_ID)));
-        assertThat(subnet.getList(), hasItem(new CustomMatcher<Pool>(
-                "a Pool object with start " + POOL_START + " and end " + POOL_END) {
-
-            @Override
-            public boolean matches(Object pool) {
-                return pool instanceof Pool
-                        && POOL_START.equals(((Pool) pool).getStart())
-                        && POOL_END.equals(((Pool) pool).getEnd());
-            }
-        }));
+    public void testMethods() throws Exception {
+        Subnet subnet = objectMapper.readValue(JSON_FULL, Subnet.class);
+        subnet.toString();
+        
+        String gw = subnet.getGw();
+        Assert.assertNotNull(gw);
+        subnet.setGw(gw);
+        
+        List<String> dnsNames = subnet.getDnsNames();
+        Assert.assertNotNull(dnsNames);
+        Assert.assertEquals(2, dnsNames.size());
+        subnet.setDnsNames(dnsNames);
+        
+        List<String> hostRoutes = subnet.getHostRoutes();
+        Assert.assertNotNull(hostRoutes);
+        Assert.assertEquals(2, hostRoutes.size());
+        subnet.setHostRoutes(hostRoutes);
+        
+        String name = subnet.getName();
+        Assert.assertNotNull(name);
+        subnet.setName(name);
+        
+        String tenantId = subnet.getTenantId();
+        Assert.assertNotNull(tenantId);
+        subnet.setTenantId(tenantId);
+        
+        String cidr = subnet.getCidr();
+        Assert.assertNotNull(cidr);
+        subnet.setCidr(cidr);
+        
+        String networkId = subnet.getNetworkId();
+        Assert.assertNotNull(networkId);
+        subnet.setNetworkId(networkId);
+        
+        Boolean enableDHCP = subnet.getEnableDHCP();
+        Assert.assertNotNull(enableDHCP);
+        subnet.setEnableDHCP(enableDHCP);
+        
+        IpVersion ipversion = subnet.getIpversion();
+        Assert.assertNotNull(ipversion);
+        subnet.setIpversion(ipversion);
+        
+        List<Pool> list = subnet.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        subnet.setList(list);
     }
 }
diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetsTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetsTest.java
new file mode 100644 (file)
index 0000000..d01d3f6
--- /dev/null
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.quantum.model;
+
+import com.woorea.openstack.quantum.model.Subnet;
+import com.woorea.openstack.quantum.model.Subnets;
+import java.util.List;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+public class SubnetsTest {
+
+    private static final String EOL = System.lineSeparator();
+
+    private static final String JSON_FULL = "{" + EOL
+        + "  \"subnets\" : [ {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"cidr\" : \"cidr\"," + EOL
+        + "    \"enable_dhcp\" : true," + EOL
+        + "    \"network_id\" : \"networkid\"," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"dns_nameservers\" : [ \"dnsnames-v1\", \"dnsnames-v2\" ]," + EOL
+        + "    \"allocation_pools\" : [ {" + EOL
+        + "      \"start\" : \"start\"," + EOL
+        + "      \"end\" : \"end\"" + EOL
+        + "    }, {" + EOL
+        + "      \"start\" : \"start\"," + EOL
+        + "      \"end\" : \"end\"" + EOL
+        + "    } ]," + EOL
+        + "    \"host_routes\" : [ \"hostroutes-v1\", \"hostroutes-v2\" ]," + EOL
+        + "    \"ip_version\" : 4," + EOL
+        + "    \"gateway_ip\" : \"gw\"" + EOL
+        + "  }, {" + EOL
+        + "    \"name\" : \"name\"," + EOL
+        + "    \"cidr\" : \"cidr\"," + EOL
+        + "    \"enable_dhcp\" : true," + EOL
+        + "    \"network_id\" : \"networkid\"," + EOL
+        + "    \"tenant_id\" : \"tenantid\"," + EOL
+        + "    \"dns_nameservers\" : [ \"dnsnames-v1\", \"dnsnames-v2\" ]," + EOL
+        + "    \"allocation_pools\" : [ {" + EOL
+        + "      \"start\" : \"start\"," + EOL
+        + "      \"end\" : \"end\"" + EOL
+        + "    }, {" + EOL
+        + "      \"start\" : \"start\"," + EOL
+        + "      \"end\" : \"end\"" + EOL
+        + "    } ]," + EOL
+        + "    \"host_routes\" : [ \"hostroutes-v1\", \"hostroutes-v2\" ]," + EOL
+        + "    \"ip_version\" : 4," + EOL
+        + "    \"gateway_ip\" : \"gw\"" + EOL
+        + "  } ]" + EOL
+        + "}";
+
+    private ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Subnets.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Subnets subnets = objectMapper.readValue(JSON_FULL, Subnets.class);
+        String json = objectMapper.writeValueAsString(subnets);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        Subnets subnets = objectMapper.readValue(JSON_FULL, Subnets.class);
+        subnets.toString();
+        
+        List<Subnet> list = subnets.getList();
+        Assert.assertNotNull(list);
+        Assert.assertEquals(2, list.size());
+        subnets.setList(list);
+        
+        int cnt = 0;
+        for (@SuppressWarnings("unused") Subnet x : subnets) {
+            ++cnt;
+        }
+        Assert.assertEquals(2, cnt);
+    }
+}
index dda692e..18464df 100644 (file)
@@ -9,4 +9,16 @@
        <artifactId>swift-model</artifactId>
        <name>OpenStack Swift Model</name>
        <description>OpenStack Swift Model</description>
+       <dependencies>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.skyscreamer</groupId>
+                       <artifactId>jsonassert</artifactId>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
 </project>
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
new file mode 100644 (file)
index 0000000..2500ebf
--- /dev/null
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.swift.model;
+
+import com.woorea.openstack.swift.model.Container;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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 ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Container.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Container container = objectMapper.readValue(JSON_FULL, Container.class);
+        String json = objectMapper.writeValueAsString(container);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    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
new file mode 100644 (file)
index 0000000..4cefadb
--- /dev/null
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package com.woorea.openstack.swift.model;
+
+import java.util.Calendar;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
+
+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 ObjectMapper objectMapper = new ObjectMapper()
+        .setSerializationInclusion(Inclusion.NON_NULL)
+        .enable(SerializationConfig.Feature.INDENT_OUTPUT)
+        .enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+
+    @Test
+    public void testSerialization() throws Exception {
+        System.out.println("CLASS: " + Object.class.getName());
+        System.out.println("TEST JSON: " + JSON_FULL);
+        Object object = objectMapper.readValue(JSON_FULL, Object.class);
+        String json = objectMapper.writeValueAsString(object);
+        System.out.println("RE-SERIALIZED OBJECT: " + json);
+        JSONAssert.assertEquals(JSON_FULL, json, JSONCompareMode.LENIENT);
+    }
+
+    @Test
+    public void testMethods() throws Exception {
+        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);
+    }
+}