Skip to content

Commit

Permalink
+ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kniazkov committed Nov 2, 2024
1 parent 6368a13 commit 0a25bba
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,36 @@ void testsTwoCompletelyDifferentNodes() {
final Map<Node, Node> replaced = mapping.getReplaced();
Assertions.assertEquals(1, replaced.size());
}

@Test
void testInsertedFirstWhileSecondHasActions() {
final Node first = DraftNode.create("X(A(X),D,E)");
final Node second = DraftNode.create("X(B,A(Y),D,E)");
final Mapper mapper = TopDownMapper.INSTANCE;
final Mapping mapping = mapper.map(first, second);
final Set<Insertion> inserted = mapping.getInserted();
Assertions.assertEquals(1, inserted.size());
Assertions.assertEquals("B", inserted.iterator().next().getNode().getTypeName());
final Map<Node, Node> replaced = mapping.getReplaced();
Assertions.assertEquals(1, replaced.size());
final Map.Entry<Node, Node> entry = replaced.entrySet().iterator().next();
Assertions.assertEquals("X", entry.getKey().getTypeName());
Assertions.assertEquals("Y", entry.getValue().getTypeName());
}

@Test
void testDeletedFirstWhileSecondHasActions() {
final Node first = DraftNode.create("X(B,A(X),D,E)");
final Node second = DraftNode.create("X(A(Y),D,E)");
final Mapper mapper = TopDownMapper.INSTANCE;
final Mapping mapping = mapper.map(first, second);
final Set<Node> deleted = mapping.getDeleted();
Assertions.assertEquals(1, deleted.size());
Assertions.assertEquals("B", deleted.iterator().next().getTypeName());
final Map<Node, Node> replaced = mapping.getReplaced();
Assertions.assertEquals(1, replaced.size());
final Map.Entry<Node, Node> entry = replaced.entrySet().iterator().next();
Assertions.assertEquals("X", entry.getKey().getTypeName());
Assertions.assertEquals("Y", entry.getValue().getTypeName());
}
}

0 comments on commit 0a25bba

Please sign in to comment.