### Question:
TppStopListServiceInternal implements TppStopListService { @Override public CmsResponse<Boolean> checkIfTppBlocked(String tppAuthorisationNumber, String instanceId) { String requestedInstanceId = StringUtils.isBlank(instanceId) ? serviceInstanceId : instanceId; Optional<TppStopListEntity> stopListEntityOptional = tppStopListRepository.findByTppAuthorisationNumberAndInstanceId(tppAuthorisationNumber, requestedInstanceId); Boolean blocked = stopListEntityOptional .filter(TppStopListEntity::isBlocked) .map(sl -> { log.info("TPP ID: [{}]. TPP has been blocked, because it's in stop list", tppAuthorisationNumber); return true; }) .orElse(false); return CmsResponse.<Boolean>builder() .payload(blocked) .build(); }  @Override CmsResponse<Boolean> checkIfTppBlocked(String tppAuthorisationNumber, String instanceId);  }### Answer:
@Test void checkIfTppBlocked_Fail_EmptyStopList() { when(tppStopListRepository.findByTppAuthorisationNumberAndInstanceId(AUTHORISATION_NUMBER_NOT_EXISTING, INSTANCE_ID)) .thenReturn(Optional.empty()); CmsResponse<Boolean> isTppBlocked = tppStopListService.checkIfTppBlocked(AUTHORISATION_NUMBER_NOT_EXISTING, INSTANCE_ID); assertTrue(isTppBlocked.isSuccessful()); assertFalse(isTppBlocked.getPayload()); }
@Test void checkIfTppBlocked_Success_BlockedTpp() { when(tppStopListRepository.findByTppAuthorisationNumberAndInstanceId(AUTHORISATION_NUMBER, INSTANCE_ID)) .thenReturn(Optional.of(tppStopListEntity)); when(tppStopListEntity.isBlocked()) .thenReturn(false); CmsResponse<Boolean> isTppBlocked = tppStopListService.checkIfTppBlocked(AUTHORISATION_NUMBER, INSTANCE_ID); assertTrue(isTppBlocked.isSuccessful()); assertFalse(isTppBlocked.getPayload()); }
@Test void checkIfTppBlocked_Success_NonBlockedTpp() { when(tppStopListRepository.findByTppAuthorisationNumberAndInstanceId(AUTHORISATION_NUMBER_NOT_EXISTING, INSTANCE_ID)) .thenReturn(Optional.of(tppStopListEntity)); when(tppStopListEntity.isBlocked()) .thenReturn(true); CmsResponse<Boolean> isTppBlocked = tppStopListService.checkIfTppBlocked(AUTHORISATION_NUMBER_NOT_EXISTING, INSTANCE_ID); assertTrue(isTppBlocked.isSuccessful()); assertTrue(isTppBlocked.getPayload()); }