List of usage examples for org.springframework.data.mongodb.core MongoOperations collectionExists
boolean collectionExists(String collectionName);
From source file:com.comcast.video.dawg.service.house.MongoHouseServiceTest.java
@SuppressWarnings("unchecked") @Test// w w w . ja v a2 s . co m public void testUpsertStb() { MongoHouseService service = new MongoHouseService(); MongoOperations operations = EasyMock.createMock(MongoOperations.class); EasyMock.expect(operations.collectionExists((Class) EasyMock.anyObject())).andReturn(false); EasyMock.expect(operations.createCollection((Class) EasyMock.anyObject())).andReturn(null); operations.save((PersistableDevice) EasyMock.anyObject(), (String) EasyMock.anyObject()); EasyMock.expectLastCall(); EasyMock.expect(operations.findById((Object) EasyMock.anyObject(), (Class) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(null); EasyMock.replay(operations); ReflectionTestUtils.setField(service, "template", operations); ParkService mockParkService = EasyMock.createMock(ParkService.class); EasyMock.expect(mockParkService.getModelById((String) EasyMock.anyObject())).andReturn(null); EasyMock.replay(mockParkService); ReflectionTestUtils.setField(service, "parkService", mockParkService); DawgDevice[] stb = new DawgDevice[1]; stb[0] = new PersistableDevice(); try { service.upsertStb(stb); } catch (Exception e) { Assert.fail(e.getMessage(), e); } }