Search in sources :

Example 1 with ArgumentEntity

use of org.karnak.backend.data.entity.ArgumentEntity in project karnak by OsiriX-Foundation.

the class ArgumentRepoTest method shouldModifyRecord.

/**
 * Test modification of a record.
 */
@Test
void shouldModifyRecord() {
    String initialText = "InitialText";
    String modifiedText = "ModifiedText";
    // Create an entity to save
    ArgumentEntity entity = new ArgumentEntity();
    entity.setKey(initialText);
    // Save the entity
    LOGGER.info("Saving entity with Key [{}]", entity.getKey());
    entity = repository.save(entity);
    LOGGER.info("Id of the entity with Key [{}]", entity.getId());
    // Test Save
    assertNotNull(entity);
    assertEquals(initialText, entity.getKey());
    // Modify the record
    entity.setKey(modifiedText);
    LOGGER.info("Modify entity Key [{}] to [{}]", initialText, modifiedText);
    ArgumentEntity entityModified = repository.save(entity);
    // Test Modify
    assertNotNull(entityModified);
    assertEquals(entity.getId(), entityModified.getId());
    assertEquals(modifiedText, entityModified.getKey());
    LOGGER.info("Key of the entity with id [{}]: [{}]", entityModified.getId(), entityModified.getKey());
}
Also used : ArgumentEntity(org.karnak.backend.data.entity.ArgumentEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 2 with ArgumentEntity

use of org.karnak.backend.data.entity.ArgumentEntity in project karnak by OsiriX-Foundation.

the class ArgumentRepoTest method shouldFindAllRecords.

/**
 * Test find all.
 */
@Test
void shouldFindAllRecords() {
    // Create an entity to save
    // Profile
    ProfileEntity profileEntity = new ProfileEntity();
    profileEntity.setName("name");
    profileEntity = profileRepo.saveAndFlush(profileEntity);
    // Profile element
    ProfileElementEntity profileElementEntity = new ProfileElementEntity();
    profileElementEntity.setName("name");
    profileElementEntity.setProfileEntity(profileEntity);
    profileElementEntity = profileElementRepo.saveAndFlush(profileElementEntity);
    // Argument
    ArgumentEntity entity = new ArgumentEntity();
    entity.setKey("Key");
    entity.setProfileElementEntity(profileElementEntity);
    // Save the entity
    LOGGER.info("Saving entity with Key [{}]", entity.getKey());
    repository.saveAndFlush(entity);
    // Find all
    List<ArgumentEntity> all = repository.findAll();
    // Test find all
    assertNotNull(all);
    assertTrue(all.size() > 0);
    assertEquals(1, all.size());
    LOGGER.info("Number of entities found [{}]", all.size());
}
Also used : ArgumentEntity(org.karnak.backend.data.entity.ArgumentEntity) ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 3 with ArgumentEntity

use of org.karnak.backend.data.entity.ArgumentEntity in project karnak by OsiriX-Foundation.

the class ArgumentRepoTest method shouldSaveAndFindARecord.

/**
 * Test save and find record.
 */
@Test
void shouldSaveAndFindARecord() {
    // Create an entity to save
    ArgumentEntity entity = new ArgumentEntity();
    entity.setKey("Key");
    // Save the entity
    LOGGER.info("Saving entity with Key [{}]", entity.getKey());
    entity = repository.save(entity);
    // Test Save
    assertEquals("Key", entity.getKey());
    assertNotNull(entity.getId());
    LOGGER.info("Entity with Key [{}] and id [{}] saved", entity.getKey(), entity.getId());
    // Find By Id
    Optional<ArgumentEntity> foundByIdOpt = repository.findById(entity.getId());
    // Test Find by Id
    assertTrue(foundByIdOpt.isPresent());
    LOGGER.info("Entity found with Key [{}] and id [{}]", foundByIdOpt.get().getKey(), foundByIdOpt.get().getId());
    assertEquals(entity.getId(), foundByIdOpt.get().getId());
}
Also used : ArgumentEntity(org.karnak.backend.data.entity.ArgumentEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 4 with ArgumentEntity

use of org.karnak.backend.data.entity.ArgumentEntity in project karnak by OsiriX-Foundation.

the class ArgumentRepoTest method shouldDeleteRecord.

/**
 * Test delete record.
 */
@Test
void shouldDeleteRecord() {
    // Create an entity to save
    ArgumentEntity entity = new ArgumentEntity();
    String key = "Key";
    entity.setKey(key);
    // Save the entity
    LOGGER.info("Saving entity with Key [{}]", entity.getKey());
    entity = repository.save(entity);
    // Retrieve the entity
    Optional<ArgumentEntity> 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 : ArgumentEntity(org.karnak.backend.data.entity.ArgumentEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 5 with ArgumentEntity

use of org.karnak.backend.data.entity.ArgumentEntity in project karnak by OsiriX-Foundation.

the class DatePatternTest method verifyPatternArguments.

@Test
void verifyPatternArguments() {
    List<ArgumentEntity> argsFalse = new ArrayList<>();
    argsFalse.add(new ArgumentEntity("second", "day", null));
    List<ArgumentEntity> argsFalse2 = new ArrayList<>();
    argsFalse.add(new ArgumentEntity("remove", "daytt", null));
    Assertions.assertThrows(IllegalArgumentException.class, () -> {
        DateFormat.verifyPatternArguments(argsFalse);
    });
    Assertions.assertThrows(IllegalArgumentException.class, () -> {
        DateFormat.verifyPatternArguments(argsFalse2);
    });
}
Also used : ArgumentEntity(org.karnak.backend.data.entity.ArgumentEntity) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

ArgumentEntity (org.karnak.backend.data.entity.ArgumentEntity)13 Test (org.junit.jupiter.api.Test)10 ProfileElementEntity (org.karnak.backend.data.entity.ProfileElementEntity)7 IncludedTagEntity (org.karnak.backend.data.entity.IncludedTagEntity)6 ProfileEntity (org.karnak.backend.data.entity.ProfileEntity)6 Attributes (org.dcm4che3.data.Attributes)5 Profile (org.karnak.backend.service.profilepipe.Profile)4 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 HMAC (org.karnak.backend.model.profilepipe.HMAC)3 ArrayList (java.util.ArrayList)2 ExcludedTagEntity (org.karnak.backend.data.entity.ExcludedTagEntity)2 HashContext (org.karnak.backend.model.profilepipe.HashContext)2 Text (com.vaadin.flow.component.Text)1 Div (com.vaadin.flow.component.html.Div)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 Sequence (org.dcm4che3.data.Sequence)1