@Test public void shouldNotWriteToDbIfNothingToCommit() throws Exception { StudentRepository studentRepository = new StudentRepository(new HashMap<>(), studentDatabase); studentRepository.commit(); verifyZeroInteractions(studentDatabase); }
@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();  }