Updated .json file to match server response for cloudstack 2.2.12 and tests

This commit is contained in:
andreisavu 2011-12-02 12:27:52 +02:00
parent da96b57c37
commit a6c43a5c4c
4 changed files with 16 additions and 11 deletions

View File

@ -34,6 +34,7 @@ import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -56,6 +57,7 @@ public interface AsyncJobAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listAsyncJobs")
@SelectJson("asyncjobs")
@ResponseParser(ParseAsyncJobsFromHttpResponse.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<AsyncJob<?>>> listAsyncJobs(ListAsyncJobsOptions... options);

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.cloudstack.features;
import static org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@ -28,18 +29,20 @@ import org.testng.annotations.Test;
/**
* Tests behavior of {@code AsyncJobClientLiveTest}
*
*
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "AsyncJobClientLiveTest")
public class AsyncJobClientLiveTest extends BaseCloudStackClientLiveTest {
// disabled as it takes too long
@Test(enabled = false)
@Test(enabled = true)
public void testListAsyncJobs() throws Exception {
Set<AsyncJob<?>> response = client.getAsyncJobClient().listAsyncJobs();
assert null != response;
long asyncJobCount = response.size();
assertTrue(asyncJobCount >= 0);
for (AsyncJob<?> asyncJob : response) {
assert asyncJob.getCmd() != null : asyncJob;
assert asyncJob.getUserId() >= 0 : asyncJob;
@ -57,12 +60,11 @@ public class AsyncJobClientLiveTest extends BaseCloudStackClientLiveTest {
assert query.getStatus().code() >= 0 : query;
assert query.getResultCode().code() >= 0 : query;
assert query.getProgress() >= 0 : query;
if (query.getResultCode().code() == 0) {
if (query.getResult() != null)// null is ok for result of success =
// true
// ensure we parsed properly
assert (query.getResult().getClass().getPackage().equals(AsyncJob.class.getPackage())) : query;
} else if (query.getResultCode().code() > 400) {
if (query.getResultCode() == ResultCode.SUCCESS) {
if (query.getResult() != null) {
assertEquals(query.getResult().getClass().getPackage(), AsyncJob.class.getPackage());
}
} else if (query.getResultCode() == ResultCode.FAIL) {
assert query.getResult() == null : query;
assert query.getError() != null : query;
} else {

View File

@ -39,7 +39,7 @@ import com.google.inject.Injector;
@Test(groups = "unit")
public class ParseAsyncJobsFromHttpResponseTest {
Injector i = Guice.createInjector(new GsonModule() {
Injector injector = Guice.createInjector(new GsonModule() {
@Override
protected void configure() {
@ -52,7 +52,7 @@ public class ParseAsyncJobsFromHttpResponseTest {
public void testCanParse() {
InputStream is = getClass().getResourceAsStream("/listasyncjobsresponse.json");
ParseAsyncJobsFromHttpResponse parser = i.getInstance(ParseAsyncJobsFromHttpResponse.class);
ParseAsyncJobsFromHttpResponse parser = injector.getInstance(ParseAsyncJobsFromHttpResponse.class);
Set<AsyncJob<?>> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
assertEquals(response.size(), 77);

View File

@ -1,5 +1,6 @@
{
"listasyncjobsresponse": {
"count": 77,
"asyncjobs": [{
"jobid": 1084,
"accountid": 3,