@SuppressWarnings("unchecked") @Test public void testGetReserverWithNoDeviceAssoicatedWithToken() { List<PersistableDevice> devices = new ArrayList<PersistableDevice>(); MongoTemplate mockMongoTemplate = EasyMock.createMock(MongoTemplate.class); DawgPoundMongoService dawgPoundService = new DawgPoundMongoService(); ReflectionTestUtils.setField(dawgPoundService, "mongoTemplate", mockMongoTemplate); EasyMock.expect(mockMongoTemplate.find((Query)EasyMock.anyObject(), (Class<PersistableDevice>) EasyMock.anyObject(), (String)EasyMock.anyObject())).andReturn(devices); EasyMock.replay(mockMongoTemplate); Map<String,Object>[] reservers = dawgPoundService.getByReserver(TestConstants.TOKEN); Assert.assertEquals(reservers.length, 0); EasyMock.verify(mockMongoTemplate); }
@SuppressWarnings("unchecked") @Override public Map<String,Object>[] getByReserver(String token) { List<Map<String,Object>> list = new ArrayList<Map<String,Object>>(); Criteria c = new Criteria("reserver").is(token); Query q = new Query(c); Collection<? extends DawgDevice> col = mongoTemplate.find(q, PersistableDevice.class, COLLECTION_NAME); for(DawgDevice device : col) { list.add(device.getData()); } return list.toArray(new Map[list.size()]); }
DawgPoundMongoService implements IDawgPoundService { @SuppressWarnings("unchecked") @Override public Map<String,Object>[] getByReserver(String token) { List<Map<String,Object>> list = new ArrayList<Map<String,Object>>(); Criteria c = new Criteria("reserver").is(token); Query q = new Query(c); Collection<? extends DawgDevice> col = mongoTemplate.find(q, PersistableDevice.class, COLLECTION_NAME); for(DawgDevice device : col) { list.add(device.getData()); } return list.toArray(new Map[list.size()]); } }
DawgPoundMongoService implements IDawgPoundService { @SuppressWarnings("unchecked") @Override public Map<String,Object>[] getByReserver(String token) { List<Map<String,Object>> list = new ArrayList<Map<String,Object>>(); Criteria c = new Criteria("reserver").is(token); Query q = new Query(c); Collection<? extends DawgDevice> col = mongoTemplate.find(q, PersistableDevice.class, COLLECTION_NAME); for(DawgDevice device : col) { list.add(device.getData()); } return list.toArray(new Map[list.size()]); }  }
DawgPoundMongoService implements IDawgPoundService { @SuppressWarnings("unchecked") @Override public Map<String,Object>[] getByReserver(String token) { List<Map<String,Object>> list = new ArrayList<Map<String,Object>>(); Criteria c = new Criteria("reserver").is(token); Query q = new Query(c); Collection<? extends DawgDevice> col = mongoTemplate.find(q, PersistableDevice.class, COLLECTION_NAME); for(DawgDevice device : col) { list.add(device.getData()); } return list.toArray(new Map[list.size()]); }  @PostConstruct void init(); @Override synchronized String unreserve(String id); @Override synchronized boolean overrideReserve(String id, String token, long expiration); @SuppressWarnings("unchecked") @Override Map<String,Object>[] getByReserver(String token); @Override synchronized String reserve(String id, String token, long expiration); @Override PersistableDevice getById(String id); @Override Map<String, String> isReserved(String id); @SuppressWarnings("unchecked") Map<String,Object>[] list(); }
DawgPoundMongoService implements IDawgPoundService { @SuppressWarnings("unchecked") @Override public Map<String,Object>[] getByReserver(String token) { List<Map<String,Object>> list = new ArrayList<Map<String,Object>>(); Criteria c = new Criteria("reserver").is(token); Query q = new Query(c); Collection<? extends DawgDevice> col = mongoTemplate.find(q, PersistableDevice.class, COLLECTION_NAME); for(DawgDevice device : col) { list.add(device.getData()); } return list.toArray(new Map[list.size()]); }  @PostConstruct void init(); @Override synchronized String unreserve(String id); @Override synchronized boolean overrideReserve(String id, String token, long expiration); @SuppressWarnings("unchecked") @Override Map<String,Object>[] getByReserver(String token); @Override synchronized String reserve(String id, String token, long expiration); @Override PersistableDevice getById(String id); @Override Map<String, String> isReserved(String id); @SuppressWarnings("unchecked") Map<String,Object>[] list();  }