GrantedTrustService implements TrustServicePredicate { @Override public boolean test(TSPServiceType trustedService) { if (trustedService != null) { TSPServiceInformationType serviceInformation = trustedService.getServiceInformation(); if (TrustedServiceStatus.isAcceptableStatusAfterEIDAS(serviceInformation.getServiceStatus()) || TrustedServiceStatus.isAcceptableStatusBeforeEIDAS(serviceInformation.getServiceStatus())) { return true; } ServiceHistoryType serviceHistory = trustedService.getServiceHistory(); if (serviceHistory !=null && Utils.isCollectionNotEmpty(serviceHistory.getServiceHistoryInstance())) { for (ServiceHistoryInstanceType serviceHistoryInstance : serviceHistory.getServiceHistoryInstance()) { if (TrustedServiceStatus.isAcceptableStatusAfterEIDAS(serviceHistoryInstance.getServiceStatus()) || TrustedServiceStatus.isAcceptableStatusBeforeEIDAS(serviceHistoryInstance.getServiceStatus())) { return true; } } } } return false; }  @Override boolean test(TSPServiceType trustedService);  }
@Test void test() throws Exception { TSPServiceType tspService = new TSPServiceType(); TSPServiceInformationType informationType = new TSPServiceInformationType(); GrantedTrustService selector = new GrantedTrustService(); tspService.setServiceInformation(informationType); informationType.setServiceStatus("http: assertTrue(selector.test(tspService)); informationType.setServiceStatus("http: assertTrue(selector.test(tspService)); informationType.setServiceStatus("http: assertTrue(selector.test(tspService)); informationType.setServiceStatus("http: assertTrue(selector.test(tspService)); informationType.setServiceStatus("http: assertFalse(selector.test(tspService)); assertFalse(selector.test(null)); informationType.setServiceStatus(null); assertFalse(selector.test(tspService)); assertFalse(selector.test(null)); ServiceHistoryType serviceHistory = new ServiceHistoryType(); tspService.setServiceHistory(serviceHistory); ServiceHistoryInstanceType historyInstance = new ServiceHistoryInstanceType(); historyInstance.setServiceStatus("http: serviceHistory.getServiceHistoryInstance().add(historyInstance); assertFalse(selector.test(tspService)); historyInstance.setServiceStatus("http: tspService.getServiceHistory().getServiceHistoryInstance().add(historyInstance); assertTrue(selector.test(tspService)); }