use of org.ovirt.engine.core.vdsbroker.vdsbroker.VMListReturn in project ovirt-engine by oVirt.
the class MarshallingTestCase method testShortList.
@SuppressWarnings("unchecked")
@Test
public void testShortList() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"ae80f5c4-0f63-4c2e-aed6-5372f07a14c1\", \"result\": [\"e4a0fc02-c5ad-4b35-b2d0-5a4b6557c06b\"]}";
ObjectMapper mapper = new ObjectMapper();
JsonRpcResponse response = JsonRpcResponse.fromJsonNode(mapper.readTree(json));
Future<JsonRpcResponse> future = mock(Future.class);
when(future.get()).thenReturn(response);
JsonRpcClient client = mock(JsonRpcClient.class);
JsonRpcRequest request = mock(JsonRpcRequest.class);
when(client.call(request)).thenReturn(future);
// When
Map<String, Object> map = new FutureMap(client, request).withResponseKey("vmList").withResponseType(Object[].class).withSubTypeClazz(HashMap.class).withSubtypeKey("vmId");
// Then
VMListReturn vmList = new VMListReturn(map);
Status status = vmList.status;
assertEquals("Done", status.message);
assertEquals(0, status.code);
assertEquals(1, vmList.vmList.length);
}
use of org.ovirt.engine.core.vdsbroker.vdsbroker.VMListReturn in project ovirt-engine by oVirt.
the class JsonRpcVdsServer method getExternalVmList.
@Override
public VMListReturn getExternalVmList(String uri, String username, String password, List<String> vmsNames) {
RequestBuilder requestBuilder = new RequestBuilder("Host.getExternalVMs").withParameter("uri", uri).withParameter("username", username).withParameter("password", password).withOptionalParameterAsList("vm_names", vmsNames);
JsonRpcRequest request = requestBuilder.build();
Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("vmList").withResponseType(Object[].class);
return new VMListReturn(response);
}
Aggregations