mirror of https://github.com/apache/jclouds.git
Issue 830: Remove generics from QueryResultRecords, fixes JDK7 build
This commit is contained in:
parent
323238168c
commit
797484917c
|
@ -43,6 +43,7 @@ public class ContainerType extends ResourceType {
|
|||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromContainerType(this);
|
||||
}
|
||||
|
|
|
@ -45,30 +45,30 @@ import com.google.common.collect.Sets;
|
|||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlRootElement(name = "QueryResultRecords")
|
||||
public class QueryResultRecords<R extends QueryResultRecordType> extends ContainerType {
|
||||
public class QueryResultRecords extends ContainerType {
|
||||
|
||||
public static final String MEDIA_TYPE = VCloudDirectorMediaType.QUERY_RESULT_RECORDS;
|
||||
|
||||
public static <R extends QueryResultRecordType> Builder<R, ?> builder() {
|
||||
return new ConcreteBuilder<R>();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<R, ?> toBuilder() {
|
||||
return QueryResultRecords.<R>builder().fromQueryResultRecords(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultRecords(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder<R extends QueryResultRecordType> extends Builder<R, ConcreteBuilder<R>> {
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static class Builder<R extends QueryResultRecordType, B extends Builder<R, B>> extends ContainerType.Builder<B> {
|
||||
public static class Builder<B extends Builder<B>> extends ContainerType.Builder<B> {
|
||||
|
||||
private Set<R> records = Sets.newLinkedHashSet();
|
||||
private Set<QueryResultRecordType> records = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see QueryResultRecords#getRecords()
|
||||
*/
|
||||
public B records(Set<? extends R> records) {
|
||||
public B records(Set<QueryResultRecordType> records) {
|
||||
this.records = Sets.newLinkedHashSet(checkNotNull(records, "records"));
|
||||
return self();
|
||||
}
|
||||
|
@ -76,22 +76,22 @@ public class QueryResultRecords<R extends QueryResultRecordType> extends Contain
|
|||
/**
|
||||
* @see QueryResultRecords#getRecords()
|
||||
*/
|
||||
public B record(R record) {
|
||||
this.records.add(record);
|
||||
public B record(QueryResultRecordType record) {
|
||||
this.records.add(checkNotNull(record, "record"));
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultRecords<R> build() {
|
||||
return new QueryResultRecords<R>(this);
|
||||
public QueryResultRecords build() {
|
||||
return new QueryResultRecords(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultRecords(QueryResultRecords<R> in) {
|
||||
public B fromQueryResultRecords(QueryResultRecords in) {
|
||||
return fromContainerType(in).records(in.getRecords());
|
||||
}
|
||||
}
|
||||
|
||||
protected QueryResultRecords(Builder<R,?> builder) {
|
||||
protected QueryResultRecords(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.records = ImmutableSet.copyOf(builder.records);
|
||||
}
|
||||
|
@ -101,12 +101,12 @@ public class QueryResultRecords<R extends QueryResultRecordType> extends Contain
|
|||
}
|
||||
|
||||
@XmlElementRef
|
||||
private Set<R> records = Sets.newLinkedHashSet();
|
||||
private Set<QueryResultRecordType> records = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* Set of records representing query results.
|
||||
*/
|
||||
public Set<R> getRecords() {
|
||||
public Set<QueryResultRecordType> getRecords() {
|
||||
return Collections.unmodifiableSet(records);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class QueryResultRecords<R extends QueryResultRecordType> extends Contain
|
|||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultRecords<?> that = QueryResultRecords.class.cast(o);
|
||||
QueryResultRecords that = QueryResultRecords.class.cast(o);
|
||||
return super.equals(that) && equal(this.records, that.records);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,96 +50,96 @@ public interface AdminQueryAsyncClient extends QueryAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> groupsQueryAll();
|
||||
ListenableFuture<QueryResultRecords> groupsQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/groups/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> groupsQuery(@QueryParam("filter") String filter);
|
||||
ListenableFuture<QueryResultRecords> groupsQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/orgs/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> orgsQueryAll();
|
||||
ListenableFuture<QueryResultRecords> orgsQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/orgs/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> orgsQuery(@QueryParam("filter") String filter);
|
||||
ListenableFuture<QueryResultRecords> orgsQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/rights/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> rightsQueryAll();
|
||||
ListenableFuture<QueryResultRecords> rightsQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/rights/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> rightsQuery(@QueryParam("filter") String filter);
|
||||
ListenableFuture<QueryResultRecords> rightsQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/roles/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> rolesQueryAll();
|
||||
ListenableFuture<QueryResultRecords> rolesQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/roles/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> rolesQuery(@QueryParam("filter") String filter);
|
||||
ListenableFuture<QueryResultRecords> rolesQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/strandedUsers/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> strandedUsersQueryAll();
|
||||
ListenableFuture<QueryResultRecords> strandedUsersQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/strandedUsers/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> strandedUsersQuery(@QueryParam("filter") String filter);
|
||||
ListenableFuture<QueryResultRecords> strandedUsersQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/users/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> usersQueryAll();
|
||||
ListenableFuture<QueryResultRecords> usersQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/users/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> usersQuery(@QueryParam("filter") String filter);
|
||||
ListenableFuture<QueryResultRecords> usersQuery(@QueryParam("filter") String filter);
|
||||
|
||||
@GET
|
||||
@Path("/admin/vdcs/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> vdcsQueryAll();
|
||||
ListenableFuture<QueryResultRecords> vdcsQueryAll();
|
||||
|
||||
@GET
|
||||
@Path("/admin/vdcs/query")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<QueryResultRecords<?>> vdcsQuery(@QueryParam("filter") String filter);
|
||||
ListenableFuture<QueryResultRecords> vdcsQuery(@QueryParam("filter") String filter);
|
||||
}
|
||||
|
|
|
@ -48,10 +48,10 @@ public interface AdminQueryClient extends QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> groupsQueryAll();
|
||||
QueryResultRecords groupsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> groupsQuery(String filter);
|
||||
QueryResultRecords groupsQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Org}s by using REST API general QueryHandler.
|
||||
|
@ -62,10 +62,10 @@ public interface AdminQueryClient extends QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> orgsQueryAll();
|
||||
QueryResultRecords orgsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> orgsQuery(String filter);
|
||||
QueryResultRecords orgsQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Right}s by using REST API general QueryHandler.
|
||||
|
@ -76,10 +76,10 @@ public interface AdminQueryClient extends QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> rightsQueryAll();
|
||||
QueryResultRecords rightsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> rightsQuery(String filter);
|
||||
QueryResultRecords rightsQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Role}s by using REST API general QueryHandler.
|
||||
|
@ -90,10 +90,10 @@ public interface AdminQueryClient extends QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> rolesQueryAll();
|
||||
QueryResultRecords rolesQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> rolesQuery(String filter);
|
||||
QueryResultRecords rolesQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link User}s by using REST API general QueryHandler.
|
||||
|
@ -104,10 +104,10 @@ public interface AdminQueryClient extends QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> strandedUsersQueryAll();
|
||||
QueryResultRecords strandedUsersQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> strandedUsersQuery(String filter);
|
||||
QueryResultRecords strandedUsersQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link User}s by using REST API general QueryHandler.
|
||||
|
@ -118,10 +118,10 @@ public interface AdminQueryClient extends QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> usersQueryAll();
|
||||
QueryResultRecords usersQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> usersQuery(String filter);
|
||||
QueryResultRecords usersQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Vdc}s by using REST API general QueryHandler.
|
||||
|
@ -132,8 +132,8 @@ public interface AdminQueryClient extends QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> vdcsQueryAll();
|
||||
QueryResultRecords vdcsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> vdcsQuery(String filter);
|
||||
QueryResultRecords vdcsQuery(String filter);
|
||||
}
|
||||
|
|
|
@ -67,13 +67,13 @@ public interface QueryClient {
|
|||
* @see #query(String, String)
|
||||
* @see #query(Integer, Integer, String, String, String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> queryAll(String type);
|
||||
QueryResultRecords queryAll(String type);
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> query(String type, String filter);
|
||||
QueryResultRecords query(String type, String filter);
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> query(Integer page, Integer pageSize, String format, String type, String filter);
|
||||
QueryResultRecords query(Integer page, Integer pageSize, String format, String type, String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Catalog}s by using REST API general QueryHandler.
|
||||
|
@ -84,13 +84,13 @@ public interface QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> catalogsQueryAll();
|
||||
QueryResultRecords catalogsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> catalogsQuery(String filter);
|
||||
QueryResultRecords catalogsQuery(String filter);
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> catalogsQuery(Integer page, Integer pageSize, String filter);
|
||||
QueryResultRecords catalogsQuery(Integer page, Integer pageSize, String filter);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -119,10 +119,10 @@ public interface QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> vAppTemplatesQueryAll();
|
||||
QueryResultRecords vAppTemplatesQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> vAppTemplatesQuery(String filter);
|
||||
QueryResultRecords vAppTemplatesQuery(String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link VApp}s by using REST API general QueryHandler.
|
||||
|
@ -133,27 +133,13 @@ public interface QueryClient {
|
|||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> vAppsQueryAll();
|
||||
QueryResultRecords vAppsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> vAppsQuery(String filter);
|
||||
QueryResultRecords vAppsQuery(String filter);
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> vAppsQuery(Integer page, Integer pageSize, String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Vm}s by using REST API general QueryHandler.
|
||||
*
|
||||
* <pre>
|
||||
* GET /vms/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords<QueryResultRecordType> vmsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords<QueryResultRecordType> vmsQuery(String filter);
|
||||
QueryResultRecords vAppsQuery(Integer page, Integer pageSize, String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link VAppReference}s by using REST API general QueryHandler.
|
||||
|
@ -173,4 +159,18 @@ public interface QueryClient {
|
|||
/** @see #queryAll() */
|
||||
VAppReferences vAppReferencesQuery(Integer page, Integer pageSize, String filter);
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Vm}s by using REST API general QueryHandler.
|
||||
*
|
||||
* <pre>
|
||||
* GET /vms/query
|
||||
* </pre>
|
||||
*
|
||||
* @see #queryAll(String)
|
||||
*/
|
||||
QueryResultRecords vmsQueryAll();
|
||||
|
||||
/** @see #queryAll() */
|
||||
QueryResultRecords vmsQuery(String filter);
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class AdminQueryClientExpectTest extends BaseVCloudDirectorRestClientExpe
|
|||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
|
||||
|
||||
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
|
||||
QueryResultRecords expected = QueryResultRecords.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=records"))
|
||||
.type("application/vnd.vmware.vcloud.query.records+xml")
|
||||
.name("group")
|
||||
|
@ -114,7 +114,7 @@ public class AdminQueryClientExpectTest extends BaseVCloudDirectorRestClientExpe
|
|||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
|
||||
|
||||
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
|
||||
QueryResultRecords expected = QueryResultRecords.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=records"))
|
||||
.type("application/vnd.vmware.vcloud.query.records+xml")
|
||||
.name("role")
|
||||
|
|
|
@ -55,7 +55,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /admin/groups/query")
|
||||
public void testQueryAllGroups() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.groupsQueryAll();
|
||||
QueryResultRecords resultRecords = queryClient.groupsQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
|
@ -65,7 +65,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /admin/orgs/query")
|
||||
public void testQueryAllOrgs() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.orgsQueryAll();
|
||||
QueryResultRecords resultRecords = queryClient.orgsQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
|
@ -75,7 +75,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /admin/rights/query")
|
||||
public void testQueryAllRights() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.rightsQueryAll();
|
||||
QueryResultRecords resultRecords = queryClient.rightsQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
|
@ -86,7 +86,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /admin/roles/query")
|
||||
public void testQueryAllRoles() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.rolesQueryAll();
|
||||
QueryResultRecords resultRecords = queryClient.rolesQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
|
@ -97,7 +97,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /admin/strandedUsers/query")
|
||||
public void testQueryAllStrandedUsers() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.strandedUsersQueryAll();
|
||||
QueryResultRecords resultRecords = queryClient.strandedUsersQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
|
@ -108,7 +108,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /admin/users/query")
|
||||
public void testQueryAllUsers() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.usersQueryAll();
|
||||
QueryResultRecords resultRecords = queryClient.usersQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
|
@ -119,7 +119,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /admin/vdcs/query")
|
||||
public void testQueryAllVdc() {
|
||||
// TODO Ensure there will be at least one record, for asserting result
|
||||
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.vdcsQueryAll();
|
||||
QueryResultRecords resultRecords = queryClient.vdcsQueryAll();
|
||||
|
||||
for (QueryResultRecordType record : resultRecords.getRecords()) {
|
||||
Checks.checkQueryResultRecord(record);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
|
||||
|
||||
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
|
||||
QueryResultRecords expected = QueryResultRecords.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=records"))
|
||||
.type("application/vnd.vmware.vcloud.query.records+xml")
|
||||
.name("catalog")
|
||||
|
|
|
@ -113,7 +113,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
@Test(testName = "GET /catalogs/query")
|
||||
public void testQueryAllCatalogs() {
|
||||
QueryResultRecords<?> catalogRecords = queryClient.catalogsQueryAll();
|
||||
QueryResultRecords catalogRecords = queryClient.catalogsQueryAll();
|
||||
assertFalse(catalogRecords.getRecords().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogRecord", "QueryResultRecords"));
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
@Test(testName = "GET /vAppTemplates/query")
|
||||
public void testQueryAllVAppTemplates() {
|
||||
QueryResultRecords<?> queryResult = queryClient.vAppTemplatesQueryAll();
|
||||
QueryResultRecords queryResult = queryClient.vAppTemplatesQueryAll();
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class);
|
||||
|
@ -135,7 +135,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
@Test(testName = "GET /vAppTemplates/query?filter)")
|
||||
public void testQueryVAppTemplatesWithFilter() {
|
||||
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
|
||||
QueryResultRecords<?> queryResult = queryClient.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName()));
|
||||
QueryResultRecords queryResult = queryClient.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName()));
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class);
|
||||
|
@ -146,7 +146,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
public void testQueryAllVApps() {
|
||||
vApp = instantiateVApp();
|
||||
|
||||
QueryResultRecords<?> queryResult = queryClient.vAppsQueryAll();
|
||||
QueryResultRecords queryResult = queryClient.vAppsQueryAll();
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class);
|
||||
|
@ -155,7 +155,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
@Test(testName = "GET /vApps/query?filter", dependsOnMethods = { "testQueryAllVApps" } )
|
||||
public void testQueryVAppsWithFilter() {
|
||||
QueryResultRecords<?> queryResult = queryClient.vAppsQuery(String.format("name==%s", vApp.getName()));
|
||||
QueryResultRecords queryResult = queryClient.vAppsQuery(String.format("name==%s", vApp.getName()));
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class);
|
||||
|
@ -179,7 +179,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Set<URI> vmHrefs = toHrefs(vms);
|
||||
|
||||
// Method under test: do the query
|
||||
QueryResultRecords<?> queryResult = queryClient.vmsQueryAll();
|
||||
QueryResultRecords queryResult = queryClient.vmsQueryAll();
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
|
||||
|
@ -191,21 +191,21 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
List<Vm> vms = vApp.getChildren().getVms();
|
||||
Set<URI> vmHrefs = toHrefs(vms);
|
||||
|
||||
QueryResultRecords<?> queryResult = queryClient.vmsQuery(String.format("containerName==%s", vApp.getName()));
|
||||
QueryResultRecords queryResult = queryClient.vmsQuery(String.format("containerName==%s", vApp.getName()));
|
||||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
|
||||
assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp "+vApp.getName()+" ("+vmHrefs+"); but only has "+hrefs);
|
||||
}
|
||||
|
||||
private static void assertRecordTypes(QueryResultRecords<?> queryResult, Collection<String> validTypes, Class<?> validClazz) {
|
||||
private static void assertRecordTypes(QueryResultRecords queryResult, Collection<String> validTypes, Class validClazz) {
|
||||
for (QueryResultRecordType record : queryResult.getRecords()) {
|
||||
assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, "+record.getType()+"; valid types are "+validTypes);
|
||||
assertEquals(record.getClass(), validClazz, "invalid type for query result record, "+record.getClass()+"; expected "+validClazz);
|
||||
}
|
||||
}
|
||||
|
||||
private Set<URI> toHrefs(QueryResultRecords<?> queryResult) {
|
||||
private Set<URI> toHrefs(QueryResultRecords queryResult) {
|
||||
Set<URI> hrefs = new LinkedHashSet<URI>();
|
||||
for (QueryResultRecordType record : queryResult.getRecords()) {
|
||||
hrefs.add(record.getHref());
|
||||
|
|
|
@ -375,7 +375,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
@Test(testName = "POST /vApp/{id}/action/relocate", dependsOnMethods = { "testGetVApp" })
|
||||
public void testRelocate() {
|
||||
// Relocate to the last of the available datastores
|
||||
QueryResultRecords<?> records = context.getApi().getQueryClient().queryAll("datastore");
|
||||
QueryResultRecords records = context.getApi().getQueryClient().queryAll("datastore");
|
||||
QueryResultRecordType datastore = Iterables.getLast(records.getRecords());
|
||||
RelocateParams params = RelocateParams.builder().datastore(Reference.builder().href(datastore.getHref()).build()).build();
|
||||
|
||||
|
|
Loading…
Reference in New Issue