use of org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturn in project ovirt-engine by oVirt.
the class MarshallingTestCase method testGetIsoListWithImage.
@SuppressWarnings("unchecked")
@Test
public void testGetIsoListWithImage() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"8d38c4c9-3fdb-4663-993a-dc65488875bb\", \"result\": [\"Fedora-Live-Desktop-x86_64-19-1.iso\"]}";
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("isolist").withResponseType(Object[].class);
// Then
FileStatsReturn isoList = new FileStatsReturn(map);
assertEquals("Done", isoList.getStatus().message);
assertEquals(0, isoList.getStatus().code);
assertEquals(1, isoList.getFileStats().size());
assertEquals("Fedora-Live-Desktop-x86_64-19-1.iso", isoList.getFileStats().keySet().iterator().next());
}
use of org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturn in project ovirt-engine by oVirt.
the class MarshallingTestCase method testGetIsoListWithoutIsos.
@SuppressWarnings("unchecked")
@Test
public void testGetIsoListWithoutIsos() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"c1796b67-8932-4e90-a6f9-aa68266493f8\", \"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("iso_list").withResponseType(Object[].class);
// Then
FileStatsReturn isoList = new FileStatsReturn(map);
assertEquals("Done", isoList.getStatus().message);
assertEquals(0, isoList.getStatus().code);
assertEquals(0, isoList.getFileStats().size());
}
use of org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturn in project ovirt-engine by oVirt.
the class JsonRpcIIrsServer method getFileStats.
@Override
public FileStatsReturn getFileStats(String sdUUID, String pattern, boolean caseSensitive) {
JsonRpcRequest request = new RequestBuilder("StorageDomain.getFileStats").withParameter("storagedomainID", sdUUID).withParameter("pattern", pattern).withParameter("caseSensitive", caseSensitive).build();
Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("fileStats");
return new FileStatsReturn(response);
}
Aggregations