use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.
the class PostgreSQLTextNodeCommentTests method editTextNodeComment5.
@Test
public void editTextNodeComment5() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviTextNode textNode = setupTextNode();
final List<IComment> comments = textNode.getComments() == null ? new ArrayList<IComment>() : textNode.getComments();
final IComment lastComment = comments.size() == 0 ? null : Iterables.getLast(comments);
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final String commentText = " TEXT NODE COMMENT TEST BEFORE EDIT ";
final Integer commentId = getProvider().appendTextNodeComment(textNode, commentText, user.getUserId());
final IComment newComment = new CComment(commentId, user, lastComment, commentText);
final ArrayList<IComment> newComments = getProvider().loadCommentById(commentId);
assertNotNull(newComments);
assertEquals(comments.size() + 1, newComments.size());
assertEquals(newComment, Iterables.getLast(newComments));
final String commentAfterEdit = " TEXT NODE COMMENT TEST AFTER EDIT ";
getProvider().editTextNodeComment(textNode, commentId, user.getUserId(), commentAfterEdit);
final ArrayList<IComment> commentsAfterEdit = PostgreSQLCommentFunctions.loadCommentByCommentId(getProvider(), commentId);
assertEquals(commentAfterEdit, Iterables.getLast(commentsAfterEdit).getComment());
assertEquals(commentsAfterEdit.size(), newComments.size());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.
the class PostgreSQLTextNodeCommentTests method setupTextNode.
private INaviTextNode setupTextNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction("SetCommState");
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
final INaviCodeNode codeNode = view.getContent().getBasicBlocks().get(5);
final INaviTextNode textNode = view.getContent().createTextNode(null);
view.getContent().createEdge(codeNode, textNode, EdgeType.TEXTNODE_EDGE);
final ZyGraph graph = CGraphBuilder.buildGraph(view);
globalView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST TEXT NODE COMMENTS ", " TESTING TEXT NODE COMMENTS ");
INaviTextNode savedTextNode = null;
for (final INaviViewNode node : globalView.getGraph().getNodes()) {
if (node instanceof INaviTextNode) {
savedTextNode = (INaviTextNode) node;
}
}
return savedTextNode;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.
the class PostgreSQLTextNodeCommentTests method deleteTextNodeComment2.
@Test(expected = NullPointerException.class)
public void deleteTextNodeComment2() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviTextNode textNode = setupTextNode();
getProvider().deleteTextNodeComment(textNode, null, 1);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.
the class PostgreSQLTextNodeCommentTests method deleteTextNodeComment3.
@Test(expected = NullPointerException.class)
public void deleteTextNodeComment3() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviTextNode textNode = setupTextNode();
getProvider().deleteTextNodeComment(textNode, 1, null);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.
the class PostgreSQLTextNodeCommentTests method editTextNodeComment3.
@Test(expected = NullPointerException.class)
public void editTextNodeComment3() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviTextNode textNode = setupTextNode();
getProvider().editTextNodeComment(textNode, 1, null, "");
}
Aggregations