private static void checkFileIndex(Path relativePath, byte[] md5Hash) throws GetFailedException,
NoSessionException {
UserProfile userProfileA = nodeA.getSession().getProfileManager()
.getUserProfile(UUID.randomUUID().toString(), false);
FileIndex indexA = (FileIndex) userProfileA.getFileByPath(relativePath);
UserProfile userProfileB = nodeB.getSession().getProfileManager()
.getUserProfile(UUID.randomUUID().toString(), false);
FileIndex indexB = (FileIndex) userProfileB.getFileByPath(relativePath);
// check if index is file
Assert.assertTrue(indexA.isFile());
Assert.assertTrue(indexB.isFile());
// check if isShared flag is set
Assert.assertTrue(indexA.isShared());
Assert.assertTrue(indexB.isShared());
// check write access
Assert.assertTrue(indexA.canWrite());
// user B isn't allowed to write
Assert.assertFalse(indexB.canWrite());
// check if md5 hash is the same
Assert.assertTrue(Arrays.equals(indexA.getMD5(), md5Hash));
Assert.assertTrue(Arrays.equals(indexB.getMD5(), md5Hash));
// check if userA's content protection keys are other ones
Assert.assertFalse(indexA.getProtectionKeys().getPrivate()
.equals(userProfileA.getProtectionKeys().getPrivate()));
Assert.assertFalse(indexA.getProtectionKeys().getPublic()
.equals(userProfileA.getProtectionKeys().getPublic()));
// check if user B has no content protection keys
Assert.assertNull(indexB.getProtectionKeys());
// check user permissions at A
Set<String> usersA = indexA.getCalculatedUserList();
Assert.assertEquals(2, usersA.size());
Assert.assertTrue(usersA.contains(userA.getUserId()));
Assert.assertTrue(usersA.contains(userB.getUserId()));
// check user permissions at A
Set<String> usersB = indexB.getCalculatedUserList();
Assert.assertEquals(2, usersB.size());
Assert.assertTrue(usersB.contains(userA.getUserId()));
Assert.assertTrue(usersB.contains(userB.getUserId()));
}