@Test public void findFirstByJobIdNotNullTest() { OffsetDateTime timeLastSent = DateUtils.createCurrentDateTimestamp(); OffsetDateTime timeCreated = timeLastSent.minusMinutes(10L); AuditEntryStatus status = AuditEntryStatus.PENDING; UUID testUUID = UUID.randomUUID(); AuditEntryRepository auditEntryRepository = Mockito.mock(AuditEntryRepository.class); AuditEntryEntity auditEntryEntity = new AuditEntryEntity(testUUID, timeCreated, timeLastSent, status.name(), null, null); Mockito.when(auditEntryRepository.findFirstByCommonConfigIdOrderByTimeLastSentDesc(Mockito.any(UUID.class))).thenReturn(Optional.of(auditEntryEntity)); DefaultAuditAccessor auditUtility = new DefaultAuditAccessor(auditEntryRepository, null, null, null, null); AuditJobStatusModel auditJobStatusModel = auditUtility.findFirstByJobId(testUUID).get(); String testTimeAuditCreated = auditJobStatusModel.getTimeAuditCreated(); String testTimeLastSent = auditJobStatusModel.getTimeLastSent(); String testStatus = auditJobStatusModel.getStatus(); assertTrue(auditUtility.findFirstByJobId(testUUID).isPresent()); assertEquals(DateUtils.formatDate(timeCreated, DateUtils.AUDIT_DATE_FORMAT), testTimeAuditCreated); assertEquals(DateUtils.formatDate(timeLastSent, DateUtils.AUDIT_DATE_FORMAT), testTimeLastSent); assertEquals(status.getDisplayName(), testStatus); }
@Override @Transactional public Optional<AuditJobStatusModel> findFirstByJobId(UUID jobId) { Optional<AuditEntryEntity> auditEntryEntity = auditEntryRepository.findFirstByCommonConfigIdOrderByTimeLastSentDesc(jobId); return auditEntryEntity.map(this::convertToJobStatusModel); }
DefaultAuditAccessor implements AuditAccessor { @Override @Transactional public Optional<AuditJobStatusModel> findFirstByJobId(UUID jobId) { Optional<AuditEntryEntity> auditEntryEntity = auditEntryRepository.findFirstByCommonConfigIdOrderByTimeLastSentDesc(jobId); return auditEntryEntity.map(this::convertToJobStatusModel); } }
DefaultAuditAccessor implements AuditAccessor { @Override @Transactional public Optional<AuditJobStatusModel> findFirstByJobId(UUID jobId) { Optional<AuditEntryEntity> auditEntryEntity = auditEntryRepository.findFirstByCommonConfigIdOrderByTimeLastSentDesc(jobId); return auditEntryEntity.map(this::convertToJobStatusModel); } @Autowired  DefaultAuditAccessor(AuditEntryRepository auditEntryRepository, AuditNotificationRepository auditNotificationRepository, ConfigurationAccessor configurationAccessor,
        DefaultNotificationAccessor notificationAccessor, ContentConverter contentConverter); }
DefaultAuditAccessor implements AuditAccessor { @Override @Transactional public Optional<AuditJobStatusModel> findFirstByJobId(UUID jobId) { Optional<AuditEntryEntity> auditEntryEntity = auditEntryRepository.findFirstByCommonConfigIdOrderByTimeLastSentDesc(jobId); return auditEntryEntity.map(this::convertToJobStatusModel); } @Autowired  DefaultAuditAccessor(AuditEntryRepository auditEntryRepository, AuditNotificationRepository auditNotificationRepository, ConfigurationAccessor configurationAccessor,
        DefaultNotificationAccessor notificationAccessor, ContentConverter contentConverter); @Override Optional<Long> findMatchingAuditId(Long notificationId, UUID commonDistributionId); @Override @Transactional Optional<AuditJobStatusModel> findFirstByJobId(UUID jobId); @Override @Transactional AuditEntryPageModel getPageOfAuditEntries(Integer pageNumber, Integer pageSize, String searchTerm, String sortField, String sortOrder, boolean onlyShowSentNotifications,
        Function<AlertNotificationModel, AuditEntryModel> notificationToAuditEntryConverter); @Override @Transactional Map<Long, Long> createAuditEntry(Map<Long, Long> existingNotificationIdToAuditId, UUID jobId, MessageContentGroup contentGroup); @Override @Transactional void setAuditEntrySuccess(Collection<Long> auditEntryIds); @Override @Transactional void setAuditEntryFailure(Collection<Long> auditEntryIds, String errorMessage, Throwable t); @Override @Transactional AuditEntryModel convertToAuditEntryModelFromNotification(AlertNotificationModel notificationContentEntry); }
DefaultAuditAccessor implements AuditAccessor { @Override @Transactional public Optional<AuditJobStatusModel> findFirstByJobId(UUID jobId) { Optional<AuditEntryEntity> auditEntryEntity = auditEntryRepository.findFirstByCommonConfigIdOrderByTimeLastSentDesc(jobId); return auditEntryEntity.map(this::convertToJobStatusModel); } @Autowired  DefaultAuditAccessor(AuditEntryRepository auditEntryRepository, AuditNotificationRepository auditNotificationRepository, ConfigurationAccessor configurationAccessor,
        DefaultNotificationAccessor notificationAccessor, ContentConverter contentConverter); @Override Optional<Long> findMatchingAuditId(Long notificationId, UUID commonDistributionId); @Override @Transactional Optional<AuditJobStatusModel> findFirstByJobId(UUID jobId); @Override @Transactional AuditEntryPageModel getPageOfAuditEntries(Integer pageNumber, Integer pageSize, String searchTerm, String sortField, String sortOrder, boolean onlyShowSentNotifications,
        Function<AlertNotificationModel, AuditEntryModel> notificationToAuditEntryConverter); @Override @Transactional Map<Long, Long> createAuditEntry(Map<Long, Long> existingNotificationIdToAuditId, UUID jobId, MessageContentGroup contentGroup); @Override @Transactional void setAuditEntrySuccess(Collection<Long> auditEntryIds); @Override @Transactional void setAuditEntryFailure(Collection<Long> auditEntryIds, String errorMessage, Throwable t); @Override @Transactional AuditEntryModel convertToAuditEntryModelFromNotification(AlertNotificationModel notificationContentEntry);  }