Example #1
0
  @Test
  public void testSingleReference() throws DecisionTreeParserException {
    final ReferenceResolver resolver = mock(ReferenceResolver.class);
    when(resolver.resolveReference("b", "a")).thenReturn(true);
    final References references = new References();
    references.addMapping("b", "a");

    references.resolveAll(resolver);
    verify(resolver, atMost(1)).resolveReference("b", "a");
  }
Example #2
0
  @Test
  public void testMissingReference() throws DecisionTreeParserException {
    final ReferenceResolver resolver = mock(ReferenceResolver.class);
    when(resolver.resolveReference("b", "a")).thenReturn(false);
    final References references = new References();
    references.addMapping("b", "a");

    try {
      references.resolveAll(resolver);
      fail("Should fail when the reference resolver cannot handle an input");
    } catch (DecisionTreeParserException e) {
      verify(resolver, atMost(1)).resolveReference("b", "a");
    }
  }
Example #3
0
  @Test
  public void testNestedReference_backwards() throws DecisionTreeParserException {
    // Same as the test above, but add the mappings backwards to verify the order doesn't matter
    final ReferenceResolver resolver = mock(ReferenceResolver.class);

    when(resolver.resolveReference("b", "c")).thenReturn(false).thenReturn(true);
    when(resolver.resolveReference("c", "a")).thenReturn(true);
    final References references = new References();
    references.addMapping("c", "a");
    references.addMapping("b", "c");

    references.resolveAll(resolver);
    verify(resolver, atMost(1)).resolveReference("c", "a");
    verify(resolver, atMost(2)).resolveReference("b", "c");
  }