mirror of https://github.com/apache/jclouds.git
flesh out expect test
This commit is contained in:
parent
e34c085455
commit
16309eaef1
|
@ -30,16 +30,27 @@ import org.jclouds.vcloud.director.v1_5.domain.AvailableNetworks;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Capabilities;
|
import org.jclouds.vcloud.director.v1_5.domain.Capabilities;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage;
|
import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams;
|
import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ComputeCapacity;
|
import org.jclouds.vcloud.director.v1_5.domain.ComputeCapacity;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntities;
|
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntities;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.SupportedHardwareVersions;
|
import org.jclouds.vcloud.director.v1_5.domain.SupportedHardwareVersions;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -49,31 +60,48 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", singleThreaded = true, testName = "VdcClientExpectTest")
|
@Test(groups = { "unit", "apitests", "user" }, singleThreaded = true, testName = "VdcClientExpectTest")
|
||||||
public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||||
|
|
||||||
|
private Reference vdcRef;
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "unit" }, dependsOnMethods = { "setupClient" })
|
||||||
|
public void before() {
|
||||||
|
String vdcId = "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"; // TODO: inject
|
||||||
|
vdcRef = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
|
.name("")
|
||||||
|
.href(URI.create(endpoint+"/vdc/"+vdcId))
|
||||||
|
.id(vdcId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidVdc() {
|
public void testGetVdc() {
|
||||||
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"),
|
new VcloudHttpRequestPrimer()
|
||||||
getStandardPayloadResponse("/vdc/vdc.xml", VCloudDirectorMediaType.VDC));
|
.apiCommand("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f")
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/vdc.xml", VCloudDirectorMediaType.VDC)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
Vdc expected = vdc();
|
Vdc expected = getVdc();
|
||||||
|
|
||||||
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
|
||||||
|
|
||||||
assertEquals(client.getVdcClient().getVdc(vdcRef), expected);
|
assertEquals(client.getVdcClient().getVdc(vdcRef), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs400ForInvalidVdcId() {
|
public void testResponse400ForInvalidVdcId() {
|
||||||
URI vdcUri = URI.create(endpoint + "/vdc/NOTAUUID");
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", "/vdc/NOTAUUID"),
|
new VcloudHttpRequestPrimer()
|
||||||
getStandardPayloadResponse(400, "/vdc/error400.xml", VCloudDirectorMediaType.ERROR));
|
.apiCommand("GET", "/vdc/NOTAUUID")
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/error400.xml", VCloudDirectorMediaType.ERROR)
|
||||||
|
.httpResponseBuilder().statusCode(400).build());
|
||||||
|
|
||||||
Error expected = Error.builder()
|
Error expected = Error.builder()
|
||||||
.message("validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.vdc.")
|
.message("validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.vdc.")
|
||||||
|
@ -81,7 +109,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
.minorErrorCode("BAD_REQUEST")
|
.minorErrorCode("BAD_REQUEST")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
|
||||||
try {
|
try {
|
||||||
client.getVdcClient().getVdc(vdcRef);
|
client.getVdcClient().getVdc(vdcRef);
|
||||||
fail("Should give HTTP 400 error");
|
fail("Should give HTTP 400 error");
|
||||||
|
@ -93,12 +120,15 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs403ForFakeVdcId() {
|
public void testResponse403ForFakeVdcId() {
|
||||||
URI vdcUri = URI.create(endpoint + "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"),
|
new VcloudHttpRequestPrimer()
|
||||||
getStandardPayloadResponse(403, "/vdc/error403-fake.xml", VCloudDirectorMediaType.ERROR));
|
.apiCommand("GET", "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/error403-fake.xml", VCloudDirectorMediaType.ERROR)
|
||||||
|
.httpResponseBuilder().statusCode(403).build());
|
||||||
|
|
||||||
Error expected = Error.builder()
|
Error expected = Error.builder()
|
||||||
.message("No access to entity \"com.vmware.vcloud.entity.vdc:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\".")
|
.message("No access to entity \"com.vmware.vcloud.entity.vdc:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\".")
|
||||||
|
@ -106,8 +136,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.getVdcClient().getVdc(vdcRef);
|
client.getVdcClient().getVdc(vdcRef);
|
||||||
fail("Should give HTTP 403 error");
|
fail("Should give HTTP 403 error");
|
||||||
|
@ -119,28 +147,38 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs2xxLoginCaptureVAppSucceeds() {
|
public void testCaptureVApp() {
|
||||||
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp");
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardPayloadRequest("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp",
|
new VcloudHttpRequestPrimer()
|
||||||
"/vdc/params/captureVApp", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS),
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp")
|
||||||
getStandardPayloadResponse("/vdc/vdc.xml", VCloudDirectorMediaType.VDC));
|
.xmlFilePayload("/vdc/params/captureVApp.xml", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/vdc.xml", VCloudDirectorMediaType.VDC)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
Vdc expected = vdc();
|
VAppTemplate expected = captureVApp();
|
||||||
|
|
||||||
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
// TODO: configure params
|
||||||
|
CaptureVAppParams params = CaptureVAppParams.builder()
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
assertEquals(client.getVdcClient().captureVApp(vdcRef, params), expected);
|
assertEquals(client.getVdcClient().captureVApp(vdcRef, params), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs4xxForCaptureVAppNoParams() {
|
public void testResponse4xxForCaptureVAppNoParams() {
|
||||||
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp");
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp"),
|
new VcloudHttpRequestPrimer()
|
||||||
getStandardPayloadResponse(400, "/vdc/param/error400.xml", VCloudDirectorMediaType.ERROR));
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp")
|
||||||
|
.xmlFilePayload("/vdc/params/captureVApp.xml", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/param/error400.xml", VCloudDirectorMediaType.ERROR)
|
||||||
|
.httpResponseBuilder().statusCode(400).build());
|
||||||
|
|
||||||
Error expected = Error.builder()
|
Error expected = Error.builder()
|
||||||
.message("?")
|
.message("?")
|
||||||
|
@ -148,7 +186,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
.minorErrorCode("BAD_REQUEST")
|
.minorErrorCode("BAD_REQUEST")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
|
||||||
try {
|
try {
|
||||||
client.getVdcClient().captureVApp(vdcRef, null);
|
client.getVdcClient().captureVApp(vdcRef, null);
|
||||||
fail("Should give HTTP 400 error");
|
fail("Should give HTTP 400 error");
|
||||||
|
@ -169,7 +206,161 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
// POST /vdc/{id}/media
|
// POST /vdc/{id}/media
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidMetadataList() {
|
public void testCloneMedia() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia")
|
||||||
|
.xmlFilePayload("/vdc/params/cloneMedia.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/cloneMedia.xml", VCloudDirectorMediaType.MEDIA)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
|
Media expected = cloneMedia();
|
||||||
|
|
||||||
|
// TODO: configure params
|
||||||
|
CloneMediaParams params = CloneMediaParams.builder()
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCloneVApp() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVApp")
|
||||||
|
.xmlFilePayload("/vdc/params/cloneVApp.xml", VCloudDirectorMediaType.CLONE_V_APP_PARAMS)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/cloneVApp.xml", VCloudDirectorMediaType.V_APP)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
|
VApp expected = cloneVApp();
|
||||||
|
|
||||||
|
// TODO: configure params
|
||||||
|
CloneVAppParams params = CloneVAppParams.builder()
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().cloneVApp(vdcRef, params), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCloneVAppTemplate() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVAppTemplate")
|
||||||
|
.xmlFilePayload("/vdc/params/cloneVAppTemplate.xml", VCloudDirectorMediaType.CLONE_V_APP_TEMPLATE_PARAMS)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/cloneVAppTemplate.xml", VCloudDirectorMediaType.V_APP_TEMPLATE)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
|
VAppTemplate expected = cloneVAppTemplate();
|
||||||
|
|
||||||
|
// TODO: configure params
|
||||||
|
CloneVAppTemplateParams params = CloneVAppTemplateParams.builder()
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().cloneVAppTemplate(vdcRef, params), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testComposeVApp() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/composeVApp")
|
||||||
|
.xmlFilePayload("/vdc/params/composeVApp.xml", VCloudDirectorMediaType.COMPOSE_VAPP_PARAMS)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/composeVApp.xml", VCloudDirectorMediaType.V_APP)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
|
VApp expected = composeVApp();
|
||||||
|
|
||||||
|
// TODO: configure params
|
||||||
|
ComposeVAppParams params = ComposeVAppParams.builder()
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().composeVApp(vdcRef, params), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInstantiateVAppTemplate() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/instantiateVAppTemplate")
|
||||||
|
.xmlFilePayload("/vdc/params/instantiateVAppTemplate.xml", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/instantiateVAppTemplate.xml", VCloudDirectorMediaType.V_APP)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
|
VApp expected = instantiateVAppTemplate();
|
||||||
|
|
||||||
|
// TODO: configure params
|
||||||
|
InstantiateVAppTemplateParams params = InstantiateVAppTemplateParams.builder()
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().instantiateVApp(vdcRef, params), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploadVAppTemplate() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/uploadVAppTemplate")
|
||||||
|
.xmlFilePayload("/vdc/params/uploadVAppTemplate.xml", VCloudDirectorMediaType.UPLOAD_VAPP_TEMPLATE_PARAMS)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/uploadVAppTemplate.xml", VCloudDirectorMediaType.V_APP_TEMPLATE)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
|
VAppTemplate expected = uploadVAppTemplate();
|
||||||
|
|
||||||
|
// TODO: configure params
|
||||||
|
UploadVAppTemplateParams params = UploadVAppTemplateParams.builder()
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().uploadVAppTemplate(vdcRef, params), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateMedia() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/media")
|
||||||
|
.xmlFilePayload("/vdc/params/createMedia.xml", VCloudDirectorMediaType.MEDIA)
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/vdc/createMedia.xml", VCloudDirectorMediaType.MEDIA)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
|
Media expected = createMedia();
|
||||||
|
|
||||||
|
// TODO: configure params
|
||||||
|
Media createMedia = Media.builder()
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getVdcClient().createMedia(vdcRef, createMedia), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetMetadata() {
|
||||||
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
|
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
@ -184,7 +375,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
.type("application/vnd.vmware.vcloud.vdc+xml")
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"))
|
||||||
.build())
|
.build())
|
||||||
.metadata(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build()))
|
.entries(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build()))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
||||||
|
@ -193,23 +384,23 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled=false) // No metadata in exemplar xml...
|
@Test(enabled=false) // No metadata in exemplar xml...
|
||||||
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
|
public void testGetMetadataValue() {
|
||||||
URI vdcUri = URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
|
URI vdcUri = URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata/KEY"),
|
getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata/KEY"),
|
||||||
getStandardPayloadResponse("/vdc/metadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY));
|
getStandardPayloadResponse("/vdc/metadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY));
|
||||||
|
|
||||||
MetadataEntry expected = MetadataEntry.builder()
|
MetadataValue expected = MetadataValue.builder()
|
||||||
.entry("key", "value")
|
.value("value")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
Reference vdcRef = Reference.builder().href(vdcUri).build();
|
||||||
|
|
||||||
assertEquals(client.getOrgClient().getMetadataEntry(vdcRef, "KEY"), expected);
|
assertEquals(client.getVdcClient().getMetadataValue(vdcRef, "KEY"), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vdc vdc() {
|
public static Vdc getVdc() {
|
||||||
return Vdc.builder()
|
return Vdc.builder()
|
||||||
.status(1)
|
.status(1)
|
||||||
.name("orgVDC-cloudsoft-Tier1-PAYG")
|
.name("orgVDC-cloudsoft-Tier1-PAYG")
|
||||||
|
@ -338,4 +529,44 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
||||||
.isEnabled(true)
|
.isEnabled(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private VAppTemplate captureVApp() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Media cloneMedia() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VApp cloneVApp() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VAppTemplate cloneVAppTemplate() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VApp composeVApp() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VApp instantiateVAppTemplate() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VAppTemplate uploadVAppTemplate() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Media createMedia() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue