Skip to content

Commit

Permalink
RIA-7376_link_case_det: Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirsanov committed Sep 19, 2023
1 parent 1ad913d commit 5f956c1
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ class InternalMaintainCaseLinkAppealTemplateTest {
private final String logo = "[userImage:hmcts.png]";
private InternalMaintainCaseLinkAppealTemplate internalMaintainCaseLinkAppealTemplate;
private Map<String, Object> fieldValuesMap;
private final List<String> reasonsForLink = List.of("CLRC001", "CLRC002");
private final List<AbstractMap.SimpleEntry<String, String>> pairList = List.of(
new AbstractMap.SimpleEntry<>("reason", "Same Party"),
new AbstractMap.SimpleEntry<>("reason", "Same child/ren")
);

@BeforeEach
public void setUp() {
Expand All @@ -69,6 +72,7 @@ void dataSetup() {
when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName));
when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber));
when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES));
when(asylumCase.read(CASE_LINKS)).thenReturn(Optional.of(createCaseLinksFixtures()));
}

@Test
Expand All @@ -81,13 +85,14 @@ void should_populate_template_correctly() {
assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName"));
assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber"));
assertEquals(telephoneNumber, fieldValuesMap.get("customerServicesTelephone"));
assertEquals(pairList, fieldValuesMap.get("reason"));
assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent"));
}

@Test
void should_throw_when_case_links_are_not_present() {
dataSetup();
when(asylumCase.read(CASE_LINKS, List.class)).thenReturn(Optional.empty());
when(asylumCase.read(CASE_LINKS)).thenReturn(Optional.empty());

assertThatThrownBy(() -> internalMaintainCaseLinkAppealTemplate.mapFieldValues(caseDetails))
.isExactlyInstanceOf(IllegalStateException.class)
Expand All @@ -98,14 +103,7 @@ void should_throw_when_case_links_are_not_present() {
@Test
void should_resolve_reasons_from_latest_create_link_event() {
dataSetup();
when(asylumCase.read(CASE_LINKS)).thenReturn(Optional.of(createCaseLinksFixtures()));

fieldValuesMap = internalMaintainCaseLinkAppealTemplate.mapFieldValues(caseDetails);
List<AbstractMap.SimpleEntry<String, String>> pairList = List.of(
new AbstractMap.SimpleEntry<>("reason", "Same Party"),
new AbstractMap.SimpleEntry<>("reason", "Same child/ren")
);

assertEquals(pairList, fieldValuesMap.get("reason"));
}

Expand Down

0 comments on commit 5f956c1

Please sign in to comment.