Search in sources :

Example 6 with ArendeView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.

the class ArendeViewConverterTest method testConvertKompletteringInstansTooHigh.

@SuppressWarnings("unchecked")
@Test
public void testConvertKompletteringInstansTooHigh() throws ModuleNotFoundException {
    Arende arende = buildArende("lisjp");
    arende.setKomplettering(Arrays.asList(buildMedicinsktArende("1", 3, "arende1")));
    ArendeView result = converter.convertToDto(arende);
    assertEquals(1, result.getKompletteringar().size());
    assertEquals(RespConstants.GRUNDFORMEDICINSKTUNDERLAG_SVAR_JSON_ID_1, result.getKompletteringar().get(0).getJsonPropertyHandle());
    assertEquals(new Integer(2), result.getKompletteringar().get(0).getPosition());
    assertEquals(VARDAKTOR_NAMN, result.getVardaktorNamn());
    assertEquals(ENHETS_NAMN, result.getEnhetsnamn());
    assertEquals(VARDGIVARE_NAMN, result.getVardgivarnamn());
    verify(moduleApi).getModuleSpecificArendeParameters(any(Utlatande.class), any(List.class));
}
Also used : LuseUtlatande(se.inera.intyg.common.luse.model.internal.LuseUtlatande) LisjpUtlatande(se.inera.intyg.common.lisjp.model.internal.LisjpUtlatande) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ImmutableList(com.google.common.collect.ImmutableList) ArendeView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView) Test(org.junit.Test)

Example 7 with ArendeView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.

the class ArendeViewConverterTest method testConvertToArendeForLisjp.

@SuppressWarnings("unchecked")
@Test
public void testConvertToArendeForLisjp() throws ModuleNotFoundException {
    ArendeView result = converter.convertToDto(buildArende("lisjp"));
    assertEquals(RespConstants.GRUNDFORMEDICINSKTUNDERLAG_TELEFONKONTAKT_PATIENT_SVAR_JSON_ID_1, result.getKompletteringar().get(0).getJsonPropertyHandle());
    assertEquals(RespConstants.KANNEDOM_SVAR_JSON_ID_2, result.getKompletteringar().get(1).getJsonPropertyHandle());
    assertEquals(RespConstants.UNDERLAG_SVAR_JSON_ID_4, result.getKompletteringar().get(2).getJsonPropertyHandle());
    assertEquals(new Integer(0), result.getKompletteringar().get(0).getPosition());
    assertEquals(new Integer(0), result.getKompletteringar().get(1).getPosition());
    assertEquals(new Integer(1), result.getKompletteringar().get(2).getPosition());
    assertEquals(VARDAKTOR_NAMN, result.getVardaktorNamn());
    assertEquals(ENHETS_NAMN, result.getEnhetsnamn());
    assertEquals(VARDGIVARE_NAMN, result.getVardgivarnamn());
    verify(moduleApi).getModuleSpecificArendeParameters(any(Utlatande.class), any(List.class));
}
Also used : LuseUtlatande(se.inera.intyg.common.luse.model.internal.LuseUtlatande) LisjpUtlatande(se.inera.intyg.common.lisjp.model.internal.LisjpUtlatande) ImmutableList(com.google.common.collect.ImmutableList) ArendeView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView) Test(org.junit.Test)

Example 8 with ArendeView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.

the class ArendeViewConverterTest method paminnelserInArendeConversionViewShouldBeReverseSortedOnDate.

@Test
public void paminnelserInArendeConversionViewShouldBeReverseSortedOnDate() {
    // Given
    LocalDateTime fragaTimestamp = LocalDateTime.parse("2016-03-01T11:22:11");
    Arende fraga = createValidArendeForLuse("fraga", fragaTimestamp, "fraga1-id", null);
    Arende p1 = createValidArendeForLuse("paminnelse", fragaTimestamp.plusHours(2), "paminnelse-1.1-id", fraga);
    Arende p2 = createValidArendeForLuse("paminnelse", fragaTimestamp.plusDays(1), "paminnelse-1.2-id", fraga);
    Arende p3 = createValidArendeForLuse("paminnelse", fragaTimestamp.plusDays(3), "paminnelse-1.3-id", fraga);
    Arende svar = createValidArendeForLuse("svar", fragaTimestamp.plusDays(4), "svar-1-id", fraga);
    // When
    ArendeConversationView messageThread = converter.convertToArendeConversationView(fraga, svar, null, ImmutableList.of(p3, p1, p2), null);
    // Then
    List<ArendeView> expectedPaminnelserOrder = Stream.of(p3, p2, p1).map(converter::convertToDto).collect(Collectors.toList());
    Assertions.assertThat(messageThread.getPaminnelser()).hasSize(3).containsExactlyElementsOf(expectedPaminnelserOrder);
}
Also used : LocalDateTime(java.time.LocalDateTime) ArendeConversationView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ArendeView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView) Test(org.junit.Test)

Example 9 with ArendeView

use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.

the class ArendeViewConverterTest method testConvertKompletteringUnknownQuestionId.

@SuppressWarnings("unchecked")
@Test
public void testConvertKompletteringUnknownQuestionId() throws ModuleNotFoundException {
    Arende arende = buildArende("lisjp");
    arende.setKomplettering(Arrays.asList(buildMedicinsktArende("10", 1, "arende1")));
    ArendeView result = converter.convertToDto(arende);
    assertEquals(1, result.getKompletteringar().size());
    assertEquals("", result.getKompletteringar().get(0).getJsonPropertyHandle());
    assertEquals(new Integer(0), result.getKompletteringar().get(0).getPosition());
    assertEquals(VARDAKTOR_NAMN, result.getVardaktorNamn());
    assertEquals(ENHETS_NAMN, result.getEnhetsnamn());
    assertEquals(VARDGIVARE_NAMN, result.getVardgivarnamn());
    verify(moduleApi).getModuleSpecificArendeParameters(any(Utlatande.class), any(List.class));
}
Also used : LuseUtlatande(se.inera.intyg.common.luse.model.internal.LuseUtlatande) LisjpUtlatande(se.inera.intyg.common.lisjp.model.internal.LisjpUtlatande) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ImmutableList(com.google.common.collect.ImmutableList) ArendeView(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 ArendeView (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView)9 ImmutableList (com.google.common.collect.ImmutableList)7 LisjpUtlatande (se.inera.intyg.common.lisjp.model.internal.LisjpUtlatande)6 LuseUtlatande (se.inera.intyg.common.luse.model.internal.LuseUtlatande)6 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)6 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)6 LocalDateTime (java.time.LocalDateTime)3 ArendeConversationView (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 MoreCollectors (com.google.common.collect.MoreCollectors)1 Clock (java.time.Clock)1 Instant (java.time.Instant)1 ZoneId (java.time.ZoneId)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 RunWith (org.junit.runner.RunWith)1