Mockito.when(clientDetailsEntityService.loadClientByClientId(pairwiseClientId4)).thenReturn(pairwiseClient4);
Mockito.when(userInfoRepository.getByUsername(regularUsername)).thenAnswer(new Answer<UserInfo>() {
@Override
public UserInfo answer(InvocationOnMock invocation) throws Throwable {
UserInfo userInfo = new DefaultUserInfo();
userInfo.setPreferredUsername(regularUsername);
userInfo.setSub(regularSub);
return userInfo;
}
});
Mockito.when(pairwiseIdentiferService.getIdentifier(userInfoRegular, pairwiseClient1)).thenReturn(pairwiseSub12);
Mockito.when(pairwiseIdentiferService.getIdentifier(userInfoRegular, pairwiseClient2)).thenReturn(pairwiseSub12);
Mockito.when(pairwiseIdentiferService.getIdentifier(userInfoRegular, pairwiseClient3)).thenReturn(pairwiseSub3);
Mockito.when(pairwiseIdentiferService.getIdentifier(userInfoRegular, pairwiseClient4)).thenReturn(pairwiseSub4);
UserInfo user1 = service.getByUsernameAndClientId(regularUsername, pairwiseClientId1);
UserInfo user2 = service.getByUsernameAndClientId(regularUsername, pairwiseClientId2);
UserInfo user3 = service.getByUsernameAndClientId(regularUsername, pairwiseClientId3);
UserInfo user4 = service.getByUsernameAndClientId(regularUsername, pairwiseClientId4);
assertEquals(pairwiseSub12, user1.getSub());
assertEquals(pairwiseSub12, user2.getSub());
assertEquals(pairwiseSub3, user3.getSub());
assertEquals(pairwiseSub4, user4.getSub());
}