use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLUserFunctionsTests method testLoadUsers.
@Test
public void testLoadUsers() throws CouldntSaveDataException, CouldntLoadDataException {
final IUser user1 = CGenericSQLUserFunctions.addUser(getProvider(), "1");
final IUser user2 = CGenericSQLUserFunctions.addUser(getProvider(), "2");
final IUser user3 = CGenericSQLUserFunctions.addUser(getProvider(), "3");
final IUser user4 = CGenericSQLUserFunctions.addUser(getProvider(), "4");
final IUser user5 = CGenericSQLUserFunctions.addUser(getProvider(), "5");
final IUser user6 = CGenericSQLUserFunctions.addUser(getProvider(), "6");
final IUser user7 = CGenericSQLUserFunctions.addUser(getProvider(), "7");
final IUser user8 = CGenericSQLUserFunctions.addUser(getProvider(), "8");
final IUser user9 = CGenericSQLUserFunctions.addUser(getProvider(), "9");
final IUser user10 = CGenericSQLUserFunctions.addUser(getProvider(), "10");
final IUser user11 = CGenericSQLUserFunctions.addUser(getProvider(), "11");
final IUser user12 = CGenericSQLUserFunctions.addUser(getProvider(), "12");
final List<IUser> users = CGenericSQLUserFunctions.loadUsers(getProvider());
assertNotNull(users);
assertTrue(users.size() >= 12);
assertEquals(true, users.contains(user1));
assertEquals(true, users.contains(user2));
assertEquals(true, users.contains(user3));
assertEquals(true, users.contains(user4));
assertEquals(true, users.contains(user5));
assertEquals(true, users.contains(user6));
assertEquals(true, users.contains(user7));
assertEquals(true, users.contains(user8));
assertEquals(true, users.contains(user9));
assertEquals(true, users.contains(user10));
assertEquals(true, users.contains(user11));
assertEquals(true, users.contains(user12));
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLSectionCommentTests method deleteSectionComment6.
/**
* This test checks if the delete of a comment in a series of comments works if the comment is the
* last comment.
*
* <pre>
* Comment 1: Comment 1:
* Comment 2: -> Comment 2:
* Comment 3:
* </pre>
*/
@Test
public void deleteSectionComment6() throws CouldntSaveDataException, CouldntLoadDataException, CouldntDeleteException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> storedComments = section.getComments() == null ? new ArrayList<IComment>() : section.getComments();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String comment1String = " Comment 1: ";
final int comment1Id = getProvider().appendSectionComment(section.getModule().getConfiguration().getId(), section.getId(), comment1String, user.getUserId());
final IComment comment1 = new CComment(comment1Id, user, lastComment, comment1String);
final String comment2String = " Comment 2: ";
final int comment2Id = getProvider().appendSectionComment(section.getModule().getConfiguration().getId(), section.getId(), comment2String, user.getUserId());
final IComment comment2 = new CComment(comment2Id, user, comment1, comment2String);
final String comment3String = " Comment 3: ";
final int comment3Id = getProvider().appendSectionComment(section.getModule().getConfiguration().getId(), section.getId(), comment3String, user.getUserId());
final IComment comment3 = new CComment(comment3Id, user, comment2, comment3String);
final ArrayList<IComment> commentsBeforeDelete = getProvider().loadCommentById(comment3Id);
assertNotNull(commentsBeforeDelete);
assertEquals(storedComments.size() + 3, commentsBeforeDelete.size());
assertTrue(commentsBeforeDelete.contains(comment1));
assertTrue(commentsBeforeDelete.contains(comment2));
assertTrue(commentsBeforeDelete.contains(comment3));
assertEquals(comment3, Iterables.getLast(commentsBeforeDelete));
assertEquals(comment2, commentsBeforeDelete.get(commentsBeforeDelete.size() - 2));
assertEquals(comment1, commentsBeforeDelete.get(commentsBeforeDelete.size() - 3));
getProvider().deleteSectionComment(section.getModule().getConfiguration().getId(), section.getId(), comment3Id, user.getUserId());
final ArrayList<IComment> commentsAfterDelete1 = getProvider().loadCommentById(comment3Id);
assertNotNull(commentsAfterDelete1);
assertTrue(commentsAfterDelete1.isEmpty());
final ArrayList<IComment> commentsAfterDelete2 = getProvider().loadCommentById(comment2Id);
assertNotNull(commentsAfterDelete2);
assertEquals(storedComments.size() + 2, commentsAfterDelete2.size());
assertTrue(commentsAfterDelete2.contains(comment2));
assertTrue(commentsAfterDelete2.contains(comment1));
assertEquals(comment2, Iterables.getLast(commentsAfterDelete2));
assertEquals(comment1, commentsAfterDelete2.get(commentsAfterDelete2.size() - 2));
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLSectionCommentTests method appendSectionComment3.
@Test(expected = NullPointerException.class)
public void appendSectionComment3() throws CouldntSaveDataException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
getProvider().appendSectionComment(1, 1, null, user.getUserId());
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLSectionCommentTests method deleteSectionComment8.
/**
* This test checks if the delete of a comment in a series of comments works if the comment is the
* first comment.
*
* <pre>
* Comment 1:
* Comment 2: -> Comment 2:
* Comment 3: Comment 3:
* </pre>
*/
@Test
public void deleteSectionComment8() throws CouldntSaveDataException, CouldntDeleteException, CouldntLoadDataException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> storedComments = section.getComments() == null ? new ArrayList<IComment>() : section.getComments();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String comment1String = " Comment 1: ";
final int comment1Id = getProvider().appendSectionComment(section.getModule().getConfiguration().getId(), section.getId(), comment1String, user.getUserId());
final IComment comment1 = new CComment(comment1Id, user, lastComment, comment1String);
final String comment2String = " Comment 2: ";
final int comment2Id = getProvider().appendSectionComment(section.getModule().getConfiguration().getId(), section.getId(), comment2String, user.getUserId());
final IComment comment2 = new CComment(comment2Id, user, comment1, comment2String);
final String comment3String = " Comment 3: ";
final int comment3Id = getProvider().appendSectionComment(section.getModule().getConfiguration().getId(), section.getId(), comment3String, user.getUserId());
final IComment comment3 = new CComment(comment3Id, user, comment2, comment3String);
final ArrayList<IComment> commentsBeforeDelete = getProvider().loadCommentById(comment3Id);
assertNotNull(commentsBeforeDelete);
assertEquals(storedComments.size() + 3, commentsBeforeDelete.size());
assertTrue(commentsBeforeDelete.contains(comment1));
assertTrue(commentsBeforeDelete.contains(comment2));
assertTrue(commentsBeforeDelete.contains(comment3));
assertEquals(comment3, Iterables.getLast(commentsBeforeDelete));
assertEquals(comment2, commentsBeforeDelete.get(commentsBeforeDelete.size() - 2));
assertEquals(comment1, commentsBeforeDelete.get(commentsBeforeDelete.size() - 3));
getProvider().deleteSectionComment(section.getModule().getConfiguration().getId(), section.getId(), comment1Id, user.getUserId());
final ArrayList<IComment> commentsAfterDelete1 = getProvider().loadCommentById(comment1Id);
assertNotNull(commentsAfterDelete1);
assertTrue(commentsAfterDelete1.isEmpty());
final ArrayList<IComment> commentsAfterDelete2 = getProvider().loadCommentById(comment3Id);
final IComment comment2AfterDelete = new CComment(comment2Id, user, lastComment, comment2String);
final IComment comment3AfterDelete = new CComment(comment3Id, user, comment2AfterDelete, comment3String);
assertNotNull(commentsAfterDelete2);
assertEquals(storedComments.size() + 2, commentsAfterDelete2.size());
assertTrue(commentsAfterDelete2.contains(comment3AfterDelete));
assertTrue(commentsAfterDelete2.contains(comment2AfterDelete));
assertEquals(comment3AfterDelete, Iterables.getLast(commentsAfterDelete2));
assertEquals(comment2AfterDelete, commentsAfterDelete2.get(commentsAfterDelete2.size() - 2));
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLSectionCommentTests method appendSectionComment6.
@Test
public void appendSectionComment6() throws CouldntSaveDataException, CouldntLoadDataException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final java.util.List<IComment> storedComments = section.getComments() == null ? new ArrayList<IComment>() : section.getComments();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String firstCommentString = " PASS SECTION COMMENT 1 ";
final int firstCommentId = getProvider().appendSectionComment(section.getModule().getConfiguration().getId(), section.getId(), firstCommentString, user.getUserId());
final IComment firstComment = new CComment(firstCommentId, user, lastComment, firstCommentString);
final String secondCommentString = " PASS SECTION COMMENT 2 ";
final int secondCommentId = getProvider().appendSectionComment(section.getModule().getConfiguration().getId(), section.getId(), secondCommentString, user.getUserId());
final IComment secondComment = new CComment(secondCommentId, user, firstComment, secondCommentString);
final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(secondCommentId);
assertNotNull(commentsFromDatabase);
assertEquals(storedComments.size() + 2, commentsFromDatabase.size());
assertTrue(commentsFromDatabase.contains(firstComment));
assertTrue(commentsFromDatabase.contains(secondComment));
}
Aggregations