/** * Tests looking up users and merging. * * @throws NamingException not expected */ @Test public final void testLookup() throws NamingException { final List<Person> primaryList = new ArrayList<Person>(); final List<Person> secondaryList = new ArrayList<Person>(); primaryList.add(new Person("lastf", "Primary", "M", "Last", "F")); primaryList.add(new Person("other", "other", "M", "Last", "F")); secondaryList.add(new Person("lastf", "Secondar", "M", "Last", "F")); context.checking( new Expectations() { { oneOf(primaryMock).findPeople("searchString", 0); will(returnValue(primaryList)); oneOf(secondaryMock).findPeople("searchString", 0); will(returnValue(secondaryList)); } }); List<Person> results = sut.findPeople("searchString", 0); assertEquals(2, results.size()); context.assertIsSatisfied(); }
/** * Tests looking up users with primary and secondary returning null. * * @throws NamingException not expected */ @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(); }