use of org.karnak.backend.data.entity.TransferStatusEntity in project karnak by OsiriX-Foundation.
the class TransferStatusRepoTest method shouldFindByDestinationIdAndTransferDateAfter.
/**
* Test method findByDestinationIdAndTransferDateAfter
*/
@Test
void shouldFindByDestinationIdAndTransferDateAfter() {
// Init data
TransferStatusEntity transferStatusEntity = new TransferStatusEntity();
transferStatusEntity.setTransferDate(LocalDateTime.of(2022, 1, 14, 15, 16, 17));
TransferStatusEntity toTest = repository.saveAndFlush(transferStatusEntity);
// Call method with date before
List<TransferStatusEntity> byDestinationIdAndTransferDateAfter = repository.findByDestinationIdAndTransferDateAfter(toTest.getDestinationId(), LocalDateTime.of(2022, 1, 14, 0, 0, 0));
// Test results
assertFalse(byDestinationIdAndTransferDateAfter.isEmpty());
// Call method with date after
byDestinationIdAndTransferDateAfter = repository.findByDestinationIdAndTransferDateAfter(toTest.getDestinationId(), LocalDateTime.of(2022, 1, 15, 0, 0, 0));
// Test results
assertTrue(byDestinationIdAndTransferDateAfter.isEmpty());
}
use of org.karnak.backend.data.entity.TransferStatusEntity in project karnak by OsiriX-Foundation.
the class TransferStatusRepoTest method shouldFindByDestinationId.
/**
* Test method findByDestinationIdAndTransferDateAfter
*/
@Test
void shouldFindByDestinationId() {
// Init data
TransferStatusEntity transferStatusEntity = new TransferStatusEntity();
TransferStatusEntity toTest = repository.saveAndFlush(transferStatusEntity);
// Call method with date before
List<TransferStatusEntity> byDestinationId = repository.findByDestinationId(toTest.getDestinationId());
// Test results
assertFalse(byDestinationId.isEmpty());
assertEquals(toTest.getId(), byDestinationId.get(0).getId());
}
use of org.karnak.backend.data.entity.TransferStatusEntity in project karnak by OsiriX-Foundation.
the class TransferStatusRepoTest method shouldSaveAndFindARecord.
/**
* Test save and find record.
*/
@Test
void shouldSaveAndFindARecord() {
// Create an entity to save
TransferStatusEntity entity = new TransferStatusEntity();
entity.setPatientIdOriginal("Id");
// Save the entity
LOGGER.info("Saving entity with PatientIdOriginal [{}]", entity.getPatientIdOriginal());
entity = repository.save(entity);
// Test Save
assertEquals("Id", entity.getPatientIdOriginal());
assertNotNull(entity.getId());
LOGGER.info("Entity with PatientIdOriginal [{}] and id [{}] saved", entity.getPatientIdOriginal(), entity.getId());
// Find By Id
Optional<TransferStatusEntity> foundByIdOpt = repository.findById(entity.getId());
// Test Find by Id
assertTrue(foundByIdOpt.isPresent());
LOGGER.info("Entity found with PatientId [{}] and id [{}]", foundByIdOpt.get().getPatientIdOriginal(), foundByIdOpt.get().getId());
assertEquals(entity.getId(), foundByIdOpt.get().getId());
}
use of org.karnak.backend.data.entity.TransferStatusEntity in project karnak by OsiriX-Foundation.
the class TransferStatusRepoTest method shouldDeleteRecord.
/**
* Test delete record.
*/
@Test
void shouldDeleteRecord() {
// Create an entity to save
TransferStatusEntity entity = new TransferStatusEntity();
String description = "description";
entity.setStudyDescriptionToSend(description);
// Save the entity
LOGGER.info("Saving entity with description [{}]", entity.getStudyDescriptionToSend());
entity = repository.save(entity);
// Retrieve the entity
Optional<TransferStatusEntity> foundByIdOpt = repository.findById(entity.getId());
// Test Find by Id
assertTrue(foundByIdOpt.isPresent());
// Delete the entity
entity = foundByIdOpt.get();
Long id = entity.getId();
LOGGER.info("Deleting entity with id [{}]", id);
repository.delete(entity);
// Test Delete
foundByIdOpt = repository.findById(id);
LOGGER.info("Is deleted entity with id [{}] present: [{}]", id, foundByIdOpt.isPresent());
assertFalse(foundByIdOpt.isPresent());
}
use of org.karnak.backend.data.entity.TransferStatusEntity in project karnak by OsiriX-Foundation.
the class TransferStatusSpecificationTest method shouldFilterBySopInstanceUid.
@Test
void shouldFilterBySopInstanceUid() {
// Init data
// Original
TransferStatusFilter filterOriginal = new TransferStatusFilter();
filterOriginal.setSopInstanceUid("sopInstanceUidOriginal");
Specification<TransferStatusEntity> transferStatusSpecificationOriginal = new TransferStatusSpecification(filterOriginal);
// To Send
TransferStatusFilter filterToSend = new TransferStatusFilter();
filterToSend.setSopInstanceUid("sopInstanceUidToSend");
Specification<TransferStatusEntity> transferStatusSpecificationToSend = new TransferStatusSpecification(filterToSend);
// Call service
List<TransferStatusEntity> transferStatusEntitiesOriginal = repository.findAll(transferStatusSpecificationOriginal);
List<TransferStatusEntity> transferStatusEntitiesToSend = repository.findAll(transferStatusSpecificationToSend);
// Test results
// Original
assertNotNull(transferStatusEntitiesOriginal);
assertFalse(transferStatusEntitiesOriginal.isEmpty());
assertEquals(1, transferStatusEntitiesOriginal.size());
assertEquals("sopInstanceUidOriginal", transferStatusEntitiesOriginal.get(0).getSopInstanceUidOriginal());
// To Send
assertNotNull(transferStatusEntitiesToSend);
assertFalse(transferStatusEntitiesToSend.isEmpty());
assertEquals(1, transferStatusEntitiesToSend.size());
assertEquals("sopInstanceUidToSend", transferStatusEntitiesToSend.get(0).getSopInstanceUidToSend());
}
Aggregations