mirror of https://github.com/apache/jclouds.git
Issue 695: Added ComputePoolPerformanceStatistics+service call+tests
This commit is contained in:
parent
c5d859ce26
commit
eebe515511
|
@ -0,0 +1,95 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.internal;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A Resource with no name.
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class AnonymousResource extends BaseResource<AnonymousResource> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromBaseResource(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseResource.Builder<AnonymousResource> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AnonymousResource build() {
|
||||
return new AnonymousResource(href, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<AnonymousResource> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> in) {
|
||||
return Builder.class.cast(super.fromAttributes(in));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private AnonymousResource(URI href, String type) {
|
||||
super(href, type);
|
||||
}
|
||||
|
||||
protected AnonymousResource() {
|
||||
//For JAXB
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.resource;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="ComputePoolPerformanceStatistic">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class ComputePoolPerformanceStatistic {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromComputePoolPerformanceStatistic(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private AnonymousResource cpu;
|
||||
private AnonymousResource memory;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistic#getCpu
|
||||
*/
|
||||
public Builder cpu(AnonymousResource cpu) {
|
||||
this.cpu = cpu;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistic#getMemory
|
||||
*/
|
||||
public Builder memory(AnonymousResource memory) {
|
||||
this.memory = memory;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ComputePoolPerformanceStatistic build() {
|
||||
return new ComputePoolPerformanceStatistic(cpu, memory);
|
||||
}
|
||||
|
||||
public Builder fromComputePoolPerformanceStatistic(ComputePoolPerformanceStatistic in) {
|
||||
return cpu(in.getCpu()).memory(in.getMemory());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Cpu", required = false)
|
||||
private AnonymousResource cpu;
|
||||
|
||||
@XmlElement(name = "Memory", required = false)
|
||||
private AnonymousResource memory;
|
||||
|
||||
private ComputePoolPerformanceStatistic(@Nullable AnonymousResource cpu, @Nullable AnonymousResource memory) {
|
||||
this.cpu = cpu;
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
private ComputePoolPerformanceStatistic() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public AnonymousResource getCpu() {
|
||||
return cpu;
|
||||
}
|
||||
|
||||
public AnonymousResource getMemory() {
|
||||
return memory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "cpu="+cpu+", memory="+memory;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.resource;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="ComputePoolPerformanceStatistics">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "ComputePoolPerformanceStatistics")
|
||||
public class ComputePoolPerformanceStatistics extends Resource<ComputePoolPerformanceStatistics> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromComputePoolResourceSummary(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Resource.Builder<ComputePoolPerformanceStatistics> {
|
||||
ComputePoolPerformanceStatistic hourly;
|
||||
ComputePoolPerformanceStatistic daily;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistics#getHourly
|
||||
*/
|
||||
public Builder hourly(ComputePoolPerformanceStatistic hourly) {
|
||||
this.hourly = hourly;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistics#getDaily
|
||||
*/
|
||||
public Builder daily(ComputePoolPerformanceStatistic daily) {
|
||||
this.daily = daily;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComputePoolPerformanceStatistics build() {
|
||||
return new ComputePoolPerformanceStatistics(href, type, name, links, actions, hourly, daily);
|
||||
}
|
||||
|
||||
public Builder fromComputePoolResourceSummary(ComputePoolPerformanceStatistics in) {
|
||||
return fromResource(in).hourly(in.getHourly()).daily(in.getDaily());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<ComputePoolPerformanceStatistics> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<ComputePoolPerformanceStatistics> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "Hourly", required = false)
|
||||
ComputePoolPerformanceStatistic hourly;
|
||||
|
||||
@XmlElement(name = "Daily", required = false)
|
||||
ComputePoolPerformanceStatistic daily;
|
||||
|
||||
private ComputePoolPerformanceStatistics(URI href, String type, String name, Set<Link> links, Set<Action> actions,
|
||||
@Nullable ComputePoolPerformanceStatistic hourly, @Nullable ComputePoolPerformanceStatistic daily) {
|
||||
super(href, type, name, links, actions);
|
||||
this.hourly = hourly;
|
||||
this.daily = daily;
|
||||
}
|
||||
|
||||
private ComputePoolPerformanceStatistics() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public ComputePoolPerformanceStatistic getHourly() {
|
||||
return hourly;
|
||||
}
|
||||
|
||||
public ComputePoolPerformanceStatistic getDaily() {
|
||||
return daily;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ComputePoolPerformanceStatistics that = (ComputePoolPerformanceStatistics) o;
|
||||
|
||||
if (daily != null ? !daily.equals(that.daily) : that.daily != null)
|
||||
return false;
|
||||
if (hourly != null ? !hourly.equals(that.hourly) : that.hourly != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (hourly != null ? hourly.hashCode() : 0);
|
||||
result = 31 * result + (daily != null ? daily.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", hourly="+hourly+", daily="+daily;
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.rest.annotations.*;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistics;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummary;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummaryList;
|
||||
|
@ -110,4 +111,13 @@ public interface ResourceAsyncClient {
|
|||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ComputePoolStorageUsageDetail> getComputePoolStorageUsage(@EndpointParam URI uri);
|
||||
|
||||
/**
|
||||
* @see ResourceClient#getComputePoolPerformanceStatistics
|
||||
*/
|
||||
@GET
|
||||
@Consumes("application/vnd.tmrk.cloud.computePoolPerformanceStatistics")
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ComputePoolPerformanceStatistics> getComputePoolPerformanceStatistics(@EndpointParam URI uri);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.features;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistics;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsage;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummary;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummaryList;
|
||||
|
@ -142,4 +143,13 @@ public interface ResourceClient {
|
|||
* @return the compute pool storage usage detail
|
||||
*/
|
||||
ComputePoolStorageUsageDetail getComputePoolStorageUsage(URI uri);
|
||||
|
||||
/**
|
||||
* The Get Resources Performance Statistics call returns references to obtain
|
||||
* the individual performance statistics reports in a compute pool.
|
||||
* @param uri the uri of the call based upon the compute pool
|
||||
* e.g. /cloudapi/ecloud/computepools/{id}/performanceStatistics
|
||||
* @return
|
||||
*/
|
||||
ComputePoolPerformanceStatistics getComputePoolPerformanceStatistics(URI uri);
|
||||
}
|
||||
|
|
|
@ -143,6 +143,22 @@ public class ResourceAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncCl
|
|||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
public void testGetComputePoolPerformanceStatistics() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolPerformanceStatistics", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/computepools/89/performancestatistics"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/computepools/89/performancestatistics HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest,
|
||||
"Accept: application/vnd.tmrk.cloud.computePoolPerformanceStatistics\nx-tmrk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<ResourceAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<ResourceAsyncClient>>() {
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.xml;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.BaseRestClientTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistics;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.ResourceAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests behavior of JAXB parsing for ComputePoolPerformanceStatistics
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ComputePoolPerformanceStatisticsJAXBParsingTest")
|
||||
public class ComputePoolPerformanceStatisticsJAXBParsingTest extends BaseRestClientTest {
|
||||
|
||||
@BeforeClass
|
||||
void setupFactory() {
|
||||
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||
"credentialFoo", String.class, Integer.class,
|
||||
ImmutableSet.<Module>of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Named("exception")
|
||||
Set<String> exception() {
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
injector = createContextBuilder(contextSpec).buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
crypto = injector.getInstance(Crypto.class);
|
||||
}
|
||||
|
||||
public void testParseWithJAXB() throws Exception {
|
||||
|
||||
Method method = ResourceAsyncClient.class.getMethod("getComputePoolPerformanceStatistics", URI.class);
|
||||
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, ComputePoolPerformanceStatistics> parser = (Function<HttpResponse, ComputePoolPerformanceStatistics>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/computePoolPerformanceStatistics.xml");
|
||||
ComputePoolPerformanceStatistics stats = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
assertLinks(stats.getLinks());
|
||||
assertEquals(stats.getHourly().getCpu(), createResource("cpu", "hourly"));
|
||||
assertEquals(stats.getDaily().getCpu(), createResource("cpu", "daily"));
|
||||
assertEquals(stats.getHourly().getMemory(), createResource("memory", "hourly"));
|
||||
assertEquals(stats.getDaily().getMemory(), createResource("memory", "daily"));
|
||||
}
|
||||
|
||||
private AnonymousResource createResource(String type, String period) {
|
||||
return AnonymousResource.builder().href(URI.create("/cloudapi/ecloud/computepools/89/usage/"+type+"/performancestatistics/"+period))
|
||||
.type("application/vnd.tmrk.cloud.performanceStatistics")
|
||||
.build();
|
||||
}
|
||||
|
||||
private void assertLinks(Set<Link> links) {
|
||||
assertEquals(links.size(),1);
|
||||
Link link = Iterables.get(links, 0);
|
||||
assertEquals(link.getName(),"Default Compute Pool");
|
||||
assertEquals(link.getRelationship(), Link.Relationship.UP);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<ComputePoolPerformanceStatistics
|
||||
href="/cloudapi/ecloud/computepools/89/performancestatistics"
|
||||
type="application/vnd.tmrk.cloud.computePoolPerformanceStatistics"
|
||||
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/computepools/89"
|
||||
name="Default Compute Pool"
|
||||
type="application/vnd.tmrk.cloud.computePool" rel="up"/>
|
||||
</Links>
|
||||
<Hourly>
|
||||
<Cpu href="/cloudapi/ecloud/computepools/89/usage/cpu/performancestatistics/hourly"
|
||||
type="application/vnd.tmrk.cloud.performanceStatistics"/>
|
||||
<Memory href="/cloudapi/ecloud/computepools/89/usage/memory/performancestatistics/hourly"
|
||||
type="application/vnd.tmrk.cloud.performanceStatistics"/>
|
||||
</Hourly>
|
||||
<Daily>
|
||||
<Cpu href="/cloudapi/ecloud/computepools/89/usage/cpu/performancestatistics/daily"
|
||||
type="application/vnd.tmrk.cloud.performanceStatistics"/>
|
||||
<Memory href="/cloudapi/ecloud/computepools/89/usage/memory/performancestatistics/daily"
|
||||
type="application/vnd.tmrk.cloud.performanceStatistics"/>
|
||||
</Daily>
|
||||
</ComputePoolPerformanceStatistics>
|
Loading…
Reference in New Issue