Updated Branches: refs/heads/master d9717a432 -> 0d70c84a3
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0d70c84a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/ServerInfoToJsonTest.java ---------------------------------------------------------------------- diff --git a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/ServerInfoToJsonTest.java b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/ServerInfoToJsonTest.java index 774260e..c1453fe 100644 --- a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/ServerInfoToJsonTest.java +++ b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/ServerInfoToJsonTest.java @@ -38,120 +38,120 @@ import java.util.Map; @Test(groups = "unit") public class ServerInfoToJsonTest { - private final static ServerInfoToJson SERVER_INFO_TO_JSON = Guice.createInjector().getInstance(ServerInfoToJson.class); - - private ServerInfo input; - private JsonObject expected = new JsonObject(); - - @BeforeMethod - public void setUp() throws Exception { - Owner owner = new Owner.Builder() - .resourceUri(new URI("/api/2.0/user/5b4a69a3-8e78-4c45-a8ba-8b13f0895e23/")) - .uuid("5b4a69a3-8e78-4c45-a8ba-8b13f0895e23") - .build(); - - Map<String, String> meta = new HashMap<String, String>(); - meta.put("description", "A full server with description"); - - input = new ServerInfo.Builder() - .cpu(1000) - .cpusInsteadOfCores(false) - .drives(ImmutableList.of( - new ServerDrive.Builder() - .deviceChannel("0:0") - .deviceEmulationType(DeviceEmulationType.IDE) - .drive(new Drive.Builder() - .resourceUri(new URI("/api/2.0/drives/ae78e68c-9daa-4471-8878-0bb87fa80260/")) - .uuid("ae78e68c-9daa-4471-8878-0bb87fa80260") - .build()) - .build() - , new ServerDrive.Builder() - .bootOrder(1) + private final static ServerInfoToJson SERVER_INFO_TO_JSON = Guice.createInjector().getInstance(ServerInfoToJson.class); + + private ServerInfo input; + private JsonObject expected = new JsonObject(); + + @BeforeMethod + public void setUp() throws Exception { + Owner owner = new Owner.Builder() + .resourceUri(new URI("/api/2.0/user/5b4a69a3-8e78-4c45-a8ba-8b13f0895e23/")) + .uuid("5b4a69a3-8e78-4c45-a8ba-8b13f0895e23") + .build(); + + Map<String, String> meta = new HashMap<String, String>(); + meta.put("description", "A full server with description"); + + input = new ServerInfo.Builder() + .cpu(1000) + .cpusInsteadOfCores(false) + .drives(ImmutableList.of( + new ServerDrive.Builder() .deviceChannel("0:0") - .deviceEmulationType(DeviceEmulationType.VIRTIO) + .deviceEmulationType(DeviceEmulationType.IDE) .drive(new Drive.Builder() - .resourceUri(new URI("/api/2.0/drives/22826af4-d6c8-4d39-bd41-9cea86df2976/")) - .uuid("22826af4-d6c8-4d39-bd41-9cea86df2976") - .build()) + .resourceUri(new URI("/api/2.0/drives/ae78e68c-9daa-4471-8878-0bb87fa80260/")) + .uuid("ae78e68c-9daa-4471-8878-0bb87fa80260") + .build()) .build() - )) - .enableNuma(false) - .hvRelaxed(false) - .hvTsc(false) - .memory(new BigInteger("268435456")) - .meta(meta) - .name("test_acc_full_server") - .nics(ImmutableList.of( - new NIC.Builder() - .firewallPolicy(null) - .ipV4Configuration(new IPConfiguration(IPConfigurationType.DHCP, null)) - .ipV6Configuration(null) - .mac("22:a7:a0:0d:43:48") - .model(Model.VIRTIO) - .runtime(null) - .vlan(null) - .build() - )) - .owner(owner) - .requirements(new ArrayList<String>()) - .resourceUri(new URI("/api/2.0/servers/a19a425f-9e92-42f6-89fb-6361203071bb/")) - .runtime(null) - .smp(1) - .status(ServerStatus.STOPPED) - .tags(ImmutableList.of("tag_uuid_1", "tag_uuid_2")) - .uuid("a19a425f-9e92-42f6-89fb-6361203071bb") - .vncPassword("tester") - .build(); - - expected.addProperty("name", "test_acc_full_server"); - expected.addProperty("cpu", 1000); - expected.addProperty("mem", "268435456"); - - JsonObject metaObject = new JsonObject(); - metaObject.addProperty("description", "A full server with description"); - - expected.add("meta", metaObject); - expected.add("requirements", new JsonArray()); - - JsonArray tagsArray = new JsonArray(); - tagsArray.add(new JsonPrimitive("tag_uuid_1")); - tagsArray.add(new JsonPrimitive("tag_uuid_2")); - expected.add("tags", tagsArray); - expected.addProperty("vnc_password", "tester"); - - JsonObject nicJson = new JsonObject(); - - JsonObject ipv4ConfObject = new JsonObject(); - ipv4ConfObject.addProperty("conf", "dhcp"); - nicJson.add("ip_v4_conf", ipv4ConfObject); - nicJson.addProperty("model", "virtio"); - nicJson.addProperty("mac", "22:a7:a0:0d:43:48"); - - JsonArray nicsArray = new JsonArray(); - nicsArray.add(nicJson); - - expected.add("nics", nicsArray); - - JsonArray drivesArray = new JsonArray(); - JsonObject driveJson1 = new JsonObject(); - driveJson1.addProperty("boot_order", 0); - driveJson1.addProperty("dev_channel", "0:0"); - driveJson1.addProperty("device", "ide"); - driveJson1.addProperty("drive", "ae78e68c-9daa-4471-8878-0bb87fa80260"); - - JsonObject driveJson2 = new JsonObject(); - driveJson2.addProperty("boot_order", 1); - driveJson2.addProperty("dev_channel", "0:0"); - driveJson2.addProperty("device", "virtio"); - driveJson2.addProperty("drive", "22826af4-d6c8-4d39-bd41-9cea86df2976"); - - drivesArray.add(driveJson1); - drivesArray.add(driveJson2); - - expected.add("drives", drivesArray); - } - - public void test(){ - Assert.assertEquals(SERVER_INFO_TO_JSON.apply(input), expected); - } + , new ServerDrive.Builder() + .bootOrder(1) + .deviceChannel("0:0") + .deviceEmulationType(DeviceEmulationType.VIRTIO) + .drive(new Drive.Builder() + .resourceUri(new URI("/api/2.0/drives/22826af4-d6c8-4d39-bd41-9cea86df2976/")) + .uuid("22826af4-d6c8-4d39-bd41-9cea86df2976") + .build()) + .build() + )) + .enableNuma(false) + .hvRelaxed(false) + .hvTsc(false) + .memory(new BigInteger("268435456")) + .meta(meta) + .name("test_acc_full_server") + .nics(ImmutableList.of( + new NIC.Builder() + .firewallPolicy(null) + .ipV4Configuration(new IPConfiguration(IPConfigurationType.DHCP, null)) + .ipV6Configuration(null) + .mac("22:a7:a0:0d:43:48") + .model(Model.VIRTIO) + .runtime(null) + .vlan(null) + .build() + )) + .owner(owner) + .requirements(new ArrayList<String>()) + .resourceUri(new URI("/api/2.0/servers/a19a425f-9e92-42f6-89fb-6361203071bb/")) + .runtime(null) + .smp(1) + .status(ServerStatus.STOPPED) + .tags(ImmutableList.of("tag_uuid_1", "tag_uuid_2")) + .uuid("a19a425f-9e92-42f6-89fb-6361203071bb") + .vncPassword("tester") + .build(); + + expected.addProperty("name", "test_acc_full_server"); + expected.addProperty("cpu", 1000); + expected.addProperty("mem", "268435456"); + + JsonObject metaObject = new JsonObject(); + metaObject.addProperty("description", "A full server with description"); + + expected.add("meta", metaObject); + expected.add("requirements", new JsonArray()); + + JsonArray tagsArray = new JsonArray(); + tagsArray.add(new JsonPrimitive("tag_uuid_1")); + tagsArray.add(new JsonPrimitive("tag_uuid_2")); + expected.add("tags", tagsArray); + expected.addProperty("vnc_password", "tester"); + + JsonObject nicJson = new JsonObject(); + + JsonObject ipv4ConfObject = new JsonObject(); + ipv4ConfObject.addProperty("conf", "dhcp"); + nicJson.add("ip_v4_conf", ipv4ConfObject); + nicJson.addProperty("model", "virtio"); + nicJson.addProperty("mac", "22:a7:a0:0d:43:48"); + + JsonArray nicsArray = new JsonArray(); + nicsArray.add(nicJson); + + expected.add("nics", nicsArray); + + JsonArray drivesArray = new JsonArray(); + JsonObject driveJson1 = new JsonObject(); + driveJson1.addProperty("boot_order", 0); + driveJson1.addProperty("dev_channel", "0:0"); + driveJson1.addProperty("device", "ide"); + driveJson1.addProperty("drive", "ae78e68c-9daa-4471-8878-0bb87fa80260"); + + JsonObject driveJson2 = new JsonObject(); + driveJson2.addProperty("boot_order", 1); + driveJson2.addProperty("dev_channel", "0:0"); + driveJson2.addProperty("device", "virtio"); + driveJson2.addProperty("drive", "22826af4-d6c8-4d39-bd41-9cea86df2976"); + + drivesArray.add(driveJson1); + drivesArray.add(driveJson2); + + expected.add("drives", drivesArray); + } + + public void test() { + Assert.assertEquals(SERVER_INFO_TO_JSON.apply(input), expected); + } } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0d70c84a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/TagToJsonTest.java ---------------------------------------------------------------------- diff --git a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/TagToJsonTest.java b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/TagToJsonTest.java index 5526adf..91d315f 100644 --- a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/TagToJsonTest.java +++ b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/TagToJsonTest.java @@ -39,61 +39,61 @@ import java.util.Map; @Test(groups = "unit") public class TagToJsonTest { - private static final TagToJson TAG_TO_JSON = Guice.createInjector().getInstance(TagToJson.class); + private static final TagToJson TAG_TO_JSON = Guice.createInjector().getInstance(TagToJson.class); - private Tag input; - private JsonObject expected; + private Tag input; + private JsonObject expected; - @BeforeMethod - public void setUp() throws Exception { - Owner owner = new Owner.Builder() - .resourceUri(new URI("/api/2.0/user/5b4a69a3-8e78-4c45-a8ba-8b13f0895e23/")) - .uuid("5b4a69a3-8e78-4c45-a8ba-8b13f0895e23") - .build(); + @BeforeMethod + public void setUp() throws Exception { + Owner owner = new Owner.Builder() + .resourceUri(new URI("/api/2.0/user/5b4a69a3-8e78-4c45-a8ba-8b13f0895e23/")) + .uuid("5b4a69a3-8e78-4c45-a8ba-8b13f0895e23") + .build(); - Map<String, String> meta = new HashMap<String, String>(); - meta.put("description", "test tag"); + Map<String, String> meta = new HashMap<String, String>(); + meta.put("description", "test tag"); - input = new Tag.Builder() - .meta(meta) - .name("TagCreatedWithResource") - .resources(ImmutableList.of( - new TagResource.Builder() - .uuid("96537817-f4b6-496b-a861-e74192d3ccb0") - .build() - , new TagResource.Builder() - .uuid("61bcc398-c034-42f1-81c9-f6d7f62c4ea0") - .build() - , new TagResource.Builder() - .uuid("3610d935-514a-4552-acf3-a40dd0a5f961") - .build() - , new TagResource.Builder() - .resourceType(TagResourceType.IPS) - .resourceUri(new URI("/api/2.0/ips/185.12.6.183/")) - .uuid("185.12.6.183") - .owner(owner) - .build() - )) - .build(); + input = new Tag.Builder() + .meta(meta) + .name("TagCreatedWithResource") + .resources(ImmutableList.of( + new TagResource.Builder() + .uuid("96537817-f4b6-496b-a861-e74192d3ccb0") + .build() + , new TagResource.Builder() + .uuid("61bcc398-c034-42f1-81c9-f6d7f62c4ea0") + .build() + , new TagResource.Builder() + .uuid("3610d935-514a-4552-acf3-a40dd0a5f961") + .build() + , new TagResource.Builder() + .resourceType(TagResourceType.IPS) + .resourceUri(new URI("/api/2.0/ips/185.12.6.183/")) + .uuid("185.12.6.183") + .owner(owner) + .build() + )) + .build(); - expected = new JsonObject(); + expected = new JsonObject(); - JsonObject metaObject = new JsonObject(); - metaObject.addProperty("description", "test tag"); + JsonObject metaObject = new JsonObject(); + metaObject.addProperty("description", "test tag"); - expected.add("meta", metaObject); - expected.addProperty("name", "TagCreatedWithResource"); + expected.add("meta", metaObject); + expected.addProperty("name", "TagCreatedWithResource"); - JsonArray resourcesArray = new JsonArray(); - resourcesArray.add(new JsonPrimitive("96537817-f4b6-496b-a861-e74192d3ccb0")); - resourcesArray.add(new JsonPrimitive("61bcc398-c034-42f1-81c9-f6d7f62c4ea0")); - resourcesArray.add(new JsonPrimitive("3610d935-514a-4552-acf3-a40dd0a5f961")); - resourcesArray.add(new JsonPrimitive("185.12.6.183")); + JsonArray resourcesArray = new JsonArray(); + resourcesArray.add(new JsonPrimitive("96537817-f4b6-496b-a861-e74192d3ccb0")); + resourcesArray.add(new JsonPrimitive("61bcc398-c034-42f1-81c9-f6d7f62c4ea0")); + resourcesArray.add(new JsonPrimitive("3610d935-514a-4552-acf3-a40dd0a5f961")); + resourcesArray.add(new JsonPrimitive("185.12.6.183")); - expected.add("resources", resourcesArray); - } + expected.add("resources", resourcesArray); + } - public void test(){ - Assert.assertEquals(TAG_TO_JSON.apply(input), expected); - } + public void test() { + Assert.assertEquals(TAG_TO_JSON.apply(input), expected); + } } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0d70c84a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/VLANInfoToJsonTest.java ---------------------------------------------------------------------- diff --git a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/VLANInfoToJsonTest.java b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/VLANInfoToJsonTest.java index 8a940c8..3aab795 100644 --- a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/VLANInfoToJsonTest.java +++ b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/functions/VLANInfoToJsonTest.java @@ -40,46 +40,47 @@ import java.util.Map; @Test(groups = "unit") public class VLANInfoToJsonTest { - private static final VLANInfoToJson VLAN_INFO_TO_JSON = Guice.createInjector().getInstance(VLANInfoToJson.class); + private static final VLANInfoToJson VLAN_INFO_TO_JSON = Guice.createInjector().getInstance(VLANInfoToJson.class); - private VLANInfo input; - private JsonObject expected; - { - Map<String, String> meta = new HashMap<String, String>(); - meta.put("description", "test vlan"); - meta.put("test_key_1", "test_value_1"); - meta.put("test_key_2", "test_value_2"); + private VLANInfo input; + private JsonObject expected; - try { - input = new VLANInfo.Builder() - .meta(meta) - .resourceUri(new URI("/api/2.0/vlans/96537817-f4b6-496b-a861-e74192d3ccb0/")) - .servers(ImmutableList.of( - new Server.Builder() - .uuid("81f911f9-5152-4328-8671-02543bafbd0e") - .resourceUri(new URI("/api/2.0/servers/81f911f9-5152-4328-8671-02543bafbd0e/")) - .build() - , new Server.Builder() - .uuid("19163e1a-a6d6-4e73-8087-157dd302c373") - .resourceUri(new URI("/api/2.0/servers/19163e1a-a6d6-4e73-8087-157dd302c373/")) - .build() - )) - .subscription(new Subscription.Builder() - .id("7272") - .resourceUri(new URI("/api/2.0/subscriptions/7272/")) - .build()) - .tags(new ArrayList<Tag>()) - .uuid("96537817-f4b6-496b-a861-e74192d3ccb0") - .build(); - } catch (URISyntaxException e) { - e.printStackTrace(); - } + { + Map<String, String> meta = new HashMap<String, String>(); + meta.put("description", "test vlan"); + meta.put("test_key_1", "test_value_1"); + meta.put("test_key_2", "test_value_2"); - expected = new JsonObject(); - expected.add("meta", new JsonParser().parse(new Gson().toJson(meta))); - } + try { + input = new VLANInfo.Builder() + .meta(meta) + .resourceUri(new URI("/api/2.0/vlans/96537817-f4b6-496b-a861-e74192d3ccb0/")) + .servers(ImmutableList.of( + new Server.Builder() + .uuid("81f911f9-5152-4328-8671-02543bafbd0e") + .resourceUri(new URI("/api/2.0/servers/81f911f9-5152-4328-8671-02543bafbd0e/")) + .build() + , new Server.Builder() + .uuid("19163e1a-a6d6-4e73-8087-157dd302c373") + .resourceUri(new URI("/api/2.0/servers/19163e1a-a6d6-4e73-8087-157dd302c373/")) + .build() + )) + .subscription(new Subscription.Builder() + .id("7272") + .resourceUri(new URI("/api/2.0/subscriptions/7272/")) + .build()) + .tags(new ArrayList<Tag>()) + .uuid("96537817-f4b6-496b-a861-e74192d3ccb0") + .build(); + } catch (URISyntaxException e) { + e.printStackTrace(); + } - public void test(){ - Assert.assertEquals(VLAN_INFO_TO_JSON.apply(input), expected); - } + expected = new JsonObject(); + expected.add("meta", new JsonParser().parse(new Gson().toJson(meta))); + } + + public void test() { + Assert.assertEquals(VLAN_INFO_TO_JSON.apply(input), expected); + } }
