@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)); }
@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"))); }
@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"))); }