diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Response.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Response.java index d3cea109f..fe1d541af 100644 --- a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Response.java +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Response.java @@ -39,16 +39,16 @@ public abstract class Response { public abstract List info(); @Nullable - public abstract List warning(); + public abstract List warning(); @Nullable - public abstract List error(); + public abstract List error(); public abstract String requestId(); @SerializedNames({ "operation", "responseCode", "message", "info", "warning", "error", "requestId" }) public static Response create(String operation, String responseCode, String message, List info, - List warning, List error, String requestId) { + List warning, List error, String requestId) { return builder().operation(operation).responseCode(responseCode).message(message).info(info).warning(warning) .error(error).requestId(requestId).build(); } @@ -66,17 +66,17 @@ public abstract static class Builder { public abstract Builder info(List info); - public abstract Builder warning(List warning); + public abstract Builder warning(List warning); - public abstract Builder error(List error); + public abstract Builder error(List error); public abstract Builder requestId(String requestId); abstract Response autoBuild(); - abstract List warning(); + abstract List warning(); - abstract List error(); + abstract List error(); abstract List info(); diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/utils/ParseResponse.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/utils/ParseResponse.java index 6f8b5def0..809d93457 100644 --- a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/utils/ParseResponse.java +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/utils/ParseResponse.java @@ -46,17 +46,19 @@ protected ParseResponse(Json json, String propertyName) { } public String apply(HttpResponse from) { - try { - InputStream gson = from.getPayload().openStream(); - - final Response response = json.fromJson(gson, TypeLiteral.get(Response.class).getType()); + Response response = null; + try (InputStream gson = from.getPayload().openStream()) { + response = json.fromJson(gson, TypeLiteral.get(Response.class).getType()); return tryFindInfoPropertyValue(response); } catch (Exception e) { StringBuilder message = new StringBuilder(); - message.append("Error parsing input: "); - message.append(e.getMessage()); + message.append("Error parsing input: ").append(e.getMessage()); + if (response != null) { + message.append(" ").append("Response Message: ").append(response.message()); + message.append(" ").append(checkForErrorElements(response)); + } logger.error(e, message.toString()); - throw new HttpResponseException(message.toString() + "\n" + from, null, from, e); + throw new HttpResponseException(message.toString() + ".\n" + from, null, from, e); } finally { releasePayload(from); } @@ -83,4 +85,15 @@ public String apply(Property input) { } return ""; } + + final String checkForErrorElements(final Response response) { + if (response.error() != null && !response.error().isEmpty()) { + StringBuilder message = new StringBuilder("Error Elements: "); + for (Property e : response.error()) { + message.append(e.name()).append(":").append(e.value()).append(", "); + } + return message.subSequence(0, message.length() - 2).toString() + "."; + } + return null; + } } diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/FirewallRuleParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/FirewallRuleParseTest.java new file mode 100644 index 000000000..82150e2c3 --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/FirewallRuleParseTest.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.jclouds.dimensiondata.cloudcontrol.parse; + +import org.jclouds.dimensiondata.cloudcontrol.domain.FirewallRule; +import org.jclouds.dimensiondata.cloudcontrol.domain.FirewallRuleTarget; +import org.jclouds.dimensiondata.cloudcontrol.domain.IpRange; +import org.jclouds.dimensiondata.cloudcontrol.domain.State; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +@Test(groups = "unit") +public class FirewallRuleParseTest extends BaseDimensionDataCloudControlParseTest { + + @Override + public String resource() { + return "/firewallRule.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public FirewallRule expected() { + return FirewallRule.builder().networkDomainId("484174a2-ae74-4658-9e56-50fc90e086cf") + .name("CCDEFAULT.BlockOutboundMailIPv6Secure").action("DROP").ipVersion("IPV6").protocol("TCP") + .source(FirewallRuleTarget.builder().ip(IpRange.create("ANY", null)).build()).destination( + FirewallRuleTarget.builder().ip(IpRange.create("ANY", null)) + .port(FirewallRuleTarget.Port.create(587, null)).build()).ruleType("DEFAULT_RULE").enabled(true) + .id("1aa3d0ce-d95d-4296-8338-9717e0d37ff9").datacenterId("NA9").state(State.NORMAL).build(); + } +} diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/NatRuleParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/NatRuleParseTest.java new file mode 100644 index 000000000..ee3cad600 --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/NatRuleParseTest.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.jclouds.dimensiondata.cloudcontrol.parse; + +import org.jclouds.dimensiondata.cloudcontrol.domain.NatRule; +import org.jclouds.dimensiondata.cloudcontrol.domain.State; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +@Test(groups = "unit") +public class NatRuleParseTest extends BaseDimensionDataCloudControlParseTest { + + @Override + public String resource() { + return "/natRule.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public NatRule expected() { + return NatRule.builder().networkDomainId("484174a2-ae74-4658-9e56-50fc90e086cf") + .createTime(parseDate("2015-03-06T13:45:10.000Z")).internalIp("10.0.0.16").externalIp("165.180.12.19") + .state(State.NORMAL).id("2169a38e-5692-497e-a22a-701a838a6539").datacenterId("NA9").build(); + } +} diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/NetworkDomainParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/NetworkDomainParseTest.java new file mode 100644 index 000000000..5292b358a --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/NetworkDomainParseTest.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.jclouds.dimensiondata.cloudcontrol.parse; + +import org.jclouds.dimensiondata.cloudcontrol.domain.NetworkDomain; +import org.jclouds.dimensiondata.cloudcontrol.domain.State; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +@Test(groups = "unit") +public class NetworkDomainParseTest extends BaseDimensionDataCloudControlParseTest { + + @Override + public String resource() { + return "/networkDomain.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public NetworkDomain expected() { + return NetworkDomain.builder().name("test").description("").type(NetworkDomain.Type.ESSENTIALS) + .snatIpv4Address("168.128.3.44").createTime(parseDate("2016-03-08T14:39:47.000Z")).state(State.NORMAL) + .id("8e082ed6-c198-4eff-97cb-aeac6f9685d8").datacenterId("NA9").build(); + } +} diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/PublicIpBlockParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/PublicIpBlockParseTest.java new file mode 100644 index 000000000..f3e3aad3b --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/PublicIpBlockParseTest.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.jclouds.dimensiondata.cloudcontrol.parse; + +import org.jclouds.dimensiondata.cloudcontrol.domain.PublicIpBlock; +import org.jclouds.dimensiondata.cloudcontrol.domain.State; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +@Test(groups = "unit") +public class PublicIpBlockParseTest extends BaseDimensionDataCloudControlParseTest { + + @Override + public String resource() { + return "/publicIpBlock.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public PublicIpBlock expected() { + return PublicIpBlock.builder().networkDomainId("690de302-bb80-49c6-b401-8c02bbefb945").baseIp("168.128.6.216") + .size(2).createTime(parseDate("2016-03-14T11:49:33.000Z")).state(State.NORMAL) + .id("9993e5fc-bdce-11e4-8c14-b8ca3a5d9ef8").datacenterId("NA9").build(); + } +} diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/ServerParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/ServerParseTest.java new file mode 100644 index 000000000..5d44d5e45 --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/ServerParseTest.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.jclouds.dimensiondata.cloudcontrol.parse; + +import org.jclouds.dimensiondata.cloudcontrol.domain.CPU; +import org.jclouds.dimensiondata.cloudcontrol.domain.Disk; +import org.jclouds.dimensiondata.cloudcontrol.domain.Guest; +import org.jclouds.dimensiondata.cloudcontrol.domain.NIC; +import org.jclouds.dimensiondata.cloudcontrol.domain.NetworkInfo; +import org.jclouds.dimensiondata.cloudcontrol.domain.OperatingSystem; +import org.jclouds.dimensiondata.cloudcontrol.domain.Server; +import org.jclouds.dimensiondata.cloudcontrol.domain.State; +import org.jclouds.dimensiondata.cloudcontrol.domain.VirtualHardware; +import org.jclouds.dimensiondata.cloudcontrol.domain.VmTools; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; +import java.util.Collections; + +@Test(groups = "unit") +public class ServerParseTest extends BaseDimensionDataCloudControlParseTest { + + @Override + public String resource() { + return "/server.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public Server expected() { + + return Server.builder().id("cb08c7ba-7a51-4e32-8d39-05d2270f8f8b").name("ServerApiLiveTest").datacenterId("EU6") + .state(State.NORMAL).sourceImageId("56eb0b7c-15a7-4b63-b373-05b962e37554") + .createTime(parseDate("2017-07-03T16:29:33.000Z")).started(true).deployed(true).guest(Guest.builder() + .operatingSystem( + OperatingSystem.builder().id("REDHAT764").displayName("REDHAT7/64").family("UNIX").build()) + .vmTools(VmTools.builder().apiVersion(9356).type(VmTools.Type.VMWARE_TOOLS) + .versionStatus(VmTools.VersionStatus.CURRENT).runningStatus(VmTools.RunningStatus.NOT_RUNNING) + .build()).osCustomization(true).build()) + .cpu(CPU.builder().count(2).speed("STANDARD").coresPerSocket(1).build()).memoryGb(4).disks(Collections + .singletonList( + Disk.builder().id("918f12ba-5e5e-4cd6-87bd-60c18293c24d").scsiId(0).sizeGb(20).speed("STANDARD") + .state("NORMAL").build())).networkInfo(NetworkInfo.builder().primaryNic( + NIC.builder().id("f0c00cab-bfa3-4c51-8c0a-c52fdac1ae4b").privateIpv4("10.0.0.7") + .ipv6("2a00:47c0:111:1131:5851:1950:411c:3dd8").vlanId("7bd12a4d-4e83-4254-a266-174aa5f55187") + .vlanName("jclouds vlan").state("NORMAL").build()).additionalNic(Collections.emptyList()) + .networkDomainId("d122949b-8990-46d6-98f0-91c8676fc720").build()) + .virtualHardware(VirtualHardware.builder().upToDate(true).version("vmx-10").build()) + .softwareLabels(Collections.emptyList()).build(); + } +} diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/ServersParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/ServersParseTest.java new file mode 100644 index 000000000..eb97dae8e --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/ServersParseTest.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.jclouds.dimensiondata.cloudcontrol.parse; + +import com.google.common.collect.ImmutableList; +import org.jclouds.dimensiondata.cloudcontrol.domain.CPU; +import org.jclouds.dimensiondata.cloudcontrol.domain.Disk; +import org.jclouds.dimensiondata.cloudcontrol.domain.Guest; +import org.jclouds.dimensiondata.cloudcontrol.domain.NIC; +import org.jclouds.dimensiondata.cloudcontrol.domain.NetworkInfo; +import org.jclouds.dimensiondata.cloudcontrol.domain.OperatingSystem; +import org.jclouds.dimensiondata.cloudcontrol.domain.Server; +import org.jclouds.dimensiondata.cloudcontrol.domain.Servers; +import org.jclouds.dimensiondata.cloudcontrol.domain.State; +import org.jclouds.dimensiondata.cloudcontrol.domain.VirtualHardware; +import org.jclouds.dimensiondata.cloudcontrol.domain.VmTools; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; +import java.util.Collections; +import java.util.List; + +@Test(groups = "unit") +public class ServersParseTest extends BaseDimensionDataCloudControlParseTest { + + @Override + public String resource() { + return "/servers.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public Servers expected() { + List servers = ImmutableList + .of(Server.builder().id("b8246ba4-847d-475b-b296-f76787a69ca8").name("parser-test-server-name") + .description("parser-test-server-description").datacenterId("NA9").state(State.NORMAL) + .sourceImageId("1e44ab3f-2426-45ec-a1b5-827b2ce58836") + .createTime(parseDate("2016-03-10T13:05:21.000Z")).started(true).deployed(true).guest(Guest.builder() + .operatingSystem( + OperatingSystem.builder().id("CENTOS564").displayName("CENTOS5/64").family("UNIX") + .build()).vmTools(VmTools.builder().apiVersion(9354).type(VmTools.Type.VMWARE_TOOLS) + .versionStatus(VmTools.VersionStatus.NEED_UPGRADE) + .runningStatus(VmTools.RunningStatus.RUNNING).build()).osCustomization(true).build()) + .cpu(CPU.builder().count(2).speed("STANDARD").coresPerSocket(1).build()).memoryGb(4).disks(Collections + .singletonList(Disk.builder().id("0ba67812-d7b7-4c3f-b114-870fbea24d42").scsiId(0).sizeGb(10) + .speed("STANDARD").state("NORMAL").build())).networkInfo(NetworkInfo.builder().primaryNic( + NIC.builder().id("980a9fdd-4ea2-478b-85b4-f016349f1738").privateIpv4("10.0.0.8") + .ipv6("2607:f480:111:1575:c47:7479:2af8:3f1a") + .vlanId("6b25b02e-d3a2-4e69-8ca7-9bab605deebd") + .vlanId("6b25b02e-d3a2-4e69-8ca7-9bab605deebd").vlanName("vlan1").state("NORMAL").build()) + .additionalNic(null).networkDomainId("690de302-bb80-49c6-b401-8c02bbefb945").build()) + .virtualHardware(VirtualHardware.builder().upToDate(false).version("vmx-08").build()) + .softwareLabels(Collections.emptyList()).build()); + return new Servers(servers, 1, 5, 5, 250); + } +} diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/VlanParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/VlanParseTest.java new file mode 100644 index 000000000..804e491e1 --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/VlanParseTest.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.jclouds.dimensiondata.cloudcontrol.parse; + +import org.jclouds.dimensiondata.cloudcontrol.domain.IpRange; +import org.jclouds.dimensiondata.cloudcontrol.domain.NetworkDomain; +import org.jclouds.dimensiondata.cloudcontrol.domain.State; +import org.jclouds.dimensiondata.cloudcontrol.domain.Vlan; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +@Test(groups = "unit") +public class VlanParseTest extends BaseDimensionDataCloudControlParseTest { + + @Override + public String resource() { + return "/vlan.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public Vlan expected() { + return Vlan.builder() + .networkDomain(NetworkDomain.builder().id("690de302-bb80-49c6-b401-8c02bbefb945").name("test").build()) + .name("vlan1").description("").privateIpv4Range(IpRange.create("10.0.0.0", 24)) + .ipv4GatewayAddress("10.0.0.1").ipv6Range(IpRange.create("2607:f480:111:1575:0:0:0:0", 64)) + .ipv6GatewayAddress("2607:f480:111:1575:0:0:0:1").createTime(parseDate("2016-03-11T10:41:19.000Z")) + .state(State.NORMAL).datacenterId("NA9").id("6b25b02e-d3a2-4e69-8ca7-9bab605deebd").build(); + } +} diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/utils/ResponseParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/utils/ParseResponseTest.java similarity index 75% rename from dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/utils/ResponseParseTest.java rename to dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/utils/ParseResponseTest.java index 5c4ea1d1f..995e318b4 100644 --- a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/utils/ResponseParseTest.java +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/utils/ParseResponseTest.java @@ -24,8 +24,8 @@ import java.util.ArrayList; import java.util.List; -@Test(groups = "unit", testName = "ResponseParseTest", singleThreaded = true) -public class ResponseParseTest { +@Test(groups = "unit", testName = "ParseResponseTest", singleThreaded = true) +public class ParseResponseTest { public void testTryFindPropertyValue() { @@ -53,4 +53,18 @@ public void testTryFindPropertyValue_PropertyNotFound() { new ParseResponse(null, "noProperty").tryFindInfoPropertyValue(response); } + + public void testTryFindPropertyValue_ErrorReturned() { + + List errorProperties = new ArrayList(); + errorProperties.add(Property.create("propertyName1", "propertyValue1")); + errorProperties.add(Property.create("propertyName2", "propertyValue2")); + + Response response = Response.builder().responseCode("responseCode").error(errorProperties).message("message") + .operation("operation").requestId("requestId").info(null).build(); + + Assert.assertEquals(new ParseResponse(null, "noProperty").checkForErrorElements(response), + "Error Elements: propertyName1:propertyValue1, propertyName2:propertyValue2."); + } + } diff --git a/dimensiondata/src/test/resources/firewallRule.json b/dimensiondata/src/test/resources/firewallRule.json new file mode 100644 index 000000000..e85b5d862 --- /dev/null +++ b/dimensiondata/src/test/resources/firewallRule.json @@ -0,0 +1,25 @@ +{ + "networkDomainId": "484174a2-ae74-4658-9e56-50fc90e086cf", + "name": "CCDEFAULT.BlockOutboundMailIPv6Secure", + "action": "DROP", + "ipVersion": "IPV6", + "protocol": "TCP", + "source": { + "ip": { + "address": "ANY" + } + }, + "destination": { + "ip": { + "address": "ANY" + }, + "port": { + "begin": 587 + } + }, + "enabled": true, + "state": "NORMAL", + "id": "1aa3d0ce-d95d-4296-8338-9717e0d37ff9", + "datacenterId": "NA9", + "ruleType": "DEFAULT_RULE" +} \ No newline at end of file diff --git a/dimensiondata/src/test/resources/server.json b/dimensiondata/src/test/resources/server.json index 9ece77395..f0804e047 100644 --- a/dimensiondata/src/test/resources/server.json +++ b/dimensiondata/src/test/resources/server.json @@ -19,7 +19,7 @@ "primaryNic": { "id": "f0c00cab-bfa3-4c51-8c0a-c52fdac1ae4b", "privateIpv4": "10.0.0.7", - "ipv6": "2a00:47c0: 111: 1131: 5851: 1950:411c: 3dd8", + "ipv6": "2a00:47c0:111:1131:5851:1950:411c:3dd8", "vlanId": "7bd12a4d-4e83-4254-a266-174aa5f55187", "vlanName": "jclouds vlan", "networkAdapter": "E1000", @@ -32,7 +32,7 @@ }, "softwareLabel": [], "sourceImageId": "56eb0b7c-15a7-4b63-b373-05b962e37554", - "createTime": "2017-07-03T16: 29: 33.000Z", + "createTime": "2017-07-03T16:29:33.000Z", "deployed": true, "started": true, "state": "NORMAL",