fix typo and tidy tests

This commit is contained in:
danikov 2012-02-07 15:21:11 +00:00
parent e368e8e4cc
commit 0feb27fd93
2 changed files with 10 additions and 35 deletions

View File

@ -46,24 +46,11 @@ import com.google.common.collect.ImmutableMultimap;
public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test
public void testWhenResponseIs2xxLoginReturnsValidOrgList() {
HttpRequest orgListRequest = HttpRequest.builder()
.method("GET")
.endpoint(URI.create("http://localhost/api/org/"))
.headers(ImmutableMultimap.<String, String> builder()
.put("Accept", "*/*")
.put("x-vcloud-authorization",token)
.build())
.build();
HttpResponse orgListResponse = HttpResponse.builder()
.statusCode(200)
.payload(payloadFromResourceWithContentType("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML
+";version=1.5"))
.build();
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", URI.create("http://localhost/api/org/")),
getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML));
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgListRequest,
orgListResponse);
OrgList expected = OrgList.builder()
.org(Reference.builder()
.type("application/vnd.vmware.vcloud.org+xml")
@ -79,21 +66,9 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
public void testWhenResponseIs2xxLoginReturnsValidOrg() {
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
HttpRequest orgRequest = HttpRequest.builder()
.method("GET")
.endpoint(orgRef)
.headers(ImmutableMultimap.<String, String> builder()
.put("Accept", "*/*")
.put("x-vcloud-authorization", token)
.build())
.build();
HttpResponse orgResponse = HttpResponse.builder()
.statusCode(200)
.payload(payloadFromResourceWithContentType("/org/org.xml", VCloudDirectorMediaType.ORG_XML + ";version=1.5"))
.build();
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, orgRequest, orgResponse);
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", orgRef),
getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG_XML));
Org expected = Org
.builder()
@ -154,7 +129,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", metaRef),
getStandardPaylodResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML));
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML));
Metadata expected = Metadata.builder()
.type("application/vnd.vmware.vcloud.metadata+xml")
@ -169,13 +144,13 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
assertEquals(client.getOrgClient().getMetadata(orgRef), expected);
}
@Test(enabled=false)
@Test(enabled=false) // No metadata in exemplar xml...
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", metadataRef),
getStandardPaylodResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML));
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML));
MetadataEntry expected = MetadataEntry.builder()
.build();

View File

@ -65,7 +65,7 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
.build()).build();
}
protected HttpResponse getStandardPaylodResponse(String relativeFilePath, String mediaType) {
protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) {
return HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType+";version=1.5")).build();
}