Search in sources :

Example 1 with TransferStatusEntity

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());
}
Also used : TransferStatusEntity(org.karnak.backend.data.entity.TransferStatusEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 2 with TransferStatusEntity

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());
}
Also used : TransferStatusEntity(org.karnak.backend.data.entity.TransferStatusEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 3 with TransferStatusEntity

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());
}
Also used : TransferStatusEntity(org.karnak.backend.data.entity.TransferStatusEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 4 with TransferStatusEntity

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());
}
Also used : TransferStatusEntity(org.karnak.backend.data.entity.TransferStatusEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 5 with TransferStatusEntity

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());
}
Also used : TransferStatusEntity(org.karnak.backend.data.entity.TransferStatusEntity) TransferStatusFilter(org.karnak.frontend.monitoring.component.TransferStatusFilter) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Aggregations

TransferStatusEntity (org.karnak.backend.data.entity.TransferStatusEntity)24 Test (org.junit.jupiter.api.Test)15 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)12 TransferStatusFilter (org.karnak.frontend.monitoring.component.TransferStatusFilter)7 Pageable (org.springframework.data.domain.Pageable)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 PageImpl (org.springframework.data.domain.PageImpl)3 ArrayList (java.util.ArrayList)2 TransferStatusSpecification (org.karnak.backend.data.repo.specification.TransferStatusSpecification)2 SerieSummaryNotification (org.karnak.backend.model.notification.SerieSummaryNotification)2 TransferMonitoringNotification (org.karnak.backend.model.notification.TransferMonitoringNotification)2 CSVWriter (com.opencsv.CSVWriter)1 StatefulBeanToCsvBuilder (com.opencsv.bean.StatefulBeanToCsvBuilder)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 LocalDateTime (java.time.LocalDateTime)1 List (java.util.List)1 Map (java.util.Map)1 DestinationEntity (org.karnak.backend.data.entity.DestinationEntity)1 ForwardNodeEntity (org.karnak.backend.data.entity.ForwardNodeEntity)1