Source:
public void testInsertingBankItem() throws AuthenticationException, DatabaseAccessException, NoSuchAlgorithmException { final String courseId = "COURSE_ID"; identityManager.createNewItem(TEACHER_USER_ID, TEACHER_AUTH_ID, VALID_ITEM_ID, School.ItemType.BANK_PROBLEM, courseId, null); final DBObject dbItemObject = db.getCollection(getCollectionFromType(School.ItemType.BANK_PROBLEM)).findOne(new ObjectId(VALID_ITEM_ID)); Assert.assertEquals(VALID_ITEM_ID, dbItemObject.get(DatabaseStringConstants.PROBLEM_BANK_ID).toString()); Assert.assertEquals(TEACHER_USER_ID, dbItemObject.get(DatabaseStringConstants.OWNER_ID).toString()); final DBCursor cursor = db.getCollection(DatabaseStringConstants.USER_GROUP_COLLECTION).find(); final DBObject dbObject = cursor.next(); System.out.println(dbObject); Assert.assertEquals(VALID_ITEM_ID, dbObject.get(DatabaseStringConstants.COURSE_ID).toString()); String salt = HashManager.generateUnSecureSalt(dbObject.get(DatabaseStringConstants.COURSE_ID).toString()); String teacherHash = null; String courseHash = null; try { teacherHash = HashManager.toHex(HashManager.createHash(TEACHER_USER_ID, salt).getBytes()); courseHash = HashManager.toHex(HashManager.createHash(courseId, salt).getBytes()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (AuthenticationException e) { e.printStackTrace(); } DBObject nonUsers = new BasicDBObject(); nonUsers.put(TEACHER_USER_ID, teacherHash); DBObject adminGroup = ((DBObject) dbObject.get(DatabaseStringConstants.NON_USER_LIST)); Assert.assertEquals(nonUsers, adminGroup); DBObject students = new BasicDBObject(); students.put(courseId, courseHash); DBObject studentGroup = (DBObject) dbObject.get(DatabaseStringConstants.USER_LIST); Assert.assertEquals(students, studentGroup); }

Target:
public void testInsertingBankItem() throws AuthenticationException, DatabaseAccessException, NoSuchAlgorithmException { final String courseId = "COURSE_ID"; identityManager.createNewItem(TEACHER_USER_ID, TEACHER_AUTH_ID, VALID_ITEM_ID, School.ItemType.BANK_PROBLEM, courseId, null); final DBObject dbItemObject = db.getCollection(getCollectionFromType(School.ItemType.BANK_PROBLEM)).findOne(new ObjectId(VALID_ITEM_ID)); Assert.assertEquals(VALID_ITEM_ID, dbItemObject.get(DatabaseStringConstants.PROBLEM_BANK_ID).toString()); Assert.assertEquals(TEACHER_USER_ID, dbItemObject.get(DatabaseStringConstants.OWNER_ID).toString()); final DBCursor cursor = db.getCollection(DatabaseStringConstants.USER_GROUP_COLLECTION).find(); final DBObject dbObject = cursor.next(); System.out.println(dbObject); Assert.assertEquals(VALID_ITEM_ID, dbObject.get(DatabaseStringConstants.COURSE_ID).toString()); String salt = HashManager.generateUnSecureSalt(dbObject.get(DatabaseStringConstants.COURSE_ID).toString()); String teacherHash = null; String courseHash = null; try { teacherHash = HashManager.toHex(HashManager.createHash(TEACHER_USER_ID, salt).getBytes()); courseHash = HashManager.toHex(HashManager.createHash(courseId, salt).getBytes()); } catch (NoSuchAlgorithmException | AuthenticationException e) { e.printStackTrace(); } DBObject nonUsers = new BasicDBObject(); nonUsers.put(TEACHER_USER_ID, teacherHash); DBObject adminGroup = ((DBObject) dbObject.get(DatabaseStringConstants.NON_USER_LIST)); Assert.assertEquals(nonUsers, adminGroup); DBObject students = new BasicDBObject(); students.put(courseId, courseHash); DBObject studentGroup = (DBObject) dbObject.get(DatabaseStringConstants.USER_LIST); Assert.assertEquals(students, studentGroup); }