/** Test of execute method, of class CollectAccountsClosure. */ @Test public void testExecute_isAccount() { // set up test data final QueryResult input = new QueryResult(); final Account account = new Account(); account.setName("Hello"); input.setEntities(Arrays.asList(new Account[] {account})); final Map<String, Account> accountsByName = new HashMap<>(); final Map<String, Item> itemsByName = new HashMap<>(); final Map<String, Department> departmentsByName = new HashMap<>(); // set up mocks final Logger logger = mock(Logger.class); // invoke method under test final CollectLookupValuesClosure collectLookupValuesClosure = new CollectLookupValuesClosure(accountsByName, itemsByName, departmentsByName, logger); collectLookupValuesClosure.execute(input); // assertions assertEquals(accountsByName.get(account.getName()), account); // verificaitons verifyZeroInteractions(logger); }
/** Test of execute method, of class CollectAccountsClosure. */ @Test public void testExecute_notAccount() { // set up test data final QueryResult input = new QueryResult(); final Customer customer = new Customer(); input.setEntities(Arrays.asList(new Customer[] {customer})); final Map<String, Account> accountsByName = new HashMap<>(); final Map<String, Item> itemsByName = new HashMap<>(); final Map<String, Department> departmentsByName = new HashMap<>(); // set up mocks final Logger logger = mock(Logger.class); // invoke method under test final CollectLookupValuesClosure collectAccountsClosure = new CollectLookupValuesClosure(accountsByName, itemsByName, departmentsByName, logger); collectAccountsClosure.execute(input); // assertions assertTrue(accountsByName.isEmpty()); // verificaitons verify(logger, times(1)).warn(anyString(), any(Customer.class)); }