From 0a7a9f378e498bd1a1283dd5e18b7134a186ecf6 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 23 Aug 2012 16:52:14 +0300 Subject: [PATCH] Updated KeyPair toString method to make expect test pass --- .../org/jclouds/openstack/nova/v2_0/domain/KeyPair.java | 9 +++++++-- .../nova/v2_0/extensions/KeyPairApiExpectTest.java | 1 + .../openstack/nova/v2_0/parse/ParseKeyPairListTest.java | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java index cb59e6744d..f14332ef70 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java @@ -174,8 +174,13 @@ public class KeyPair { } protected ToStringHelper string() { - return Objects.toStringHelper(this) - .add("publicKey", publicKey).add("privateKey", privateKey).add("userId", userId).add("name", name).add("fingerprint", fingerprint); + return Objects.toStringHelper("") + .omitNullValues() + .add("public_key", publicKey) + .add("private_key", privateKey) + .add("user_id", userId) + .add("name", name) + .add("fingerprint", fingerprint); } @Override diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java index 4e39d8922b..5f215c3b50 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java @@ -55,6 +55,7 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest { assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1")); + // NOTE this required a change to the KeyPair domain object toString method assertEquals(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().listKeyPairs().toString(), new ParseKeyPairListTest().expected().toString()); } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java index 0cd7354993..bc30d5b001 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.openstack.nova.v2_0.parse; -import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -33,6 +32,7 @@ import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; import com.google.inject.Guice; import com.google.inject.Injector; @@ -52,7 +52,7 @@ public class ParseKeyPairListTest extends BaseItemParserTest> expected() { - Map kp1 = new HashMap(); + Map kp1 = Maps.newHashMap(); kp1.put( "keypair", KeyPair @@ -60,7 +60,7 @@ public class ParseKeyPairListTest extends BaseItemParserTest kp2 = new HashMap(); + Map kp2 = Maps.newHashMap(); kp2.put( "keypair", KeyPair