Example usage for org.springframework.data.mongodb.core MongoOperations find

List of usage examples for org.springframework.data.mongodb.core MongoOperations find

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core MongoOperations find.

Prototype

<T> List<T> find(Query query, Class<T> entityClass, String collectionName);

Source Link

Document

Map the results of an ad-hoc query on the specified collection to a List of the specified type.

Usage

From source file:com.comcast.video.dawg.service.house.MongoParkServiceTest.java

@SuppressWarnings("unchecked")
@Test/*from   www. j  av  a2 s.c om*/
public void testFindAll() {
    MongoParkService service = new MongoParkService();
    MongoOperations operations = EasyMock.createMock(MongoOperations.class);
    EasyMock.expect(operations.find((Query) EasyMock.anyObject(), (Class) EasyMock.anyObject(),
            (String) EasyMock.anyObject())).andReturn(null);
    EasyMock.replay(operations);
    ReflectionTestUtils.setField(service, "template", operations);
    Assert.assertNotNull(service.findAll());

}

From source file:com.comcast.video.dawg.service.house.MongoParkServiceTest.java

@SuppressWarnings("unchecked")
@Test/*  w  ww .  j a  va2 s . c  om*/
public void testFindAllWithPageable() {
    MongoParkService service = new MongoParkService();
    MongoOperations operations = EasyMock.createMock(MongoOperations.class);
    EasyMock.expect(operations.find((Query) EasyMock.anyObject(), (Class) EasyMock.anyObject(),
            (String) EasyMock.anyObject())).andReturn(null).anyTimes();
    EasyMock.replay(operations);
    ReflectionTestUtils.setField(service, "template", operations);
    Assert.assertNotNull(service.findAll(null));
    Assert.assertNotNull(service.findAll(new PageRequest(0, 1)));

}

From source file:com.comcast.video.dawg.service.house.MongoParkServiceTest.java

@SuppressWarnings("unchecked")
@Test/*from   w  ww  .  j av a2  s.  c  o  m*/
public void testFindByKeys() {
    MongoParkService service = new MongoParkService();
    MongoOperations operations = EasyMock.createMock(MongoOperations.class);
    EasyMock.expect(operations.find((Query) EasyMock.anyObject(), (Class) EasyMock.anyObject(),
            (String) EasyMock.anyObject())).andReturn(null);
    EasyMock.replay(operations);
    ReflectionTestUtils.setField(service, "template", operations);
    String[] keys = new String[1];
    keys[0] = "1";
    Assert.assertNotNull(service.findByKeys(keys));

}

From source file:com.comcast.video.dawg.service.house.MongoParkServiceTest.java

@SuppressWarnings("unchecked")
@Test//ww  w . j a  v a  2  s .c om
public void testFindByKeysWithPageable() {
    MongoParkService service = new MongoParkService();
    MongoOperations operations = EasyMock.createMock(MongoOperations.class);
    EasyMock.expect(operations.find((Query) EasyMock.anyObject(), (Class) EasyMock.anyObject(),
            (String) EasyMock.anyObject())).andReturn(null).anyTimes();
    EasyMock.replay(operations);
    ReflectionTestUtils.setField(service, "template", operations);
    String[] keys = new String[1];
    keys[0] = "1";
    Assert.assertNotNull(service.findByKeys(keys, null));
    Assert.assertNotNull(service.findByKeys(keys, new PageRequest(0, 1)));
}

From source file:com.comcast.video.dawg.service.house.MongoHouseServiceTest.java

@SuppressWarnings("unchecked")
@Test//ww  w  .  ja v a2 s .  co  m
public void testGetStbsByQuery() {
    MongoHouseService service = new MongoHouseService();
    MongoOperations operations = EasyMock.createMock(MongoOperations.class);
    EasyMock.expect(operations.find((Query) EasyMock.anyObject(), (Class) EasyMock.anyObject(),
            (String) EasyMock.anyObject())).andReturn(null);
    EasyMock.replay(operations);
    ReflectionTestUtils.setField(service, "template", operations);

    String query = "";
    Assert.assertNotNull(service.getStbsByQuery(query), "Got Null ");
}

From source file:com.comcast.video.dawg.service.house.MongoHouseServiceTest.java

@SuppressWarnings("unchecked")
@Test//from   ww w.  jav a  2s.  c  om
public void testGetStbsByKey() {
    MongoHouseService service = new MongoHouseService();
    MongoOperations operations = EasyMock.createMock(MongoOperations.class);
    EasyMock.expect(operations.find((Query) EasyMock.anyObject(), (Class) EasyMock.anyObject(),
            (String) EasyMock.anyObject())).andReturn(null);

    EasyMock.replay(operations);
    ReflectionTestUtils.setField(service, "template", operations);

    String[] id = new String[1];
    id[0] = "a";
    Assert.assertNotNull(service.getStbsByKey(id), "Got Null");
}

From source file:com.comcast.video.dawg.service.house.MongoHouseServiceTest.java

@SuppressWarnings("unchecked")
@Test//from w  w  w. j a  v a2  s  .c  o  m
public void testGetStbsById() {
    MongoHouseService service = new MongoHouseService();
    MongoOperations operations = EasyMock.createMock(MongoOperations.class);
    List<Object> obj = new ArrayList<Object>();
    EasyMock.expect(operations.find(EasyMock.anyObject(Query.class), EasyMock.anyObject(Class.class),
            EasyMock.anyObject(String.class))).andReturn(obj);
    EasyMock.replay(operations);
    ReflectionTestUtils.setField(service, "template", operations);

    String[] id = new String[1];
    id[0] = "";
    Assert.assertNotNull(service.getStbsById(id), "Got Null");
}

From source file:com.comcast.video.dawg.service.house.MongoHouseServiceTest.java

@SuppressWarnings("unchecked")
@Test/*from w  w  w.ja  v  a  2  s.  co  m*/
public void testGetAll() {

    MongoHouseService service = new MongoHouseService();
    MongoOperations op = EasyMock.createMock(MongoOperations.class);
    List<PersistableDevice> list = new ArrayList<PersistableDevice>();
    list.add(new PersistableDevice());
    EasyMock.expect(
            op.find((Query) EasyMock.anyObject(), (Class) EasyMock.anyObject(), (String) EasyMock.anyObject()))
            .andReturn(list);
    EasyMock.replay(op);
    ReflectionTestUtils.setField(service, "template", op);
    Assert.assertNotNull(service.getAll());
}