ViolationNode extends AbstractReportNode { @Override public boolean equalsNode(AbstractReportNode arg0) { if (!(arg0 instanceof ViolationNode)) { return false; } RuleViolation rv = ((ViolationNode) arg0).getRuleViolation(); return rv.getFilename().equals(getRuleViolation().getFilename()) && rv.getBeginLine() == getRuleViolation().getBeginLine() && rv.getBeginColumn() == getRuleViolation().getBeginColumn() && rv.getEndLine() == getRuleViolation().getEndLine() && rv.getEndColumn() == getRuleViolation().getEndColumn() && rv.getVariableName().equals(getRuleViolation().getVariableName()); } ViolationNode(RuleViolation violation); RuleViolation getRuleViolation(); @Override boolean equalsNode(AbstractReportNode arg0);  }
@Test public void testEqualsNodeWithTwoEqualViolations() { final ViolationNode node1 = createViolationNode("Foo.java", 1, 1, 5, 15, ""); final ViolationNode node2 = createViolationNode("Foo.java", 1, 1, 5, 15, ""); assertTrue("Two equal violations should result in equal nodes", node1.equalsNode(node2)); }
@Test public void testEqualsNodeWithTwoDifferentViolationsDifferentFilename() { final ViolationNode node1 = createViolationNode("Foo.java", 1, 1, 5, 15, ""); final ViolationNode node2 = createViolationNode("Bar.java", 1, 1, 5, 15, ""); assertFalse("Two violations with different filename should result in not equal nodes", node1.equalsNode(node2)); }
@Test public void testEqualsNodeWithTwoDifferentViolationsDifferentBeginLine() { final ViolationNode node1 = createViolationNode("Foo.java", 1, 2, 5, 15, ""); final ViolationNode node2 = createViolationNode("Foo.java", 2, 2, 5, 15, ""); assertFalse("Two violations with different beginLine should result in not equal nodes", node1.equalsNode(node2)); }
@Test public void testEqualsNodeWithTwoDifferentViolationsDifferentEndLine() { final ViolationNode node1 = createViolationNode("Foo.java", 1, 1, 5, 15, ""); final ViolationNode node2 = createViolationNode("Foo.java", 1, 2, 5, 15, ""); assertFalse("Two violations with different endLine should result in not equal nodes", node1.equalsNode(node2)); }
@Test public void testEqualsNodeWithTwoDifferentViolationsDifferentBeginColumn() { final ViolationNode node1 = createViolationNode("Foo.java", 1, 1, 5, 15, ""); final ViolationNode node2 = createViolationNode("Foo.java", 1, 1, 7, 15, ""); assertFalse("Two violations with different beginColumn should result in not equal nodes", node1.equalsNode(node2)); }
@Test public void testEqualsNodeWithTwoDifferentViolationsDifferentEndColumn() { final ViolationNode node1 = createViolationNode("Foo.java", 1, 1, 5, 15, ""); final ViolationNode node2 = createViolationNode("Foo.java", 1, 1, 5, 17, ""); assertFalse("Two violations with different end column should result in not equal nodes", node1.equalsNode(node2)); }
@Test public void testEqualsNodeWithTwoDifferentViolationsDifferentVariableName() { final ViolationNode node1 = createViolationNode("Foo.java", 1, 1, 5, 15, "a"); final ViolationNode node2 = createViolationNode("Foo.java", 1, 1, 5, 15, "b"); assertFalse("Two violations with different variableName should result in not equal nodes", node1.equalsNode(node2)); }