use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class StringComplexFieldActionsTest method testSubString.
@Test
public void testSubString() {
SubString action = new SubString();
action.setStartIndex(2);
action.setEndIndex(4);
assertNull(StringComplexFieldActions.subString(action, null));
assertEquals("", StringComplexFieldActions.subString(action, ""));
try {
StringComplexFieldActions.subString(null, "aa");
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
assertTrue(true);
}
}
use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class StringComplexFieldActionsTest method testEndsWith.
@Test
public void testEndsWith() {
EndsWith action = new EndsWith();
action.setString("");
assertFalse(StringComplexFieldActions.endsWith(action, null));
assertTrue(StringComplexFieldActions.endsWith(action, ""));
assertTrue(StringComplexFieldActions.endsWith(action, "foo"));
action.setString("bar");
assertFalse(StringComplexFieldActions.endsWith(action, null));
assertFalse(StringComplexFieldActions.endsWith(action, ""));
assertFalse(StringComplexFieldActions.endsWith(action, "foo"));
assertTrue(StringComplexFieldActions.endsWith(action, "foobar"));
assertFalse(StringComplexFieldActions.endsWith(action, "barfoo"));
}
use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class StringComplexFieldActionsTest method testStartsWith.
@Test
public void testStartsWith() {
StartsWith action = new StartsWith();
action.setString("");
assertFalse(StringComplexFieldActions.startsWith(action, null));
assertTrue(StringComplexFieldActions.startsWith(action, ""));
assertTrue(StringComplexFieldActions.startsWith(action, "foo"));
action.setString("foo");
assertFalse(StringComplexFieldActions.startsWith(action, null));
assertFalse(StringComplexFieldActions.startsWith(action, ""));
assertTrue(StringComplexFieldActions.startsWith(action, "foo"));
assertTrue(StringComplexFieldActions.startsWith(action, "foobar"));
assertFalse(StringComplexFieldActions.startsWith(action, "barfoo"));
}
use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class StringComplexFieldActionsTest method testConcatenate.
@Test
public void testConcatenate() {
Concatenate action = new Concatenate();
assertEquals(null, StringComplexFieldActions.concatenate(action, null));
assertEquals("1true2.0", StringComplexFieldActions.concatenate(action, new Object[] { 1, true, 2.0 }));
assertEquals("1true2.0", StringComplexFieldActions.concatenate(action, Arrays.asList(1, true, 2.0)));
Map<Object, Object> map = new LinkedHashMap<>();
map.put(1, 1);
map.put(true, true);
map.put(2.0, 2.0);
assertEquals("1true2.0", StringComplexFieldActions.concatenate(action, map));
action.setDelimiter("-");
assertEquals(null, StringComplexFieldActions.concatenate(action, null));
assertEquals("1-true-2.0", StringComplexFieldActions.concatenate(action, new Object[] { 1, true, 2.0 }));
assertEquals("1-true-2.0", StringComplexFieldActions.concatenate(action, Arrays.asList(1, true, 2.0)));
assertEquals("1-true-2.0", StringComplexFieldActions.concatenate(action, map));
}
use of io.atlasmap.v2.Action in project atlasmap by atlasmap.
the class StringComplexFieldActionsTest method testLastIndexOf.
@Test
public void testLastIndexOf() {
LastIndexOf action = new LastIndexOf();
action.setString("");
assertEquals(-1, StringComplexFieldActions.lastIndexOf(action, null));
assertEquals(0, StringComplexFieldActions.lastIndexOf(action, ""));
assertEquals(3, StringComplexFieldActions.lastIndexOf(action, "foo"));
action.setString("bar");
assertEquals(-1, StringComplexFieldActions.lastIndexOf(action, null));
assertEquals(-1, StringComplexFieldActions.lastIndexOf(action, ""));
assertEquals(-1, StringComplexFieldActions.lastIndexOf(action, "foo"));
assertEquals(3, StringComplexFieldActions.lastIndexOf(action, "foobar"));
assertEquals(6, StringComplexFieldActions.lastIndexOf(action, "foobarbar"));
}
Aggregations