Skip to content

Commit

Permalink
Fix unit tests for MappingsTraverser
Browse files Browse the repository at this point in the history
Signed-off-by: Megha Goyal <[email protected]>
  • Loading branch information
goyamegh committed Nov 29, 2023
1 parent b651811 commit 6ad9519
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,21 @@ public void testTraverseInvalidMappings() {
MappingMetadata mappingMetadata = new MappingMetadata(MapperService.SINGLE_MAPPING_NAME, root);

MappingsTraverser mappingsTraverser = new MappingsTraverser(mappingMetadata);
final boolean[] errorHappend = new boolean[1];
List<String> paths = new ArrayList<>();
mappingsTraverser.addListener(new MappingsTraverser.MappingsTraverserListener() {
@Override
public void onLeafVisited(MappingsTraverser.Node node) {
assertNotNull(node);
paths.add(node.currentPath);
}

@Override
public void onError(String error) {
errorHappend[0] = true;
fail("Failed traversing invalid mappings");
}
});
mappingsTraverser.traverse();
assertTrue(errorHappend[0]);
assertEquals(0, paths.size());
}

public void testTraverseEmptyMappings() {
Expand All @@ -162,19 +163,22 @@ public void testTraverseEmptyMappings() {

MappingsTraverser mappingsTraverser = new MappingsTraverser(mappingMetadata);
final boolean[] errorHappend = new boolean[1];
mappingsTraverser.addListener(new MappingsTraverser.MappingsTraverserListener() {
List<String> paths = new ArrayList<>();

mappingsTraverser.addListener(new MappingsTraverser.MappingsTraverserListener() {
@Override
public void onLeafVisited(MappingsTraverser.Node node) {
assertNotNull(node);
paths.add(node.currentPath);
}

@Override
public void onError(String error) {
errorHappend[0] = true;
fail("Failed traversing empty mappings");
}
});
mappingsTraverser.traverse();
assertTrue(errorHappend[0]);
assertEquals(0, paths.size());
}

public void testTraverseValidMappingsWithTypeFilter() {
Expand Down

0 comments on commit 6ad9519

Please sign in to comment.