AggregationService { protected Set<II> removeDuplicates(List<II> iiArray) { Set<ComparableII> comparableIISet = new HashSet<>(); for (II ii : iiArray) { comparableIISet.add(new ComparableII(ii)); } Set<II> iiSet = new HashSet<>(); for (ComparableII comparableII : comparableIISet) { iiSet.add(comparableII.getII()); } return iiSet; } AggregationService(ExchangeManager exchangeManager,
        PatientCorrelationProxyFactory patientCorrelationProxyFactory, PixRetrieveBuilder pixRetrieveBuilder,
        StandardOutboundDocQueryHelper standardOutboundDocQueryHelper, TransactionLogger transactionLogger);  AggregationService(); List<OutboundOrchestratable> createChildRequests(AdhocQueryRequest adhocQueryRequest,
        AssertionType assertion, NhinTargetCommunitiesType targets);  }
@Test public void ensureNoDuplicates() { II id1 = new II(); id1.setRoot("1.1"); id1.setExtension("patientId"); id1.setAssigningAuthorityName("AA"); II id2 = new II(); id2.setRoot("1.1"); id2.setExtension("patientId"); id2.setAssigningAuthorityName("AA"); II[] idArray = new II[2]; idArray[0] = id1; idArray[1] = id2; TransactionLogger transactionLogger = mock(TransactionLogger.class); AggregationService service = new AggregationService(ExchangeManager.getInstance(), new PatientCorrelationProxyObjectFactory(), new PixRetrieveBuilder(), new StandardOutboundDocQueryHelper(), transactionLogger); Set<II> idSet = service.removeDuplicates(java.util.Arrays.asList(idArray)); assertEquals(1, idSet.size()); II[] noDupesArray = idSet.toArray(new II[0]); assertEquals(id1.getAssigningAuthorityName(), noDupesArray[0].getAssigningAuthorityName()); assertEquals(id1.getExtension(), noDupesArray[0].getExtension()); assertEquals(id1.getRoot(), noDupesArray[0].getRoot()); assertEquals(id1.isDisplayable(), noDupesArray[0].isDisplayable()); }