use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLLocalCodeNodeCommentTests method appendLocalCodeNodeComment5.
@Test
public void appendLocalCodeNodeComment5() throws CouldntLoadDataException, CouldntSaveDataException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> storedComments = codeNode.getComments().getLocalCodeNodeComment() == null ? new ArrayList<IComment>() : codeNode.getComments().getLocalCodeNodeComment();
final int numberOfComments = storedComments.size();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String firstCommentString = " PASS LOCAL CODE NODE COMMENT 1 ";
final int firstCommentId = getProvider().appendLocalCodeNodeComment(codeNode, firstCommentString, user.getUserId());
final IComment firstComment = new CComment(firstCommentId, user, lastComment, firstCommentString);
final String secondCommentString = " PASS LOCAL CODE NODE COMMENT 2 ";
final int secondCommentId = getProvider().appendLocalCodeNodeComment(codeNode, secondCommentString, user.getUserId());
final IComment secondComment = new CComment(secondCommentId, user, firstComment, secondCommentString);
final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(secondCommentId);
assertNotNull(commentsFromDatabase);
assertEquals(numberOfComments + 2, commentsFromDatabase.size());
assertTrue(commentsFromDatabase.contains(firstComment));
assertTrue(commentsFromDatabase.contains(secondComment));
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLLocalCodeNodeCommentTests method appendLocalCodeNodeComment4.
@Test
public void appendLocalCodeNodeComment4() throws CouldntSaveDataException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
getProvider().appendLocalCodeNodeComment(codeNode, " PASS LOCAL CODE NODE COMMENT ", user.getUserId());
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLLocalCodeNodeCommentTests method deleteLocalCodeNodeComment7.
/**
* 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 deleteLocalCodeNodeComment7() throws CouldntLoadDataException, CouldntSaveDataException, CouldntDeleteException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> storedComments = codeNode.getComments().getLocalCodeNodeComment() == null ? new ArrayList<IComment>() : codeNode.getComments().getLocalCodeNodeComment();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String comment1String = " Comment 1: ";
final int comment1Id = getProvider().appendLocalCodeNodeComment(codeNode, comment1String, user.getUserId());
final IComment comment1 = new CComment(comment1Id, user, lastComment, comment1String);
final String comment2String = " Comment 2: ";
final int comment2Id = getProvider().appendLocalCodeNodeComment(codeNode, comment2String, user.getUserId());
final IComment comment2 = new CComment(comment2Id, user, comment1, comment2String);
final String comment3String = " Comment 3: ";
final int comment3Id = getProvider().appendLocalCodeNodeComment(codeNode, 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().deleteLocalCodeNodeComment(codeNode, 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 PostgreSQLUserFunctionsTests method testEditUser.
@Test
public void testEditUser() throws CouldntSaveDataException {
final IUser user = CGenericSQLUserFunctions.addUser(getProvider(), "TEST USER FOR EDIT TEST BEFORE EDIT");
assertNotNull(user);
assertEquals("TEST USER FOR EDIT TEST BEFORE EDIT", user.getUserName());
assertNotNull(user.getUserId());
final IUser newUser = CGenericSQLUserFunctions.editUserName(getProvider(), user, "TEST USER FOR EDIT TEST AFTER EDIT");
assertNotNull(newUser);
assertEquals(user.getUserId(), newUser.getUserId());
assertEquals("TEST USER FOR EDIT TEST AFTER EDIT", newUser.getUserName());
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLUserFunctionsTests method testAddUser.
@Test
public void testAddUser() throws CouldntSaveDataException {
final IUser user = CGenericSQLUserFunctions.addUser(getProvider(), "TEST USER FOR INSERT TEST");
assertNotNull(user);
assertEquals("TEST USER FOR INSERT TEST", user.getUserName());
assertNotNull(user.getUserId());
}
Aggregations