protected void mockUserDatabase(String userId, UaaUser user) { userDatabase = Mockito.mock(UaaUserDatabase.class); Mockito.when(userDatabase.retrieveUserById(Matchers.eq(userId))).thenReturn(user); Mockito.when(userDatabase.retrieveUserById(AdditionalMatchers.not(Matchers.eq(userId)))) .thenThrow(new UsernameNotFoundException("mock")); tokenServices.setUserDatabase(userDatabase); }
@Test public void testDeliverGCRefresh() throws Exception { // setup GCIdSet idSet = mock(GCIdSet.class); when(idSet.numElements()).thenReturn(1); GCId id = mock(GCId.class); when(idSet.asArray()).thenReturn(new GCId[] {id}); message = new GCRefreshMessage(0, idSet, null, null); // act koalaGCPastImpl.deliver(null, message); // assert verify(continuation).receiveResult(AdditionalMatchers.aryEq(new Boolean[] {Boolean.TRUE})); verify(storageManager, never()).exists((Id) anyObject()); }