@Test public void testInsert() { DBObject query = Mockito.mock(DBObject.class); DBObject docToPersist = ContainerDocumentHelper.buildDocumentToPersist(mockHolder, entity, generatorStrategy, naturalKeyExtractor); when(query.get("_id")).thenReturn(ID); when(mockHolder.getContainerDocument(ATTENDANCE)).thenReturn(createContainerDocAttendance()); when(mongoTemplate.getCollection(ATTENDANCE)).thenReturn(mockCollection); when(mockCollection.update(Mockito.any(DBObject.class), Mockito.eq(docToPersist), Mockito.eq(true), Mockito.eq(false), Mockito.eq(WriteConcern.SAFE))).thenReturn(writeResult); String result = testAccessor.insertContainerDoc(query, entity); assertTrue(result.equals(ID)); assertFalse("Wrong result returned by insert", result.equals("")); Mockito.verify(mockCollection, Mockito.times(1)).update(Mockito.any(DBObject.class), Mockito.eq(docToPersist), Mockito.eq(true), Mockito.eq(false), Mockito.eq(WriteConcern.SAFE)); }
public boolean insert(final List<Entity> entityList) { boolean result = true; for (Entity entity : entityList) { result &= !insert(entity).isEmpty(); } return result; }
ContainerDocumentAccessor { public boolean insert(final List<Entity> entityList) { boolean result = true; for (Entity entity : entityList) { result &= !insert(entity).isEmpty(); } return result; } }
ContainerDocumentAccessor { public boolean insert(final List<Entity> entityList) { boolean result = true; for (Entity entity : entityList) { result &= !insert(entity).isEmpty(); } return result; } ContainerDocumentAccessor(final UUIDGeneratorStrategy strategy, final INaturalKeyExtractor extractor,
                                     final MongoTemplate mongoTemplate, final SchemaRepository schemaRepo); }
ContainerDocumentAccessor { public boolean insert(final List<Entity> entityList) { boolean result = true; for (Entity entity : entityList) { result &= !insert(entity).isEmpty(); } return result; } ContainerDocumentAccessor(final UUIDGeneratorStrategy strategy, final INaturalKeyExtractor extractor,
                                     final MongoTemplate mongoTemplate, final SchemaRepository schemaRepo); boolean isContainerDocument(final String entity); boolean isContainerSubdoc(final String entity); boolean insert(final List<Entity> entityList); String insert(final Entity entity); boolean update(final String type, final String id, Map<String, Object> newValues, String collectionName); String update(final Entity entity); Entity findById(String collectionName, String id); List<Entity> findAll(String collectionName, Query query); boolean delete(final Entity entity); @SuppressWarnings("unchecked") boolean deleteContainerNonSubDocs(final Entity containerDoc); long count(String collectionName, Query query); boolean exists(String collectionName, String id); String getEmbeddedDocType(final String containerDocType); }
ContainerDocumentAccessor { public boolean insert(final List<Entity> entityList) { boolean result = true; for (Entity entity : entityList) { result &= !insert(entity).isEmpty(); } return result; } ContainerDocumentAccessor(final UUIDGeneratorStrategy strategy, final INaturalKeyExtractor extractor,
                                     final MongoTemplate mongoTemplate, final SchemaRepository schemaRepo); boolean isContainerDocument(final String entity); boolean isContainerSubdoc(final String entity); boolean insert(final List<Entity> entityList); String insert(final Entity entity); boolean update(final String type, final String id, Map<String, Object> newValues, String collectionName); String update(final Entity entity); Entity findById(String collectionName, String id); List<Entity> findAll(String collectionName, Query query); boolean delete(final Entity entity); @SuppressWarnings("unchecked") boolean deleteContainerNonSubDocs(final Entity containerDoc); long count(String collectionName, Query query); boolean exists(String collectionName, String id); String getEmbeddedDocType(final String containerDocType);  }