Search in sources :

Example 1 with FileStatsReturn

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());
}
Also used : JsonRpcResponse(org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse) JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) FileStatsReturn(org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturn) JsonRpcClient(org.ovirt.vdsm.jsonrpc.client.JsonRpcClient) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 2 with FileStatsReturn

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());
}
Also used : JsonRpcResponse(org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse) JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) FileStatsReturn(org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturn) JsonRpcClient(org.ovirt.vdsm.jsonrpc.client.JsonRpcClient) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 3 with FileStatsReturn

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);
}
Also used : JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder) FileStatsReturn(org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturn)

Aggregations

FileStatsReturn (org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturn)3 JsonRpcRequest (org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest)3 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2 Test (org.junit.Test)2 JsonRpcClient (org.ovirt.vdsm.jsonrpc.client.JsonRpcClient)2 JsonRpcResponse (org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse)2 RequestBuilder (org.ovirt.vdsm.jsonrpc.client.RequestBuilder)1