コード例 #1
0
  @Test
  public void setterGetter() {
    final SourceValue value = new SourceValue("value", true, true);

    final ValueMap map = new ValueMap();

    map.setSourceValues(Collections.singleton(value));
    map.setReturnValue("return");

    Assert.assertEquals(map.getReturnValue(), "return");
    Assert.assertEquals(map.getSourceValues().size(), 1);
    Assert.assertTrue(map.getSourceValues().contains(value));
  }
コード例 #2
0
  @Test
  public void subString() {
    final SourceValue value = new SourceValue("value", true, true);

    final ValueMap map = new ValueMap();

    map.setSourceValues(Collections.singleton(value));
    map.setReturnValue("return");

    Set<StringAttributeValue> result = map.apply("elephant");

    Assert.assertTrue(result.isEmpty());

    result = map.apply("elephantvaluegiraffe");
    Assert.assertEquals(result.size(), 1);
    Assert.assertTrue(result.contains(new StringAttributeValue("return")));
  }
コード例 #3
0
  @Test
  public void regexp() {
    final HashSet<SourceValue> sources = new HashSet<>(3);

    sources.add(new SourceValue("R(.+)", false, false));
    sources.add(new SourceValue("RE(.+)", true, false));
    final ValueMap map = new ValueMap();
    map.setSourceValues(sources);
    map.setReturnValue("foo$1");

    Set<StringAttributeValue> result = map.apply("elephant");
    Assert.assertTrue(result.isEmpty());

    result = map.apply("Recursion");
    Assert.assertEquals(result.size(), 2);
    Assert.assertTrue(result.contains(new StringAttributeValue("fooecursion")));
    Assert.assertTrue(result.contains(new StringAttributeValue("foocursion")));
  }