DawgPoundClient extends DawgClient implements IDawgPoundClient, DeviceProvider { @Override public Collection<MetaStb> getReservedDevices(String token) { List<MetaStb> devices = new ArrayList<>(); try { @SuppressWarnings("unchecked") Map<String, Object>[] maps = client.get("/reserved/token/"+token, Map[].class); for (Map<String,Object> map : maps) { devices.add(new MetaStb(map)); } } catch (HttpException e) { e.printStackTrace(); throw new HttpRuntimeException(e); } return devices; } DawgPoundClient();  DawgPoundClient(String baseURL); @Override Collection<MetaStb> getReservedDevices(String token); @Override void reserve(Reservation reservation); @SuppressWarnings("unchecked") @Override Reservation getReservation(String deviceId); @Override Collection<MetaStb> getDevices(String token); static final String DEFAULT_BASE_URL; }
@SuppressWarnings("unchecked") @Test(expectedExceptions=HttpRuntimeException.class) public void testGetReservedDevicesWithEmptyToken() throws HttpException { RestClient mockClient = EasyMock.createMock(RestClient.class); DawgPoundClient client = new DawgPoundClient(); client.setClient(mockClient); Map[] maps = new HashMap[1]; maps[0] = new HashMap<>(); EasyMock.expect(mockClient.get((String) EasyMock.anyObject(),(Class<Map[]>)EasyMock.anyObject())).andThrow(new HttpRuntimeException() ); EasyMock.replay(mockClient); String token=""; client.getReservedDevices(token); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testGetReservedDevices() throws HttpException { RestClient restClient = EasyMock.createMock(RestClient.class); Map<String,Object>[] maps = new HashMap[1]; Map<String,Object> map = new HashMap<String,Object>(); map.put("key", new Object()); maps[0] = map; EasyMock.expect(restClient.get((String)EasyMock.anyObject(), (Class) EasyMock.anyObject())).andReturn(maps); DawgPoundClient client = new DawgPoundClient(); client.setClient(restClient); EasyMock.replay(restClient); String token="abc"; Assert.assertNotNull( client.getReservedDevices(token)); }