Search in sources :

Example 16 with Action

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);
    }
}
Also used : SubString(io.atlasmap.v2.SubString) Test(org.junit.Test)

Example 17 with Action

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"));
}
Also used : EndsWith(io.atlasmap.v2.EndsWith) Test(org.junit.Test)

Example 18 with Action

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"));
}
Also used : StartsWith(io.atlasmap.v2.StartsWith) Test(org.junit.Test)

Example 19 with Action

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));
}
Also used : Concatenate(io.atlasmap.v2.Concatenate) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 20 with Action

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"));
}
Also used : LastIndexOf(io.atlasmap.v2.LastIndexOf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)28 AtlasFieldActionInfo (io.atlasmap.spi.AtlasFieldActionInfo)13 Action (io.atlasmap.v2.Action)6 ActionDetail (io.atlasmap.v2.ActionDetail)6 SubString (io.atlasmap.v2.SubString)6 ConvertMassUnit (io.atlasmap.v2.ConvertMassUnit)5 Action (com.opensymphony.xwork2.Action)3 AtlasFieldAction (io.atlasmap.api.AtlasFieldAction)3 AtlasMapping (io.atlasmap.v2.AtlasMapping)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 AbsoluteValue (io.atlasmap.v2.AbsoluteValue)2 Actions (io.atlasmap.v2.Actions)2 Append (io.atlasmap.v2.Append)2 Concatenate (io.atlasmap.v2.Concatenate)2 ConvertAreaUnit (io.atlasmap.v2.ConvertAreaUnit)2 ConvertDistanceUnit (io.atlasmap.v2.ConvertDistanceUnit)2 ConvertVolumeUnit (io.atlasmap.v2.ConvertVolumeUnit)2 DataSource (io.atlasmap.v2.DataSource)2 LastIndexOf (io.atlasmap.v2.LastIndexOf)2