use of org.ovirt.engine.core.vdsbroker.vdsbroker.VMListReturn in project ovirt-engine by oVirt.
the class JsonRpcVdsServer method list.
@Override
public VMListReturn list() {
JsonRpcRequest request = new RequestBuilder("Host.getVMList").withOptionalParameterAsList("vmList", new ArrayList<>(Arrays.asList(new String[] {}))).withParameter("onlyUUID", false).build();
Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("vmList").withResponseType(Object[].class);
return new VMListReturn(response);
}
use of org.ovirt.engine.core.vdsbroker.vdsbroker.VMListReturn in project ovirt-engine by oVirt.
the class JsonRpcVdsServer method fullList.
@Override
public VMListReturn fullList(List<String> vmIds) {
JsonRpcRequest request = new RequestBuilder("Host.getVMFullList").withOptionalParameterAsList("vmList", vmIds).build();
Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("vmList").withResponseType(Object[].class);
return new VMListReturn(response);
}
use of org.ovirt.engine.core.vdsbroker.vdsbroker.VMListReturn in project ovirt-engine by oVirt.
the class MarshallingTestCase method testGetVMList.
@SuppressWarnings("unchecked")
@Test
public void testGetVMList() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"e32621e5-753f-45b8-b071-2eb929408efd\", \"result\": [{\"status\": \"Up\", \"vmId\": \"dd4d61c3-5128-4c26-ae71-0dbe5081ea93\"}]}";
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);
// Then
VMListReturn vmList = new VMListReturn(map);
assertEquals("Done", vmList.status.message);
assertEquals(0, vmList.status.code);
assertEquals(1, vmList.vmList.length);
assertEquals("dd4d61c3-5128-4c26-ae71-0dbe5081ea93", vmList.vmList[0].get("vmId"));
assertEquals("Up", vmList.vmList[0].get("status"));
}
use of org.ovirt.engine.core.vdsbroker.vdsbroker.VMListReturn in project ovirt-engine by oVirt.
the class MarshallingTestCase method testEmptyListVDS.
@SuppressWarnings("unchecked")
@Test
public void testEmptyListVDS() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"3a0a4c64-1b67-4b48-bc31-e4e0cb7538b1\", \"result\": []}";
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);
// Then
VMListReturn vmList = new VMListReturn(map);
Status status = vmList.status;
assertEquals("Done", status.message);
assertEquals(0, status.code);
assertEquals(0, vmList.vmList.length);
}
use of org.ovirt.engine.core.vdsbroker.vdsbroker.VMListReturn in project ovirt-engine by oVirt.
the class MarshallingTestCase method testGetVMListIdsOnly.
@SuppressWarnings("unchecked")
@Test
public void testGetVMListIdsOnly() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"e9968b53-7450-4059-83e6-d3569f7024ec\", \"result\": [\"1397d80b-1c48-4d4a-acf9-ebd669bf3b25\"]}";
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);
// Then
VMListReturn vmList = new VMListReturn(map);
assertEquals("Done", vmList.status.message);
assertEquals(0, vmList.status.code);
assertEquals(1, vmList.vmList.length);
assertEquals("1397d80b-1c48-4d4a-acf9-ebd669bf3b25", vmList.vmList[0].get("vmId"));
}
Aggregations