コード例 #1
0
ファイル: VistaUserMapTest.java プロジェクト: montge/eHMP
 private VistaUserDetails createUser(
     String duz, String vistaId, String division, String access, String verify) {
   VistaUserDetails user = mock(VistaUserDetails.class);
   when(user.getDUZ()).thenReturn(duz);
   when(user.getVistaId()).thenReturn(vistaId);
   when(user.getDivision()).thenReturn(division);
   when(user.getPassword()).thenReturn(access + ";" + verify);
   return user;
 }
コード例 #2
0
 protected VistaUserDetails createUser(
     String vistaId,
     String division,
     String duz,
     String password,
     boolean nonExpired,
     boolean nonLocked,
     boolean credentialsNonExpired,
     boolean enabled,
     GrantedAuthority... authorities) {
   VistaUserDetails user = mock(VistaUserDetails.class);
   when(user.getVistaId()).thenReturn(vistaId);
   when(user.getDivision()).thenReturn(division);
   when(user.getDUZ()).thenReturn(duz);
   when(user.isAccountNonExpired()).thenReturn(nonExpired);
   when(user.isAccountNonLocked()).thenReturn(nonLocked);
   when(user.isCredentialsNonExpired()).thenReturn(credentialsNonExpired);
   when(user.isEnabled()).thenReturn(enabled);
   when(user.getUsername()).thenReturn(duz + "@" + vistaId + ";" + division);
   when(user.getPassword()).thenReturn(password);
   if (password != null) {
     String[] pieces = password.split("\\)");
     String[] credentialsPieces = pieces[1].split(";");
     if (credentialsPieces.length == 2) {
       String accessCode = credentialsPieces[0];
       String verifyCode = credentialsPieces[1];
       when(user.getCredentials()).thenReturn(division + ":" + accessCode + ";" + verifyCode);
     } else if (credentialsPieces.length == 1) {
       String appHandle = credentialsPieces[0];
       when(user.getCredentials()).thenReturn(division + ":" + appHandle);
     }
   }
   when(user.getAuthorities()).thenReturn((Collection) Arrays.asList(authorities));
   return user;
 }