use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView in project webcert by sklintyg.
the class ArendeViewConverterTest method differentMessageThreadsShouldBeSeparatedAndSortedOnSenasteHandelse.
@Test
public void differentMessageThreadsShouldBeSeparatedAndSortedOnSenasteHandelse() {
// Given
LocalDateTime startOfFirstThread = LocalDateTime.parse("2016-03-01T11:22:11");
Arende fraga1 = createValidArendeForLuse("fraga", startOfFirstThread, "fraga1-id", null);
Arende p11 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusHours(2), "paminnelse-1.1-id", fraga1);
Arende p12 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusDays(1), "paminnelse-1.2-id", fraga1);
Arende p13 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusDays(3), "paminnelse-1.3-id", fraga1);
Arende svar1 = createValidArendeForLuse("svar", startOfFirstThread.plusDays(4), "svar-1-id", fraga1);
LocalDateTime startOfSecondThread = LocalDateTime.parse("2016-03-02T11:22:11");
Arende fraga2 = createValidArendeForLuse("fraga", startOfSecondThread, "fraga2-id", null);
Arende p21 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusHours(2), "paminnelse-2.1-id", fraga2);
Arende p22 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusDays(1), "paminnelse-2.2-id", fraga2);
Arende svar2 = createValidArendeForLuse("svar", startOfFirstThread.plusDays(4), "svar-2-id", fraga2);
List<Arende> mixedThreads = ImmutableList.of(fraga1, fraga2, p11, p21, p12, p22, p13, svar2, svar1);
// When
List<ArendeConversationView> createdList = converter.buildArendeConversations(intygsId, mixedThreads, Collections.emptyList(), Collections.emptyList());
// Then
List<ArendeView> expectedPaminnelser1Dtos = Stream.of(p13, p12, p11).map(converter::convertToDto).collect(Collectors.toList());
List<ArendeView> expectedPaminnelser2Dtos = Stream.of(p22, p21).map(converter::convertToDto).collect(Collectors.toList());
Assertions.assertThat(createdList).hasSize(2).extracting("fraga", "svar", "paminnelser").contains(tuple(converter.convertToDto(fraga1), converter.convertToDto(svar1), expectedPaminnelser1Dtos), tuple(converter.convertToDto(fraga2), converter.convertToDto(svar2), expectedPaminnelser2Dtos));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView in project webcert by sklintyg.
the class ArendeViewConverterTest method convertToArendeConversationViewTest.
@Test
public void convertToArendeConversationViewTest() {
final String fragaMeddelandeId = "fragaId";
final LocalDateTime senasteHandelseFraga = LocalDateTime.now();
final String svarMeddelandeId = "svarId";
final String paminnelse1MeddelandeId = "paminnelse1Id";
final LocalDateTime paminnelse1Timestamp = LocalDateTime.now();
final String paminnelse2MeddelandeId = "paminnelse2Id";
final LocalDateTime paminnelse2Timestamp = paminnelse1Timestamp.minusDays(2);
ArendeConversationView res = converter.convertToArendeConversationView(buildArende(fragaMeddelandeId, senasteHandelseFraga, LocalDateTime.now()), buildArende(svarMeddelandeId, null, LocalDateTime.now()), null, Arrays.asList(buildArende(paminnelse2MeddelandeId, null, paminnelse2Timestamp), buildArende(paminnelse1MeddelandeId, null, paminnelse1Timestamp)), null);
assertNotNull(res);
assertNotNull(res.getFraga());
assertEquals(fragaMeddelandeId, res.getFraga().getInternReferens());
assertNotNull(res.getSvar());
assertEquals(svarMeddelandeId, res.getSvar().getInternReferens());
assertNotNull(res.getPaminnelser());
assertEquals(2, res.getPaminnelser().size());
// assert paminnelser are sorted
assertEquals(paminnelse1MeddelandeId, res.getPaminnelser().get(0).getInternReferens());
assertEquals(paminnelse2MeddelandeId, res.getPaminnelser().get(1).getInternReferens());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView in project webcert by sklintyg.
the class ArendeViewConverterTest method emptyListOfKompletterandeIntygIsOk.
@Test
public void emptyListOfKompletterandeIntygIsOk() {
// Given
LocalDateTime fragaTimestamp = LocalDateTime.parse("2016-03-01T11:22:11");
Arende fraga = createValidArendeForLuse("fraga", fragaTimestamp, "unique id of fraga", null);
Arende svar = createValidArendeForLuse("svar", fragaTimestamp.plusMinutes(10), "unique id of svar", fraga);
// When
List<ArendeConversationView> res = converter.buildArendeConversations(fraga.getIntygsId(), ImmutableList.of(fraga, svar), Collections.emptyList(), Collections.emptyList());
// Then
Assertions.assertThat(res).hasSize(1).extracting("fraga", "svar", "answeredWithIntyg").contains(tuple(converter.convertToDto(fraga), converter.convertToDto(svar), null));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeConversationView 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);
}
Aggregations