byte[] notHashedUserIdAndPassword = new byte[] {2, 3};
byte[] hashedOnceUserIdAndPassword = new byte[] {3, 4};
byte[] iv = new byte[] {5, 6};
SecretKey wrappingKey = new SecretKeySpec(new byte[] {5, 6}, "AES");
Account account = em.find(Account.class, userId);
expect(mockCryptoEngine.stringToBytes(userId + masterPassword)).andStubReturn(notHashedUserIdAndPassword);
expect(mockCryptoEngine.hash(aryEq(notHashedUserIdAndPassword))).andStubReturn(hashedOnceUserIdAndPassword);
expect(mockCryptoEngine.hash(aryEq(hashedOnceUserIdAndPassword))).andStubReturn(account.getMasterPassword());
expect(mockCryptoEngine.bytesToSecretKey(aryEq(hashedOnceUserIdAndPassword))).andReturn(wrappingKey);
expect(mockCryptoEngine.buildInitializationVector(aryEq(wrappingKey.getEncoded()))).andReturn(iv);
expect(mockCryptoEngine.decrypt(aryEq(account.getEncryptedSecretKey()), same(wrappingKey), aryEq(iv))).andReturn(encryptionKey);
expect(mockCryptoEngine.bytesToSecretKey(encryptionKey)).andReturn(secretKey);
replay(mockCryptoEngine);
UserInformation loginUserInformation = impl.login(userId, masterPassword);