IOException, NoPeerConnectionException {
NetworkManager putter = network.get(0); // where the process runs
NetworkManager client = network.get(1); // where the user profile is stored
// create the needed objects
UserCredentials credentials = NetworkTestUtil.generateRandomCredentials();
UserProfile testProfile = new UserProfile(credentials.getUserId());
IConsumeUserProfile context = new ConsumeProfileContext(testProfile);
// initialize the process and the one and only step to test
PutUserProfileStep step = new PutUserProfileStep(credentials, context, putter.getDataManager());
UseCaseTestUtil.executeProcess(step);
// get the user profile which should be stored at the proxy
FutureGet global = client.getDataManager().getUnblocked(
new Parameters().setLocationKey(credentials.getProfileLocationKey()).setContentKey(
H2HConstants.USER_PROFILE));
global.awaitUninterruptibly();
global.getFutureRequests().awaitUninterruptibly();
EncryptedNetworkContent found = (EncryptedNetworkContent) global.getData().object();
Assert.assertNotNull(found);
// decrypt it using the same password as set above
SecretKey decryptionKeys = PasswordUtil.generateAESKeyFromPassword(credentials.getPassword(),
credentials.getPin(), H2HConstants.KEYLENGTH_USER_PROFILE);
UserProfile decrypted = (UserProfile) H2HEncryptionUtil.decryptAES(found, decryptionKeys);
// verify if both objects are the same
Assert.assertEquals(credentials.getUserId(), decrypted.getUserId());
}