@Test public final void testLookupNull() throws NamingException { context.checking(new Expectations() { { oneOf(primaryMock).findPeople("searchString", 0); will(returnValue(null)); oneOf(secondaryMock).findPeople("searchString", 0); will(returnValue(null)); } }); sut.findPeople("searchString", 0); context.assertIsSatisfied(); }
public List<Person> findPeople(final String searchString, final int searchLimit) { List<Person> primaryList = primary.findPeople(searchString, searchLimit); List<Person> secondaryList = secondary.findPeople(searchString, searchLimit); HashMap<String, Person> personMap = new HashMap<String, Person>(); if (null != primaryList) { for (Person p : primaryList) { personMap.put(p.getAccountId(), p); } } if (null != secondaryList) { for (Person p : secondaryList) { if (!(personMap.containsKey(p.getAccountId()))) { personMap.put(p.getAccountId(), p); } } } List<Person> mergedList = new ArrayList<Person>(); mergedList.addAll(personMap.values()); return mergedList; }
MultiSourcePersonLookup implements PersonLookupStrategy { public List<Person> findPeople(final String searchString, final int searchLimit) { List<Person> primaryList = primary.findPeople(searchString, searchLimit); List<Person> secondaryList = secondary.findPeople(searchString, searchLimit); HashMap<String, Person> personMap = new HashMap<String, Person>(); if (null != primaryList) { for (Person p : primaryList) { personMap.put(p.getAccountId(), p); } } if (null != secondaryList) { for (Person p : secondaryList) { if (!(personMap.containsKey(p.getAccountId()))) { personMap.put(p.getAccountId(), p); } } } List<Person> mergedList = new ArrayList<Person>(); mergedList.addAll(personMap.values()); return mergedList; } }
MultiSourcePersonLookup implements PersonLookupStrategy { public List<Person> findPeople(final String searchString, final int searchLimit) { List<Person> primaryList = primary.findPeople(searchString, searchLimit); List<Person> secondaryList = secondary.findPeople(searchString, searchLimit); HashMap<String, Person> personMap = new HashMap<String, Person>(); if (null != primaryList) { for (Person p : primaryList) { personMap.put(p.getAccountId(), p); } } if (null != secondaryList) { for (Person p : secondaryList) { if (!(personMap.containsKey(p.getAccountId()))) { personMap.put(p.getAccountId(), p); } } } List<Person> mergedList = new ArrayList<Person>(); mergedList.addAll(personMap.values()); return mergedList; } MultiSourcePersonLookup(final PersonLookupStrategy inPrimary, final PersonLookupStrategy inSecondary); }
MultiSourcePersonLookup implements PersonLookupStrategy { public List<Person> findPeople(final String searchString, final int searchLimit) { List<Person> primaryList = primary.findPeople(searchString, searchLimit); List<Person> secondaryList = secondary.findPeople(searchString, searchLimit); HashMap<String, Person> personMap = new HashMap<String, Person>(); if (null != primaryList) { for (Person p : primaryList) { personMap.put(p.getAccountId(), p); } } if (null != secondaryList) { for (Person p : secondaryList) { if (!(personMap.containsKey(p.getAccountId()))) { personMap.put(p.getAccountId(), p); } } } List<Person> mergedList = new ArrayList<Person>(); mergedList.addAll(personMap.values()); return mergedList; } MultiSourcePersonLookup(final PersonLookupStrategy inPrimary, final PersonLookupStrategy inSecondary); List<Person> findPeople(final String searchString, final int searchLimit); }
MultiSourcePersonLookup implements PersonLookupStrategy { public List<Person> findPeople(final String searchString, final int searchLimit) { List<Person> primaryList = primary.findPeople(searchString, searchLimit); List<Person> secondaryList = secondary.findPeople(searchString, searchLimit); HashMap<String, Person> personMap = new HashMap<String, Person>(); if (null != primaryList) { for (Person p : primaryList) { personMap.put(p.getAccountId(), p); } } if (null != secondaryList) { for (Person p : secondaryList) { if (!(personMap.containsKey(p.getAccountId()))) { personMap.put(p.getAccountId(), p); } } } List<Person> mergedList = new ArrayList<Person>(); mergedList.addAll(personMap.values()); return mergedList; } MultiSourcePersonLookup(final PersonLookupStrategy inPrimary, final PersonLookupStrategy inSecondary); List<Person> findPeople(final String searchString, final int searchLimit);  }