http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/ProvisionableToImageTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/ProvisionableToImageTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/ProvisionableToImageTest.java new file mode 100644 index 0000000..1861ebf --- /dev/null +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/ProvisionableToImageTest.java @@ -0,0 +1,198 @@ +/* + * 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.apache.jclouds.profitbricks.rest.compute.function; + +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableSet; +import com.squareup.okhttp.mockwebserver.MockResponse; +import java.util.Set; +import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksApiMockTest; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.ImageBuilder; +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.domain.Location; +import org.jclouds.domain.LocationBuilder; +import org.jclouds.domain.LocationScope; +import static org.testng.Assert.assertEquals; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "ProvisionableToImageTest", singleThreaded = true) +public class ProvisionableToImageTest extends BaseProfitBricksApiMockTest { + + private ProvisionableToImage fnImage; + + private final Location location = new LocationBuilder().id("us/las").description("us/las").scope(LocationScope.ZONE) + .parent(new LocationBuilder().id("us").description("us").scope(LocationScope.REGION).build()).build(); + + @BeforeTest + public void setup() { + this.fnImage = new ProvisionableToImage(Suppliers.<Set<? extends Location>>ofInstance(ImmutableSet.of(location))); + } + + @Test + public void testImageToImage() { + + server.enqueue( + new MockResponse().setBody(stringFromResource("/compute/image.json")) + ); + + org.apache.jclouds.profitbricks.rest.domain.Image image = api.imageApi().getImage("some-id"); + + Image actual = fnImage.apply(image); + + Image expected = new ImageBuilder() + .ids(image.id()) + .name(image.properties().name()) + .location(location) + .status(Image.Status.AVAILABLE) + .operatingSystem(OperatingSystem.builder() + .description("UBUNTU") + .family(OsFamily.UBUNTU) + .version("14.04") + .is64Bit(false) + .build()) + .build(); + + assertEquals(actual, expected); + } + + @Test + public void testImageDescriptionParsing() { + + server.enqueue( + new MockResponse().setBody(stringFromResource("/compute/image1.json")) + ); + + org.apache.jclouds.profitbricks.rest.domain.Image image1 = api.imageApi().getImage("some-id"); + + Image actual1 = fnImage.apply(image1); + + Image expected1 = new ImageBuilder() + .ids(image1.id()) + .name(image1.properties().name()) + .location(location) + .status(Image.Status.AVAILABLE) + .operatingSystem(OperatingSystem.builder() + .description("FEDORA") + .family(OsFamily.FEDORA) + .version("7") + .is64Bit(true) + .build()) + .build(); + + assertEquals(actual1, expected1); + + server.enqueue( + new MockResponse().setBody(stringFromResource("/compute/image2.json")) + ); + + org.apache.jclouds.profitbricks.rest.domain.Image image2 = api.imageApi().getImage("some-id"); + + Image actual2 = fnImage.apply(image2); + + Image expected2 = new ImageBuilder() + .ids(image2.id()) + .name(image2.properties().name()) + .location(location) + .status(Image.Status.AVAILABLE) + .operatingSystem(OperatingSystem.builder() + .description("UNRECOGNIZED") + .family(OsFamily.UNRECOGNIZED) + .version("6.5.0") + .is64Bit(true) + .build()) + .build(); + + assertEquals(actual2, expected2); + + server.enqueue( + new MockResponse().setBody(stringFromResource("/compute/image3.json")) + ); + + org.apache.jclouds.profitbricks.rest.domain.Image image3 = api.imageApi().getImage("some-id"); + + Image actual3 = fnImage.apply(image3); + + Image expected3 = new ImageBuilder() + .ids(image3.id()) + .name(image3.properties().name()) + .location(location) + .status(Image.Status.AVAILABLE) + .operatingSystem(OperatingSystem.builder() + .description("WINDOWS") + .family(OsFamily.WINDOWS) + .version("2008") + .is64Bit(false) + .build()) + .build(); + + assertEquals(actual3, expected3); + } + + @Test + public void testSnapshotToImage() { + + server.enqueue( + new MockResponse().setBody(stringFromResource("/compute/snapshot1.json")) + ); + + org.apache.jclouds.profitbricks.rest.domain.Snapshot snapshot1 = api.snapshotApi().get("some-id"); + + Image actual1 = fnImage.apply(snapshot1); + + Image expected1 = new ImageBuilder() + .ids(snapshot1.id()) + .name(snapshot1.properties().name()) + .location(location) + .status(Image.Status.AVAILABLE) + .operatingSystem(OperatingSystem.builder() + .description(snapshot1.properties().description()) + .family(OsFamily.LINUX) + .is64Bit(true) + .build()) + .build(); + + assertEquals(actual1, expected1); + + server.enqueue( + new MockResponse().setBody(stringFromResource("/compute/snapshot2.json")) + ); + + org.apache.jclouds.profitbricks.rest.domain.Snapshot snapshot2 = api.snapshotApi().get("some-id"); + + Image actual2 = fnImage.apply(snapshot2); + + Image expected2 = new ImageBuilder() + .ids(snapshot2.id()) + .name(snapshot2.properties().name()) + .location(location) + .status(Image.Status.PENDING) + .operatingSystem(OperatingSystem.builder() + .description("ubuntu") + .family(OsFamily.UBUNTU) + .is64Bit(true) + .version("00.00") + .build()) + .build(); + + assertEquals(actual2, expected2); + assertEquals(actual2.getOperatingSystem(), expected2.getOperatingSystem()); + + } +}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/ServerInDataCenterToNodeMetadataTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/ServerInDataCenterToNodeMetadataTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/ServerInDataCenterToNodeMetadataTest.java new file mode 100644 index 0000000..3c35e56 --- /dev/null +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/ServerInDataCenterToNodeMetadataTest.java @@ -0,0 +1,157 @@ +/* + * 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.apache.jclouds.profitbricks.rest.compute.function; + +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.name.Names; +import com.squareup.okhttp.mockwebserver.MockResponse; +import java.util.Set; +import org.apache.jclouds.profitbricks.rest.ProfitBricksApi; +import org.apache.jclouds.profitbricks.rest.ProfitBricksApiMetadata; +import org.apache.jclouds.profitbricks.rest.domain.DataCenter; +import org.apache.jclouds.profitbricks.rest.domain.Server; +import org.apache.jclouds.profitbricks.rest.domain.zonescoped.ServerInDataCenter; +import org.apache.jclouds.profitbricks.rest.features.DataCenterApi; +import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksApiMockTest; +import org.easymock.EasyMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import org.jclouds.compute.domain.HardwareBuilder; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.NodeMetadataBuilder; +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Processor; +import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.VolumeBuilder; +import org.jclouds.compute.functions.GroupNamingConvention; +import org.jclouds.domain.Location; +import org.jclouds.domain.LocationBuilder; +import org.jclouds.domain.LocationScope; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "ServerInDataCenterToNodeMetadataTest", singleThreaded = true) +public class ServerInDataCenterToNodeMetadataTest extends BaseProfitBricksApiMockTest { + + private ServerInDataCenterToNodeMetadata fnNodeMetadata; + private DataCenterApi dataCenterApi; + + @BeforeTest + public void setup() { + Supplier<Set<? extends Location>> locationsSupply = new Supplier<Set<? extends Location>>() { + + @Override + public Set<? extends Location> get() { + return ImmutableSet.of( + new LocationBuilder() + .id("mock") + .description("JClouds-DC") + .scope(LocationScope.REGION) + .metadata(ImmutableMap.<String, Object>of( + "version", "10", + "state", "AVAILABLE")) + .parent(new LocationBuilder() + .id("de/fra") + .description("Germany, Frankfurt (M)") + .scope(LocationScope.PROVIDER) + .build()) + .build()); + } + }; + + GroupNamingConvention.Factory namingConvention = Guice.createInjector(new AbstractModule() { + @Override + protected void configure() { + Names.bindProperties(binder(), new ProfitBricksApiMetadata().getDefaultProperties()); + } + }).getInstance(GroupNamingConvention.Factory.class); + + api = EasyMock.createMock(ProfitBricksApi.class); + dataCenterApi = EasyMock.createMock(DataCenterApi.class); + expect(dataCenterApi.getDataCenter("mock")).andReturn( + DataCenter.create("mock", "datacenter", "href", null, DataCenter.Properties.create("location", "location", org.apache.jclouds.profitbricks.rest.domain.Location.MOCK, 0), null)); + expect(api.dataCenterApi()).andReturn(dataCenterApi); + + replay(dataCenterApi, api); + + this.fnNodeMetadata = new ServerInDataCenterToNodeMetadata(new VolumeToVolume(), locationsSupply, api, namingConvention); + } + + @Test + public void testServerInDataCenterToNodeMetadata() { + + server.enqueue( + new MockResponse().setBody(stringFromResource("/compute/server.json")) + ); + Server serverObject = api.serverApi().getServer("mock", "some-id"); + + ServerInDataCenter server = new ServerInDataCenter(serverObject, "mock"); + + NodeMetadata expected = fnNodeMetadata.apply(server); + assertNotNull(expected); + + NodeMetadata actual = new NodeMetadataBuilder() + .group("docker001") + .ids(server.getDataCenter() + "/" + serverObject.id()) + .name(server.getServer().properties().name()) + .backendStatus("AVAILABLE") + .status(NodeMetadata.Status.RUNNING) + .hardware(new HardwareBuilder() + .ids("cpu=4,ram=4096,disk=40") + .name("cpu=4,ram=4096,disk=40") + .ram(server.getServer().properties().ram()) + .processor(new Processor(server.getServer().properties().cores(), 1d)) + .hypervisor("kvm") + .volume(new VolumeBuilder() + .bootDevice(true) + .size(40f) + .id("c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1") + .durable(true) + .type(Volume.Type.LOCAL) + .build()) + .build()) + .operatingSystem(new OperatingSystem.Builder() + .description(OsFamily.LINUX.value()) + .family(OsFamily.LINUX) + .build()) + .location(new LocationBuilder() + .id("mock") + .description("JClouds-DC") + .scope(LocationScope.REGION) + .metadata(ImmutableMap.<String, Object>of( + "version", "10", + "state", "AVAILABLE")) + .parent(new LocationBuilder() + .id("de/fra") + .description("Germany, Frankfurt (M)") + .scope(LocationScope.PROVIDER) + .build()) + .build()) + .publicAddresses(ImmutableList.<String>of("173.252.120.6")) + .build(); + + assertEquals(actual, expected); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/VolumeToVolumeTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/VolumeToVolumeTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/VolumeToVolumeTest.java new file mode 100644 index 0000000..979fee7 --- /dev/null +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/function/VolumeToVolumeTest.java @@ -0,0 +1,58 @@ +/* + * 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.apache.jclouds.profitbricks.rest.compute.function; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksApiMockTest; +import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.VolumeBuilder; +import static org.testng.Assert.assertEquals; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "VolumeToVolumeTest", singleThreaded = true) +public class VolumeToVolumeTest extends BaseProfitBricksApiMockTest { + + private VolumeToVolume fnVolume; + + @BeforeTest + public void setup() { + this.fnVolume = new VolumeToVolume(); + } + + @Test + public void testVolumeToVolume() { + + server.enqueue( + new MockResponse().setBody(stringFromResource("/compute/volume.json")) + ); + + org.apache.jclouds.profitbricks.rest.domain.Volume volume = api.volumeApi().getVolume("datacenter-id", "some-id"); + + Volume actual = fnVolume.apply(volume); + + Volume expected = new VolumeBuilder() + .id(volume.id()) + .size(40f) + .device("1") + .durable(true) + .type(Volume.Type.LOCAL) + .build(); + + assertEquals(actual, expected); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java index 4e73323..22d5ae2 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java @@ -30,23 +30,23 @@ import org.testng.annotations.Test; @Test(groups = "unit", testName = "DataCenterApiMockTest", singleThreaded = true) public class DataCenterApiMockTest extends BaseProfitBricksApiMockTest { - + @Test public void testGetList() throws InterruptedException { server.enqueue( - new MockResponse().setBody(stringFromResource("/datacenter/list.json")) + new MockResponse().setBody(stringFromResource("/datacenter/list.json")) ); - + List<DataCenter> list = dataCenterApi().list(); - + assertNotNull(list); assertEquals(list.size(), 3); assertEquals(list.get(0).properties().name(), "vea"); - + assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/datacenters"); } - + @Test public void testGetListWith404() throws InterruptedException { server.enqueue(response404()); @@ -55,81 +55,82 @@ public class DataCenterApiMockTest extends BaseProfitBricksApiMockTest { assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/datacenters?depth=1"); } - + @Test public void testGetDataCenter() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/datacenter/get.json")); response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); - + server.enqueue(response); - + DataCenter dataCenter = dataCenterApi().getDataCenter("some-id"); - + assertNotNull(dataCenter); assertEquals(dataCenter.properties().name(), "docker"); - + assertEquals(dataCenter.properties().location(), Location.US_LAS); + assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/datacenters/some-id"); } - + public void testGetDataCenterWith404() throws InterruptedException { server.enqueue(response404()); DataCenter dataCenter = dataCenterApi().getDataCenter("some-id"); - + assertNull(dataCenter); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/datacenters/some-id"); } - + @Test public void testCreate() throws InterruptedException { server.enqueue( - new MockResponse().setBody(stringFromResource("/datacenter/get.json")) + new MockResponse().setBody(stringFromResource("/datacenter/get.json")) ); - - DataCenter dataCenter = dataCenterApi().create("test-data-center", "example description", Location.US_LAS.value()); - + + DataCenter dataCenter = dataCenterApi().create("test-data-center", "example description", Location.US_LAS.getId()); + assertNotNull(dataCenter); assertNotNull(dataCenter.id()); - + assertEquals(server.getRequestCount(), 1); - assertSent(server, "POST", "/datacenters", + assertSent(server, "POST", "/datacenters", "{\"properties\": {\"name\": \"test-data-center\", \"description\": \"example description\",\"location\": \"us/las\"}}" ); } - + @Test public void testUpdate() throws InterruptedException { server.enqueue( - new MockResponse().setBody(stringFromResource("/datacenter/get.json")) + new MockResponse().setBody(stringFromResource("/datacenter/get.json")) ); - + DataCenter dataCenter = dataCenterApi().update("some-id", "new name"); - + assertEquals(server.getRequestCount(), 1); assertSent(server, "PATCH", "/datacenters/some-id", "{\"name\": \"new name\"}"); } - + @Test public void testDelete() throws InterruptedException { server.enqueue(response204()); - + dataCenterApi().delete("some-id"); assertEquals(server.getRequestCount(), 1); assertSent(server, "DELETE", "/datacenters/some-id"); } - + @Test public void testDepth() throws InterruptedException { - + for (int i = 1; i <= 5; ++i) { server.enqueue( - new MockResponse().setBody( - stringFromResource(String.format("/datacenter/get-depth-%d.json", i)) - ) + new MockResponse().setBody( + stringFromResource(String.format("/datacenter/get-depth-%d.json", i)) + ) ); DataCenter dataCenter = dataCenterApi().getDataCenter("some-id", new DepthOptions().depth(i)); assertNotNull(dataCenter); @@ -137,9 +138,9 @@ public class DataCenterApiMockTest extends BaseProfitBricksApiMockTest { assertSent(server, "GET", "/datacenters/some-id?depth=" + i); } } - + private DataCenterApi dataCenterApi() { return api.dataCenterApi(); } - + } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApiMockTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApiMockTest.java new file mode 100644 index 0000000..db68b3d --- /dev/null +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpBlockApiMockTest.java @@ -0,0 +1,150 @@ +/* + * 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.apache.jclouds.profitbricks.rest.features; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import java.util.List; +import org.apache.jclouds.profitbricks.rest.domain.IpBlock; +import org.apache.jclouds.profitbricks.rest.domain.Location; +import org.apache.jclouds.profitbricks.rest.domain.options.DepthOptions; +import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksApiMockTest; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "IpBlockApiMockTest", singleThreaded = true) +public class IpBlockApiMockTest extends BaseProfitBricksApiMockTest { + + private IpBlockApi ipBlockApi() { + return api.ipBlockApi(); + } + + @Test + public void testList() throws InterruptedException { + server.enqueue( + new MockResponse().setBody(stringFromResource("/ipblock/list.json")) + ); + + List<IpBlock> list = ipBlockApi().list(); + + assertNotNull(list); + assertEquals(list.size(), 2); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/ipblocks"); + } + + @Test + public void testListWith404() throws InterruptedException { + server.enqueue(response404()); + List<IpBlock> list = ipBlockApi().list(); + assertTrue(list.isEmpty()); + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/ipblocks"); + } + + @Test + public void testListWithDepth() throws InterruptedException { + server.enqueue( + new MockResponse().setBody(stringFromResource("/ipblock/list.depth-5.json")) + ); + + List<IpBlock> list = ipBlockApi().list(new DepthOptions().depth(5)); + + assertNotNull(list); + assertEquals(list.size(), 2); + assertEquals(list.get(0).properties().name(), "jclouds-block"); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/ipblocks?depth=5"); + } + + @Test + public void testListWith404WithDepth() throws InterruptedException { + server.enqueue(response404()); + List<IpBlock> list = ipBlockApi().list(new DepthOptions().depth(5)); + assertTrue(list.isEmpty()); + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/ipblocks?depth=5"); + } + + @Test + public void testGetIpBlock() throws InterruptedException { + MockResponse response = new MockResponse(); + response.setBody(stringFromResource("/ipblock/get.json")); + response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); + + server.enqueue(response); + + IpBlock ipblock = ipBlockApi().get("some-id"); + + assertNotNull(ipblock); + assertEquals(ipblock.properties().name(), "jclouds-block"); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/ipblocks/some-id"); + } + + public void testGetIpBlockWith404() throws InterruptedException { + server.enqueue(response404()); + + IpBlock ipblock = ipBlockApi().get("some-id"); + + assertEquals(ipblock, null); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "GET", "/ipblocks/some-id"); + } + + @Test + public void testCreate() throws InterruptedException { + server.enqueue( + new MockResponse().setBody(stringFromResource("/ipblock/get.json")) + ); + + IpBlock.PropertiesRequest properties = IpBlock.PropertiesRequest.create("jclouds-block", Location.US_LAS.getId(), 2); + IpBlock ipblock = ipBlockApi().create( + IpBlock.Request.creatingBuilder() + .properties(properties) + .build()); + + assertNotNull(ipblock); + assertNotNull(ipblock.id()); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "POST", "/ipblocks", + "{\"properties\":{\n" + + "\"name\":\"jclouds-block\",\n" + + "\"location\":\"us/las\",\n" + + "\"size\":2}\n" + + "}" + ); + } + + @Test + public void testDelete() throws InterruptedException { + server.enqueue( + new MockResponse().setBody("") + ); + + ipBlockApi().delete("some-id"); + assertEquals(server.getRequestCount(), 1); + assertSent(server, "DELETE", "/ipblocks/some-id"); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java new file mode 100644 index 0000000..c88ccda --- /dev/null +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java @@ -0,0 +1,96 @@ +/* + * 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.apache.jclouds.profitbricks.rest.features; + +import com.google.common.base.Predicate; +import java.util.List; +import org.apache.jclouds.profitbricks.rest.domain.IpBlock; +import org.apache.jclouds.profitbricks.rest.domain.Location; +import org.apache.jclouds.profitbricks.rest.domain.State; +import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "IpblockApiLiveTest") +public class IpblockApiLiveTest extends BaseProfitBricksLiveTest { + + IpBlock testIpBlock; + + private IpBlockApi ipBlockApi() { + return api.ipBlockApi(); + } + + @BeforeClass + public void setupTest() { + testIpBlock = ipBlockApi().create(IpBlock.Request.creatingBuilder() + .properties(IpBlock.PropertiesRequest.create("jclouds ipBlock", Location.US_LAS.getId(), 1)).build()); + assertIpBlockAvailable(testIpBlock); + } + + @AfterClass(alwaysRun = true) + public void teardownTest() { + if (testIpBlock != null) { + ipBlockApi().delete(testIpBlock.id()); + assertIpBlockRemoved(testIpBlock); + + } + } + + @Test + public void testGetNic() { + IpBlock ipBlock = ipBlockApi().get(testIpBlock.id()); + + assertNotNull(ipBlock); + assertEquals(ipBlock.id(), testIpBlock.id()); + } + + @Test + public void testList() { + List<IpBlock> ipBlocks = ipBlockApi().list(); + + assertNotNull(ipBlocks); + assertFalse(ipBlocks.isEmpty()); + } + + private void assertIpBlockAvailable(IpBlock ipblock) { + assertPredicate(new Predicate<IpBlock>() { + @Override + public boolean apply(IpBlock testIpBlock) { + IpBlock ipBlock = ipBlockApi().get(testIpBlock.id()); + if (ipBlock == null || ipBlock.metadata() == null) { + return false; + } + + return ipBlock.metadata().state() == State.AVAILABLE; + } + }, ipblock); + } + + private void assertIpBlockRemoved(IpBlock ipblock) { + assertPredicate(new Predicate<IpBlock>() { + @Override + public boolean apply(IpBlock testIpBlock) { + return ipBlockApi().get(testIpBlock.id()) == null; + } + }, ipblock); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java index 6117cf7..e81b8fb 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java @@ -18,6 +18,7 @@ package org.apache.jclouds.profitbricks.rest.features; import com.google.common.base.Predicate; import java.util.List; +import org.apache.jclouds.profitbricks.rest.domain.CpuFamily; import org.apache.jclouds.profitbricks.rest.domain.DataCenter; import org.apache.jclouds.profitbricks.rest.domain.Image; import org.apache.jclouds.profitbricks.rest.domain.Server; @@ -26,13 +27,13 @@ import org.apache.jclouds.profitbricks.rest.domain.Volume; import org.apache.jclouds.profitbricks.rest.ids.ServerRef; import org.apache.jclouds.profitbricks.rest.ids.VolumeRef; import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; @Test(groups = "live", testName = "ServerApiLiveTest") public class ServerApiLiveTest extends BaseProfitBricksLiveTest { @@ -41,7 +42,7 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { private Server testServer; private Image attachedCdrom; private Volume attachedVolume; - + @BeforeClass public void setupTest() { dataCenter = createDataCenter(); @@ -49,40 +50,41 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { @AfterClass(alwaysRun = true) public void teardownTest() { - if (dataCenter != null) + if (dataCenter != null) { deleteDataCenter(dataCenter.id()); + } } - + @Test public void testCreateServer() { assertNotNull(dataCenter); - + testServer = serverApi().createServer( Server.Request.creatingBuilder() .dataCenterId(dataCenter.id()) .name("jclouds-node") + .cpuFamily(CpuFamily.INTEL_XEON) .cores(1) .ram(1024) .build()); - + assertNotNull(testServer); assertEquals(testServer.properties().name(), "jclouds-node"); assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id())); } - @Test(dependsOnMethods = "testCreateServer") public void testGetServer() { Server server = serverApi().getServer(dataCenter.id(), testServer.id()); - + assertNotNull(server); assertEquals(server.id(), testServer.id()); } - + @Test(dependsOnMethods = "testCreateServer") public void testList() { List<Server> servers = serverApi().getList(dataCenter.id()); - + assertNotNull(servers); assertFalse(servers.isEmpty()); assertEquals(servers.size(), 1); @@ -100,10 +102,9 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { .ram(1024 * 2) .cores(2) .build()); - - assertDataCenterAvailable(dataCenter); - + assertNodeAvailable(ServerRef.create(dataCenter.id(), testServer.id())); + assertDataCenterAvailable(dataCenter); assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id())); Server server = serverApi().getServer(dataCenter.id(), testServer.id()); @@ -115,16 +116,16 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { public void testStopServer() { serverApi().stopServer(testServer.dataCenterId(), testServer.id()); assertNodeSuspended(ServerRef.create(dataCenter.id(), testServer.id())); - + Server server = serverApi().getServer(testServer.dataCenterId(), testServer.id()); assertEquals(server.properties().vmState(), Server.Status.SHUTOFF); } - + @Test(dependsOnMethods = "testStopServer") public void testStartServer() { serverApi().startServer(testServer.dataCenterId(), testServer.id()); assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id())); - + Server server = serverApi().getServer(testServer.dataCenterId(), testServer.id()); assertEquals(server.properties().vmState(), Server.Status.RUNNING); } @@ -133,7 +134,7 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { public void testRebootServer() { serverApi().rebootServer(testServer.dataCenterId(), testServer.id()); assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id())); - + Server server = serverApi().getServer(testServer.dataCenterId(), testServer.id()); assertEquals(server.properties().vmState(), Server.Status.RUNNING); } @@ -152,11 +153,11 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { assertVolumeAvailable(VolumeRef.create(dataCenter.id(), volume.id())); attachedVolume = serverApi().attachVolume( - Server.Request.attachVolumeBuilder() - .dataCenterId(testServer.dataCenterId()) - .serverId(testServer.id()) - .volumeId(volume.id()) - .build() + Server.Request.attachVolumeBuilder() + .dataCenterId(testServer.dataCenterId()) + .serverId(testServer.id()) + .volumeId(volume.id()) + .build() ); assertVolumeAttached(testServer, volume.id()); @@ -175,7 +176,7 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { public void testDetachVolume() { serverApi().detachVolume(testServer.dataCenterId(), testServer.id(), attachedVolume.id()); assertVolumeDetached(testServer, attachedVolume.id()); - } + } @Test(dependsOnMethods = "testDetachVolume") public void testListCdroms() { @@ -186,11 +187,11 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { @Test(dependsOnMethods = "testListCdroms") public void testAttachCdrom() { attachedCdrom = serverApi().attachCdrom( - Server.Request.attachCdromBuilder() - .dataCenterId(testServer.dataCenterId()) - .serverId(testServer.id()) - .imageId("7cb4b3a3-50c3-11e5-b789-52540066fee9") - .build() + Server.Request.attachCdromBuilder() + .dataCenterId(testServer.dataCenterId()) + .serverId(testServer.id()) + .imageId("7cb4b3a3-50c3-11e5-b789-52540066fee9") + .build() ); assertEquals(attachedCdrom.properties().name(), "ubuntu-14.04.3-server-amd64.iso"); assertCdromAvailable(testServer, attachedCdrom.id()); @@ -228,14 +229,15 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { String[] params = args.split(","); Image cdrom = serverApi().getCdrom(params[0], params[1], params[2]); - if (cdrom == null || cdrom.metadata() == null) + if (cdrom == null || cdrom.metadata() == null) { return false; + } return cdrom.metadata().state() == State.AVAILABLE; } }, complexId(server.dataCenterId(), server.id(), cdRomId)); } - + private void assertCdromRemoved(Server server, String cdRomId) { assertPredicate(new Predicate<String>() { @Override @@ -253,14 +255,15 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { String[] params = args.split(","); Volume volume = serverApi().getVolume(params[0], params[1], params[2]); - if (volume == null || volume.metadata() == null) + if (volume == null || volume.metadata() == null) { return false; + } return volume.metadata().state() == State.AVAILABLE; } }, complexId(server.dataCenterId(), server.id(), volumeId)); } - + private void assertVolumeDetached(Server server, String volumeId) { assertPredicate(new Predicate<String>() { @Override @@ -270,5 +273,5 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest { } }, complexId(server.dataCenterId(), server.id(), volumeId)); } - + } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java index d4703a9..c3ade07 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java @@ -21,69 +21,72 @@ import com.google.common.collect.Iterables; import java.util.List; import org.apache.jclouds.profitbricks.rest.domain.DataCenter; import org.apache.jclouds.profitbricks.rest.domain.LicenceType; +import org.apache.jclouds.profitbricks.rest.domain.ProvisioningState; import org.apache.jclouds.profitbricks.rest.domain.Snapshot; import org.apache.jclouds.profitbricks.rest.domain.State; import org.apache.jclouds.profitbricks.rest.domain.Volume; import org.apache.jclouds.profitbricks.rest.ids.VolumeRef; import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest; -import org.testng.annotations.Test; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; @Test(groups = "live", testName = "SnapshotApiLiveTest") public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest { - + private DataCenter dataCenter; private Volume testVolume; private Snapshot testSnapshot; - + @BeforeClass public void setupTest() { dataCenter = createDataCenter(); assertDataCenterAvailable(dataCenter); testVolume = api.volumeApi().createVolume( - Volume.Request.creatingBuilder() - .dataCenterId(dataCenter.id()) - .name("jclouds-volume") - .size(3) - .licenceType(LicenceType.LINUX) - .build() + Volume.Request.creatingBuilder() + .dataCenterId(dataCenter.id()) + .name("jclouds-volume") + .size(3) + .licenceType(LicenceType.LINUX) + .build() ); assertNotNull(testVolume); assertVolumeAvailable(testVolume); - + testSnapshot = api.volumeApi().createSnapshot( - Volume.Request.createSnapshotBuilder() - .dataCenterId(testVolume.dataCenterId()) - .volumeId(testVolume.id()) - .name("test-snapshot") - .description("snapshot desc...") - .build()); + Volume.Request.createSnapshotBuilder() + .dataCenterId(testVolume.dataCenterId()) + .volumeId(testVolume.id()) + .name("test-snapshot") + .description("snapshot desc...") + .build()); assertSnapshotAvailable(testSnapshot); } @AfterClass(alwaysRun = true) public void teardownTest() { - if (dataCenter != null) + if (dataCenter != null) { deleteDataCenter(dataCenter.id()); + } } - + @Test public void testList() { List<Snapshot> snapshots = snapshotApi().list(); assertNotNull(snapshots); assertFalse(snapshots.isEmpty()); - + assertTrue(Iterables.any(snapshots, new Predicate<Snapshot>() { - @Override public boolean apply(Snapshot input) { + @Override + public boolean apply(Snapshot input) { return input.id().equals(testSnapshot.id()); } })); @@ -96,21 +99,21 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest { assertNotNull(snapshot); assertEquals(snapshot.id(), testSnapshot.id()); assertEquals(snapshot.properties().name(), "test-snapshot"); - } - + } + @Test(dependsOnMethods = "testGetSnapshot") public void testUpdateSnapshot() { Snapshot snapshot = snapshotApi().update( - Snapshot.Request.updatingBuilder() - .id(testSnapshot.id()) - .name("test-snapshot new name") - .build() + Snapshot.Request.updatingBuilder() + .id(testSnapshot.id()) + .name("test-snapshot new name") + .build() ); assertVolumeAvailable(testVolume); assertEquals(snapshot.properties().name(), "test-snapshot new name"); } - + @Test(dependsOnMethods = "testUpdateSnapshot") public void testDeleteSnapshot() { api.volumeApi().deleteVolume(testVolume.dataCenterId(), testVolume.id()); @@ -118,19 +121,20 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest { snapshotApi().delete(testSnapshot.id()); assertSnapshotRemoved(testSnapshot); } - + private SnapshotApi snapshotApi() { return api.snapshotApi(); } - + private void assertVolumeAvailable(Volume volume) { assertPredicate(new Predicate<VolumeRef>() { @Override public boolean apply(VolumeRef volumeRef) { Volume volume = api.volumeApi().getVolume(volumeRef.dataCenterId(), volumeRef.volumeId()); - if (volume == null || volume.metadata() == null) + if (volume == null || volume.metadata() == null) { return false; + } return volume.metadata().state() == State.AVAILABLE; } @@ -152,14 +156,15 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest { public boolean apply(String id) { Snapshot snapshot = api.snapshotApi().get(id); - if (snapshot == null || snapshot.metadata() == null) + if (snapshot == null || snapshot.metadata() == null) { return false; + } - return snapshot.metadata().state() == State.AVAILABLE; + return snapshot.metadata().state() == ProvisioningState.AVAILABLE; } }, snapshot.id()); } - + private void assertSnapshotRemoved(Snapshot snapshot) { assertPredicate(new Predicate<String>() { @Override @@ -169,5 +174,4 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest { }, snapshot.id()); } - } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java index de944c2..034b438 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiMockTest.java @@ -28,39 +28,39 @@ import org.testng.annotations.Test; @Test(groups = "unit", testName = "SnapshotApiMockTest", singleThreaded = true) public class SnapshotApiMockTest extends BaseProfitBricksApiMockTest { - + @Test public void testGetList() throws InterruptedException { server.enqueue( - new MockResponse().setBody(stringFromResource("/snapshot/list.json")) + new MockResponse().setBody(stringFromResource("/snapshot/list.json")) ); - + List<Snapshot> list = snapshotApi().list(); - + assertNotNull(list); assertEquals(list.size(), 9); assertEquals(list.get(0).properties().name(), "snapshot desc..."); - + assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/snapshots"); } - + @Test public void testGetListWithDepth() throws InterruptedException { server.enqueue( - new MockResponse().setBody(stringFromResource("/snapshot/list-depth-5.json")) + new MockResponse().setBody(stringFromResource("/snapshot/list-depth-5.json")) ); - + List<Snapshot> list = snapshotApi().list(new DepthOptions().depth(5)); - + assertNotNull(list); assertEquals(list.size(), 3); assertEquals(list.get(0).properties().name(), "test snapshot"); - + assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/snapshots?depth=5"); } - + @Test public void testGetListWith404() throws InterruptedException { server.enqueue(response404()); @@ -69,7 +69,7 @@ public class SnapshotApiMockTest extends BaseProfitBricksApiMockTest { assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/snapshots"); } - + @Test public void testGetListWithDepth404() throws InterruptedException { server.enqueue(response404()); @@ -78,102 +78,101 @@ public class SnapshotApiMockTest extends BaseProfitBricksApiMockTest { assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/snapshots?depth=5"); } - + @Test public void testGetSnapshot() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/snapshot/get.json")); response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); - + server.enqueue(response); - + Snapshot snapshot = snapshotApi().get("some-id"); - + assertNotNull(snapshot); assertEquals(snapshot.properties().name(), "snapshot desc..."); - + assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/snapshots/some-id"); } - + @Test public void testGetSnapshotWithDepth() throws InterruptedException { MockResponse response = new MockResponse(); response.setBody(stringFromResource("/snapshot/get-depth-5.json")); response.setHeader("Content-Type", "application/vnd.profitbricks.resource+json"); - + server.enqueue(response); - + Snapshot snapshot = snapshotApi().get("some-id", new DepthOptions().depth(5)); - + assertNotNull(snapshot); assertEquals(snapshot.properties().name(), "test snapshot 2"); - + assertEquals(this.server.getRequestCount(), 1); assertSent(this.server, "GET", "/snapshots/some-id?depth=5"); } - - + public void testGetSnapshotWith404() throws InterruptedException { server.enqueue(response404()); Snapshot snapshot = snapshotApi().get("some-id"); - + assertEquals(snapshot, null); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/snapshots/some-id"); - } - + } + public void testGetSnapshotWithDepth404() throws InterruptedException { server.enqueue(response404()); Snapshot snapshot = snapshotApi().get("some-id", new DepthOptions().depth(5)); - + assertEquals(snapshot, null); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/snapshots/some-id?depth=5"); - } - + } + @Test public void testUpdate() throws InterruptedException { server.enqueue( - new MockResponse().setBody(stringFromResource("/snapshot/get.json")) + new MockResponse().setBody(stringFromResource("/snapshot/get.json")) ); - + api.snapshotApi().update( Snapshot.Request.updatingBuilder() .id("some-id") .name("new-snapshot-name") .description("description...") .build()); - + assertEquals(server.getRequestCount(), 1); assertSent(server, "PATCH", "/rest/snapshots/some-id", "{\"name\": \"new-snapshot-name\", \"description\": \"description...\"}"); } - + @Test public void testDelete() throws InterruptedException { server.enqueue(response204()); - + snapshotApi().delete("some-id"); assertEquals(server.getRequestCount(), 1); assertSent(server, "DELETE", "/snapshots/some-id"); } - + @Test public void testDeleteWith404() throws InterruptedException { server.enqueue(response404()); snapshotApi().delete("some-id"); - + assertEquals(server.getRequestCount(), 1); assertSent(server, "DELETE", "/snapshots/some-id"); } - + private SnapshotApi snapshotApi() { return api.snapshotApi(); } - + } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java index ec6532a..98c8090 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java @@ -22,6 +22,8 @@ import java.util.List; import org.apache.jclouds.profitbricks.rest.domain.DataCenter; import org.apache.jclouds.profitbricks.rest.domain.Image; import org.apache.jclouds.profitbricks.rest.domain.LicenceType; +import static org.apache.jclouds.profitbricks.rest.domain.Location.US_LAS; +import org.apache.jclouds.profitbricks.rest.domain.ProvisioningState; import org.apache.jclouds.profitbricks.rest.domain.Snapshot; import org.apache.jclouds.profitbricks.rest.domain.State; import org.apache.jclouds.profitbricks.rest.domain.Volume; @@ -29,12 +31,12 @@ import org.apache.jclouds.profitbricks.rest.domain.VolumeType; import org.apache.jclouds.profitbricks.rest.domain.options.DepthOptions; import org.apache.jclouds.profitbricks.rest.ids.VolumeRef; import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; @Test(groups = "live", testName = "VolumeApiLiveTest") public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { @@ -50,31 +52,30 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { @AfterClass(alwaysRun = true) public void teardownTest() { - if (dataCenter != null) + if (dataCenter != null) { deleteDataCenter(dataCenter.id()); + } } @Test public void testCreateVolume() { assertNotNull(dataCenter); - + List<Image> images = api.imageApi().getList(new DepthOptions().depth(5)); - + Image testImage = null; - + for (Image image : images) { - if ( - image.metadata().state() == State.AVAILABLE && - image.properties().isPublic() && - image.properties().imageType() == Image.Type.HDD && - image.properties().location() == TestLocation && - image.properties().licenceType() == LicenceType.LINUX && - ( testImage == null || testImage.properties().size() > image.properties().size() ) - ) { + if (image.metadata().state() == State.AVAILABLE + && image.properties().isPublic() + && image.properties().imageType() == Image.Type.HDD + && image.properties().location() == US_LAS + && image.properties().licenceType() == LicenceType.LINUX + && (testImage == null || testImage.properties().size() > image.properties().size())) { testImage = image; } } - + HashSet<String> sshKeys = new HashSet<String>(); sshKeys.add("hQGOEJeFL91EG3+l9TtRbWNjzhDVHeLuL3NWee6bekA="); @@ -84,7 +85,7 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { .name("jclouds-volume") .size(4) .licenceType(LicenceType.LINUX) - .type(VolumeType.HDD) + .type(VolumeType.SSD) .image(testImage.id()) .sshKeys(sshKeys) .build()); @@ -94,7 +95,6 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { assertVolumeAvailable(testVolume); } - @Test(dependsOnMethods = "testCreateVolume") public void testGetVolume() { Volume volume = volumeApi().getVolume(dataCenter.id(), testVolume.id()); @@ -130,12 +130,12 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { @Test(dependsOnMethods = "testUpdateVolume") public void testCreateSnapshot() { testSnapshot = volumeApi().createSnapshot( - Volume.Request.createSnapshotBuilder() - .dataCenterId(testVolume.dataCenterId()) - .volumeId(testVolume.id()) - .name("test-snapshot") - .description("snapshot desc...") - .build()); + Volume.Request.createSnapshotBuilder() + .dataCenterId(testVolume.dataCenterId()) + .volumeId(testVolume.id()) + .name("test-snapshot") + .description("snapshot desc...") + .build()); assertSnapshotAvailable(testSnapshot); } @@ -143,11 +143,11 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { @Test(dependsOnMethods = "testCreateSnapshot") public void testRestoreSnapshot() { volumeApi().restoreSnapshot( - Volume.Request.restoreSnapshotBuilder() - .dataCenterId(testVolume.dataCenterId()) - .volumeId(testVolume.id()) - .snapshotId(testSnapshot.id()) - .build() + Volume.Request.restoreSnapshotBuilder() + .dataCenterId(testVolume.dataCenterId()) + .volumeId(testVolume.id()) + .snapshotId(testSnapshot.id()) + .build() ); assertVolumeAvailable(testVolume); } @@ -165,8 +165,9 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { public boolean apply(VolumeRef volumeRef) { Volume volume = volumeApi().getVolume(volumeRef.dataCenterId(), volumeRef.volumeId()); - if (volume == null || volume.metadata() == null) + if (volume == null || volume.metadata() == null) { return false; + } return volume.metadata().state() == State.AVAILABLE; } @@ -188,10 +189,11 @@ public class VolumeApiLiveTest extends BaseProfitBricksLiveTest { public boolean apply(String id) { Snapshot snapshot = api.snapshotApi().get(id); - if (snapshot == null || snapshot.metadata() == null) + if (snapshot == null || snapshot.metadata() == null) { return false; + } - return snapshot.metadata().state() == State.AVAILABLE; + return snapshot.metadata().state() == ProvisioningState.AVAILABLE; } }, snapshot.id()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java index 74dde47..9e50dba 100644 --- a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java +++ b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java @@ -26,13 +26,12 @@ import com.google.inject.name.Names; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.apache.jclouds.profitbricks.rest.ProfitBricksApi; -import org.apache.jclouds.profitbricks.rest.util.ApiPredicatesModule.ComputeConstants; +import org.apache.jclouds.profitbricks.rest.compute.config.ProfitBricksComputeServiceContextModule.ComputeConstants; import static org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER; -import static org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.TIMEOUT_NODE_RUNNING; -import static org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.TIMEOUT_NODE_SUSPENDED; import org.apache.jclouds.profitbricks.rest.domain.DataCenter; import org.apache.jclouds.profitbricks.rest.domain.LicenceType; import org.apache.jclouds.profitbricks.rest.domain.Location; +import static org.apache.jclouds.profitbricks.rest.domain.Location.US_LAS; import org.apache.jclouds.profitbricks.rest.domain.Nic; import org.apache.jclouds.profitbricks.rest.domain.Server; import org.apache.jclouds.profitbricks.rest.domain.State; @@ -41,90 +40,97 @@ import org.apache.jclouds.profitbricks.rest.domain.VolumeType; import org.apache.jclouds.profitbricks.rest.ids.ServerRef; import org.apache.jclouds.profitbricks.rest.ids.VolumeRef; import org.jclouds.apis.BaseApiLiveTest; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; import org.jclouds.util.Predicates2; import static org.testng.Assert.assertTrue; public class BaseProfitBricksLiveTest extends BaseApiLiveTest<ProfitBricksApi> { - + public static final Location TestLocation = Location.US_LASDEV; - + private Predicate<String> dataCenterAvailable; private Predicate<ServerRef> serverRunning; private Predicate<ServerRef> serverSuspended; private Predicate<ServerRef> serverAvailable; private Predicate<ServerRef> serverRemoved; private Predicate<VolumeRef> volumeAvailable; - + ComputeConstants computeConstants; - + public BaseProfitBricksLiveTest() { - provider = "profitbricks-rest"; + provider = "profitbricks-rest"; } - + @Override protected ProfitBricksApi create(Properties props, Iterable<Module> modules) { - + Injector injector = newBuilder().modules(modules).overrides(props).buildInjector(); - + computeConstants = injector.getInstance(ComputeConstants.class); - + dataCenterAvailable = injector.getInstance( - Key.get(new TypeLiteral<Predicate<String>>() {}, Names.named(POLL_PREDICATE_DATACENTER)) + Key.get(new TypeLiteral<Predicate<String>>() { + }, Names.named(POLL_PREDICATE_DATACENTER)) ); - + serverRunning = injector.getInstance( - Key.get(new TypeLiteral<Predicate<ServerRef>>() {}, Names.named(TIMEOUT_NODE_RUNNING)) + Key.get(new TypeLiteral<Predicate<ServerRef>>() { + }, Names.named(TIMEOUT_NODE_RUNNING)) ); - + serverSuspended = injector.getInstance( - Key.get(new TypeLiteral<Predicate<ServerRef>>() {}, Names.named(TIMEOUT_NODE_SUSPENDED)) + Key.get(new TypeLiteral<Predicate<ServerRef>>() { + }, Names.named(TIMEOUT_NODE_SUSPENDED)) ); - + ComputeConstants c = computeConstants; - + Predicate<ServerRef> serverAvailableCheck = new Predicate<ServerRef>() { @Override public boolean apply(ServerRef serverRef) { Server server = api.serverApi().getServer(serverRef.dataCenterId(), serverRef.serverId()); - if (server == null || server.metadata().state() == null) + if (server == null || server.metadata().state() == null) { return false; + } return server.metadata().state() == State.AVAILABLE; } }; - + serverAvailable = Predicates2.retry(serverAvailableCheck, c.pollTimeout(), c.pollPeriod(), c.pollMaxPeriod(), TimeUnit.SECONDS); - + Predicate<ServerRef> serverRemovedPredicate = new Predicate<ServerRef>() { @Override public boolean apply(ServerRef serverRef) { return api.serverApi().getServer(serverRef.dataCenterId(), serverRef.serverId()) == null; } }; - + serverRemoved = Predicates2.retry(serverRemovedPredicate, c.pollTimeout(), c.pollPeriod(), c.pollMaxPeriod(), TimeUnit.SECONDS); - + Predicate<VolumeRef> volumeAvailablePredicate = new Predicate<VolumeRef>() { @Override public boolean apply(VolumeRef volumeRef) { Volume volume = api.volumeApi().getVolume(volumeRef.dataCenterId(), volumeRef.volumeId()); - - if (volume == null || volume.metadata() == null) + + if (volume == null || volume.metadata() == null) { return false; + } return volume.metadata().state() == State.AVAILABLE; } }; - + volumeAvailable = Predicates2.retry(volumeAvailablePredicate, c.pollTimeout(), c.pollPeriod(), c.pollMaxPeriod(), TimeUnit.SECONDS); - + return injector.getInstance(ProfitBricksApi.class); } - + protected <T> void assertPredicate(Predicate<T> check, T arguments) { ComputeConstants c = computeConstants; - Predicate<T>checkPoll = Predicates2.retry(check, c.pollTimeout(), c.pollPeriod(), c.pollMaxPeriod(), TimeUnit.SECONDS); + Predicate<T> checkPoll = Predicates2.retry(check, c.pollTimeout(), c.pollPeriod(), c.pollMaxPeriod(), TimeUnit.SECONDS); assertTrue(checkPoll.apply(arguments), "Random check failed in the configured timeout"); } @@ -144,42 +150,43 @@ public class BaseProfitBricksLiveTest extends BaseApiLiveTest<ProfitBricksApi> { protected void assertNodeSuspended(ServerRef serverRef) { assertTrue(serverSuspended.apply(serverRef), String.format("Server %s did not stop in the configured timeout", serverRef)); } - + protected void assertNodeRemoved(ServerRef serverRef) { assertTrue(serverRemoved.apply(serverRef), String.format("Server %s was not removed in the configured timeout", serverRef)); } - + protected void assertNodeAvailable(ServerRef serverRef) { assertTrue(serverAvailable.apply(serverRef), String.format("Server %s is not available", serverRef)); } - + protected void assertVolumeAvailable(VolumeRef volumeRef) { assertTrue(volumeAvailable.apply(volumeRef), String.format("Volume %s wasn't available in the configured timeout", volumeRef.volumeId())); } - + protected void assertNicAvailable(Nic nic) { assertPredicate(new Predicate<Nic>() { @Override public boolean apply(Nic testNic) { Nic nic = api.nicApi().get(testNic.dataCenterId(), testNic.serverId(), testNic.id()); - - if (nic == null || nic.metadata() == null) + + if (nic == null || nic.metadata() == null) { return false; - + } + return nic.metadata().state() == State.AVAILABLE; } }, nic); } - + protected DataCenter createDataCenter() { - return api.dataCenterApi().create("test-data-center", "example description", TestLocation.value()); + return api.dataCenterApi().create("test-data-center", "example description", US_LAS.getId()); } - + protected void deleteDataCenter(String id) { api.dataCenterApi().delete(id); } - + protected Volume createVolume(DataCenter dataCenter) { return api.volumeApi().createVolume( Volume.Request.creatingBuilder() @@ -190,8 +197,8 @@ public class BaseProfitBricksLiveTest extends BaseApiLiveTest<ProfitBricksApi> { .licenceType(LicenceType.LINUX) .build()); } - - protected String complexId(String ... ids) { + + protected String complexId(String... ids) { return Joiner.on(",").join(ids); } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/resources/compute/datacenter.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/compute/datacenter.json b/profitbricks-rest/src/test/resources/compute/datacenter.json new file mode 100644 index 0000000..b026ccf --- /dev/null +++ b/profitbricks-rest/src/test/resources/compute/datacenter.json @@ -0,0 +1,123 @@ +{ + "id": "12345678-abcd-efgh-ijkl-987654321000", + "type": "datacenter", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419", + "metadata": { + "createdDate": "2014-10-20T21:20:46Z", + "createdBy": "[email protected]", + "etag": "9f6fc5de2dc07df011fff0e45a75b8c5", + "lastModifiedDate": "2015-05-12T17:21:54Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "docker", + "description": "Docker environment for generating Docker specific tutorials.", + "location": "de/fra", + "version": 10 + }, + "entities": { + "servers": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/servers", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/servers", + "items": [ + { + "id": "364f0f1c-7384-462b-8f0c-cfc4c3f6e2b2", + "type": "server", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/servers/364f0f1c-7384-462b-8f0c-cfc4c3f6e2b2" + }, + { + "id": "430ccbff-e67b-43de-bfce-097e068e57ba", + "type": "server", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/servers/430ccbff-e67b-43de-bfce-097e068e57ba" + }, + { + "id": "97bd33ed-b97e-4312-acc1-96f44c6e4465", + "type": "server", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/servers/97bd33ed-b97e-4312-acc1-96f44c6e4465" + }, + { + "id": "93e2efc3-752c-4c08-8997-e688891e53bf", + "type": "server", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/servers/93e2efc3-752c-4c08-8997-e688891e53bf" + }, + { + "id": "8345c895-727f-496c-80af-1e7224b2f34e", + "type": "server", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/servers/8345c895-727f-496c-80af-1e7224b2f34e" + } + ] + }, + "volumes": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/volumes", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes", + "items": [ + { + "id": "5c4d37ca-d620-4546-8b24-f92e3c608c2c", + "type": "volume", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes/5c4d37ca-d620-4546-8b24-f92e3c608c2c" + }, + { + "id": "f9217444-4711-477f-83d8-24adea5d9557", + "type": "volume", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes/f9217444-4711-477f-83d8-24adea5d9557" + }, + { + "id": "0eea1824-8079-4c80-8e18-4e1e41a80368", + "type": "volume", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes/0eea1824-8079-4c80-8e18-4e1e41a80368" + }, + { + "id": "c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1", + "type": "volume", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes/c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1" + }, + { + "id": "dc2f35f4-7335-46f2-b30f-96e31c5ba54d", + "type": "volume", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes/dc2f35f4-7335-46f2-b30f-96e31c5ba54d" + }, + { + "id": "af473785-b791-4724-bb01-242035bf88ef", + "type": "volume", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes/af473785-b791-4724-bb01-242035bf88ef" + } + ] + }, + "loadbalancers": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/loadbalancers", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/loadbalancers", + "items": [] + }, + "lans": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/lans", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/lans", + "items": [ + { + "id": "4", + "type": "lan", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/lans/4" + }, + { + "id": "3", + "type": "lan", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/lans/3" + }, + { + "id": "2", + "type": "lan", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/lans/2" + }, + { + "id": "1", + "type": "lan", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/lans/1" + } + ] + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/resources/compute/image.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/compute/image.json b/profitbricks-rest/src/test/resources/compute/image.json new file mode 100644 index 0000000..61c54ed --- /dev/null +++ b/profitbricks-rest/src/test/resources/compute/image.json @@ -0,0 +1,32 @@ +{ + "id": "5ad99c9e-9166-11e4-9d74-52540066fee9", + "type": "image", + "href": "https://api.profitbricks.com/rest/images/5468d4f1-50bf-11e5-b789-52540066fee9", + "metadata": { + "createdDate": "2015-09-01T15:37:18Z", + "createdBy": "System", + "etag": "deeb6ea22d099ce8cddd1fc84e414fbe", + "lastModifiedDate": "2015-09-01T15:37:18Z", + "lastModifiedBy": "System", + "state": "AVAILABLE" + }, + "properties": { + "name": "Ubuntu-14.04-LTS-server-2015-01-01", + "description": null, + "location": "us/las", + "size": 2, + "cpuHotPlug": true, + "cpuHotUnplug": false, + "ramHotPlug": true, + "ramHotUnplug": false, + "nicHotPlug": true, + "nicHotUnplug": true, + "discVirtioHotPlug": true, + "discVirtioHotUnplug": true, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX", + "imageType": "HDD", + "public": true + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/resources/compute/image1.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/compute/image1.json b/profitbricks-rest/src/test/resources/compute/image1.json new file mode 100644 index 0000000..3e9aaa8 --- /dev/null +++ b/profitbricks-rest/src/test/resources/compute/image1.json @@ -0,0 +1,32 @@ +{ + "id": "f4742db0-9160-11e4-9d74-52540066fee9", + "type": "image", + "href": "https://api.profitbricks.com/rest/images/5468d4f1-50bf-11e5-b789-52540066fee9", + "metadata": { + "createdDate": "2015-09-01T15:37:18Z", + "createdBy": "System", + "etag": "deeb6ea22d099ce8cddd1fc84e414fbe", + "lastModifiedDate": "2015-09-01T15:37:18Z", + "lastModifiedBy": "System", + "state": "AVAILABLE" + }, + "properties": { + "name": "Fedora-19-server-2015-01-01", + "description": null, + "location": "us/las", + "size": 2, + "cpuHotPlug": true, + "cpuHotUnplug": false, + "ramHotPlug": true, + "ramHotUnplug": false, + "nicHotPlug": true, + "nicHotUnplug": true, + "discVirtioHotPlug": true, + "discVirtioHotUnplug": true, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX", + "imageType": "HDD", + "public": true + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/resources/compute/image2.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/compute/image2.json b/profitbricks-rest/src/test/resources/compute/image2.json new file mode 100644 index 0000000..dae0c65 --- /dev/null +++ b/profitbricks-rest/src/test/resources/compute/image2.json @@ -0,0 +1,32 @@ +{ + "id": "457bf707-d5d1-11e3-8b4f-52540066fee9", + "type": "image", + "href": "https://api.profitbricks.com/rest/images/5468d4f1-50bf-11e5-b789-52540066fee9", + "metadata": { + "createdDate": "2015-09-01T15:37:18Z", + "createdBy": "System", + "etag": "deeb6ea22d099ce8cddd1fc84e414fbe", + "lastModifiedDate": "2015-09-01T15:37:18Z", + "lastModifiedBy": "System", + "state": "AVAILABLE" + }, + "properties": { + "name": "clearos-community-6.5.0-x86_64.iso", + "description": null, + "location": "us/las", + "size": 2, + "cpuHotPlug": true, + "cpuHotUnplug": false, + "ramHotPlug": true, + "ramHotUnplug": false, + "nicHotPlug": true, + "nicHotUnplug": true, + "discVirtioHotPlug": true, + "discVirtioHotUnplug": true, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "LINUX", + "imageType": "CDROM", + "public": true + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/resources/compute/image3.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/compute/image3.json b/profitbricks-rest/src/test/resources/compute/image3.json new file mode 100644 index 0000000..8bd2d41 --- /dev/null +++ b/profitbricks-rest/src/test/resources/compute/image3.json @@ -0,0 +1,32 @@ +{ + "id": "e54af701-53b8-11e3-8f17-52540066fee9", + "type": "image", + "href": "https://api.profitbricks.com/rest/images/5468d4f1-50bf-11e5-b789-52540066fee9", + "metadata": { + "createdDate": "2015-09-01T15:37:18Z", + "createdBy": "System", + "etag": "deeb6ea22d099ce8cddd1fc84e414fbe", + "lastModifiedDate": "2015-09-01T15:37:18Z", + "lastModifiedBy": "System", + "state": "AVAILABLE" + }, + "properties": { + "name": "windows-2008-r2-server-setup.iso", + "description": null, + "location": "us/las", + "size": 2, + "cpuHotPlug": true, + "cpuHotUnplug": false, + "ramHotPlug": true, + "ramHotUnplug": false, + "nicHotPlug": true, + "nicHotUnplug": true, + "discVirtioHotPlug": true, + "discVirtioHotUnplug": true, + "discScsiHotPlug": false, + "discScsiHotUnplug": false, + "licenceType": "WINDOWS", + "imageType": "CDROM", + "public": true + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/resources/compute/predicate/datacenter-inprocess.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/compute/predicate/datacenter-inprocess.json b/profitbricks-rest/src/test/resources/compute/predicate/datacenter-inprocess.json new file mode 100644 index 0000000..06d6a77 --- /dev/null +++ b/profitbricks-rest/src/test/resources/compute/predicate/datacenter-inprocess.json @@ -0,0 +1,41 @@ +{ + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419", + "type": "datacenter", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419", + "metadata": { + "createdDate": "2014-10-20T21:20:46Z", + "createdBy": "[email protected]", + "etag": "9f6fc5de2dc07df011fff0e45a75b8c5", + "lastModifiedDate": "2015-05-12T17:21:54Z", + "lastModifiedBy": "[email protected]", + "state": "BUSY" + }, + "properties": { + "name": "docker", + "description": "Docker environment for generating Docker specific tutorials.", + "location": "us/las", + "version": 38 + }, + "entities": { + "servers": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/servers", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/servers" + }, + "volumes": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/volumes", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes" + }, + "loadbalancers": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/loadbalancers", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/loadbalancers" + }, + "lans": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/lans", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/lans" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5742745e/profitbricks-rest/src/test/resources/compute/predicate/datacenter.json ---------------------------------------------------------------------- diff --git a/profitbricks-rest/src/test/resources/compute/predicate/datacenter.json b/profitbricks-rest/src/test/resources/compute/predicate/datacenter.json new file mode 100644 index 0000000..fa0e768 --- /dev/null +++ b/profitbricks-rest/src/test/resources/compute/predicate/datacenter.json @@ -0,0 +1,41 @@ +{ + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419", + "type": "datacenter", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419", + "metadata": { + "createdDate": "2014-10-20T21:20:46Z", + "createdBy": "[email protected]", + "etag": "9f6fc5de2dc07df011fff0e45a75b8c5", + "lastModifiedDate": "2015-05-12T17:21:54Z", + "lastModifiedBy": "[email protected]", + "state": "AVAILABLE" + }, + "properties": { + "name": "docker", + "description": "Docker environment for generating Docker specific tutorials.", + "location": "us/las", + "version": 38 + }, + "entities": { + "servers": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/servers", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/servers" + }, + "volumes": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/volumes", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/volumes" + }, + "loadbalancers": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/loadbalancers", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/loadbalancers" + }, + "lans": { + "id": "b0ac144e-e294-415f-ba39-6737d5a9d419/lans", + "type": "collection", + "href": "https://api.profitbricks.com/rest/datacenters/b0ac144e-e294-415f-ba39-6737d5a9d419/lans" + } + } +} \ No newline at end of file
