### Question:
PsuIdDataAuthorisationService { public PsuIdData getPsuIdData(String authorisationId, List<PsuIdData> psuIdDataList) { PsuIdData psuIdData = authorisationService.getAuthorisationById(authorisationId) .map(Authorisation::getPsuIdData) .orElse(null); if (psuIdData == null && !psuIdDataList.isEmpty()) { psuIdData = psuIdDataList.get(0); } return psuIdData != null ? psuIdData : new PsuIdData(); }  PsuIdData getPsuIdData(String authorisationId, List<PsuIdData> psuIdDataList);  }### Answer:
@Test void getPsuIdData_fromAuthorisation() { when(authorisationService.getAuthorisationById(AUTHORISATION_ID)).thenReturn(Optional.of(authorisation)); PsuIdData actualData = psuIdDataAuthorisationService.getPsuIdData(AUTHORISATION_ID, PSU_ID_DATA_LIST_FROM_PAYMENT); assertThat(actualData).isEqualTo(PSU_ID_DATA_FROM_AUTHORISATION); }
@Test void getPsuIdData_fromPayment() { when(authorisationService.getAuthorisationById(AUTHORISATION_ID)).thenReturn(Optional.empty()); PsuIdData actualData = psuIdDataAuthorisationService.getPsuIdData(AUTHORISATION_ID, PSU_ID_DATA_LIST_FROM_PAYMENT); assertThat(actualData).isEqualTo(PSU_ID_DATA_FROM_PAYMENT); }
@Test void getPsuIdData_empty() { when(authorisationService.getAuthorisationById(AUTHORISATION_ID)).thenReturn(Optional.empty()); PsuIdData actualData = psuIdDataAuthorisationService.getPsuIdData(AUTHORISATION_ID, Collections.emptyList()); assertThat(actualData).isEqualTo(new PsuIdData()); }