@Test public void saveAuditMessage_shouldNotSaveSuccessfulAudit() { AuditMessage auditMessage = new AuditMessage(); auditMessage.setSuccess(true); when(dao.saveItem((AuditMessage) any())).thenReturn(auditMessage); when(configurationService.getSyncConfiguration().getGeneral().isPersistSuccessAudit()).thenReturn(false); when(configurationService.getSyncConfiguration().getGeneral().isPersistFailureAudit()).thenReturn(false); AuditMessage fetched = auditService.saveAuditMessageDuringSync(auditMessage); Assert.assertNull(fetched); }
@Override public AuditMessage saveAuditMessageDuringSync(AuditMessage auditMessage) { boolean persistSuccessAudit = BooleanUtils.isTrue(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistSuccessAudit(); boolean persistFailureAudit = BooleanUtils.isFalse(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistFailureAudit(); if (persistFailureAudit || persistSuccessAudit) { if (auditMessage.getTimestamp() == null) { auditMessage.setTimestamp(new Timestamp(System.currentTimeMillis())); } return dao.saveItem(auditMessage); } return null; }
SyncAuditServiceImpl extends BaseOpenmrsService implements SyncAuditService { @Override public AuditMessage saveAuditMessageDuringSync(AuditMessage auditMessage) { boolean persistSuccessAudit = BooleanUtils.isTrue(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistSuccessAudit(); boolean persistFailureAudit = BooleanUtils.isFalse(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistFailureAudit(); if (persistFailureAudit || persistSuccessAudit) { if (auditMessage.getTimestamp() == null) { auditMessage.setTimestamp(new Timestamp(System.currentTimeMillis())); } return dao.saveItem(auditMessage); } return null; } }
SyncAuditServiceImpl extends BaseOpenmrsService implements SyncAuditService { @Override public AuditMessage saveAuditMessageDuringSync(AuditMessage auditMessage) { boolean persistSuccessAudit = BooleanUtils.isTrue(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistSuccessAudit(); boolean persistFailureAudit = BooleanUtils.isFalse(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistFailureAudit(); if (persistFailureAudit || persistSuccessAudit) { if (auditMessage.getTimestamp() == null) { auditMessage.setTimestamp(new Timestamp(System.currentTimeMillis())); } return dao.saveItem(auditMessage); } return null; }  }
SyncAuditServiceImpl extends BaseOpenmrsService implements SyncAuditService { @Override public AuditMessage saveAuditMessageDuringSync(AuditMessage auditMessage) { boolean persistSuccessAudit = BooleanUtils.isTrue(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistSuccessAudit(); boolean persistFailureAudit = BooleanUtils.isFalse(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistFailureAudit(); if (persistFailureAudit || persistSuccessAudit) { if (auditMessage.getTimestamp() == null) { auditMessage.setTimestamp(new Timestamp(System.currentTimeMillis())); } return dao.saveItem(auditMessage); } return null; }  void setDao(SyncAuditDao dao); @Override AuditMessage getMessageByUuid(String uuid); @Override AuditMessage getMessageById(Integer id); @Override String getJsonMessageByUuid(String uuid); @Override String getJsonMessageById(Integer id); @Override String getPaginatedMessages(Integer page, Integer pageSize, Boolean success, String operation,
                                       String resourceName, String creatorInstanceId); @Override AuditMessage saveAuditMessageDuringSync(AuditMessage auditMessage); @Override AuditMessage saveAuditMessage(AuditMessage auditMessage); @Override AuditMessage setNextAudit(AuditMessage current, AuditMessage next); @Override Set<String> getAllCreatorIds(); @Override AuditMessage getMessageByMergeConflictUuid(String uuid); @Override String getJsonMessage(AuditMessage message); }
SyncAuditServiceImpl extends BaseOpenmrsService implements SyncAuditService { @Override public AuditMessage saveAuditMessageDuringSync(AuditMessage auditMessage) { boolean persistSuccessAudit = BooleanUtils.isTrue(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistSuccessAudit(); boolean persistFailureAudit = BooleanUtils.isFalse(auditMessage.getSuccess()) && configuration.getSyncConfiguration().getGeneral().isPersistFailureAudit(); if (persistFailureAudit || persistSuccessAudit) { if (auditMessage.getTimestamp() == null) { auditMessage.setTimestamp(new Timestamp(System.currentTimeMillis())); } return dao.saveItem(auditMessage); } return null; }  void setDao(SyncAuditDao dao); @Override AuditMessage getMessageByUuid(String uuid); @Override AuditMessage getMessageById(Integer id); @Override String getJsonMessageByUuid(String uuid); @Override String getJsonMessageById(Integer id); @Override String getPaginatedMessages(Integer page, Integer pageSize, Boolean success, String operation,
                                       String resourceName, String creatorInstanceId); @Override AuditMessage saveAuditMessageDuringSync(AuditMessage auditMessage); @Override AuditMessage saveAuditMessage(AuditMessage auditMessage); @Override AuditMessage setNextAudit(AuditMessage current, AuditMessage next); @Override Set<String> getAllCreatorIds(); @Override AuditMessage getMessageByMergeConflictUuid(String uuid); @Override String getJsonMessage(AuditMessage message);  }