@Test public void shouldNotDeleteFromDbIfNotRegisteredStudentsToBeCommitted() throws Exception { context.put(IUnitOfWork.INSERT, Collections.singletonList(student1)); context.put(IUnitOfWork.MODIFY, Collections.singletonList(student1)); studentRepository.commit(); verify(studentDatabase, never()).delete(student1); }
@Override public void commit() { if (context == null || context.size() == 0) { return; } LOGGER.info("Commit started"); if (context.containsKey(IUnitOfWork.INSERT)) { commitInsert(); } if (context.containsKey(IUnitOfWork.MODIFY)) { commitModify(); } if (context.containsKey(IUnitOfWork.DELETE)) { commitDelete(); } LOGGER.info("Commit finished."); }
StudentRepository implements IUnitOfWork<Student> { @Override public void commit() { if (context == null || context.size() == 0) { return; } LOGGER.info("Commit started"); if (context.containsKey(IUnitOfWork.INSERT)) { commitInsert(); } if (context.containsKey(IUnitOfWork.MODIFY)) { commitModify(); } if (context.containsKey(IUnitOfWork.DELETE)) { commitDelete(); } LOGGER.info("Commit finished."); } }
StudentRepository implements IUnitOfWork<Student> { @Override public void commit() { if (context == null || context.size() == 0) { return; } LOGGER.info("Commit started"); if (context.containsKey(IUnitOfWork.INSERT)) { commitInsert(); } if (context.containsKey(IUnitOfWork.MODIFY)) { commitModify(); } if (context.containsKey(IUnitOfWork.DELETE)) { commitDelete(); } LOGGER.info("Commit finished."); } StudentRepository(Map<String, List<Student>> context, StudentDatabase studentDatabase); }
StudentRepository implements IUnitOfWork<Student> { @Override public void commit() { if (context == null || context.size() == 0) { return; } LOGGER.info("Commit started"); if (context.containsKey(IUnitOfWork.INSERT)) { commitInsert(); } if (context.containsKey(IUnitOfWork.MODIFY)) { commitModify(); } if (context.containsKey(IUnitOfWork.DELETE)) { commitDelete(); } LOGGER.info("Commit finished."); } StudentRepository(Map<String, List<Student>> context, StudentDatabase studentDatabase); @Override void registerNew(Student student); @Override void registerModified(Student student); @Override void registerDeleted(Student student); @Override void commit(); }
StudentRepository implements IUnitOfWork<Student> { @Override public void commit() { if (context == null || context.size() == 0) { return; } LOGGER.info("Commit started"); if (context.containsKey(IUnitOfWork.INSERT)) { commitInsert(); } if (context.containsKey(IUnitOfWork.MODIFY)) { commitModify(); } if (context.containsKey(IUnitOfWork.DELETE)) { commitDelete(); } LOGGER.info("Commit finished."); } StudentRepository(Map<String, List<Student>> context, StudentDatabase studentDatabase); @Override void registerNew(Student student); @Override void registerModified(Student student); @Override void registerDeleted(Student student); @Override void commit();  }