Search in sources :

Example 6 with JoltTransform

use of com.bazaarvoice.jolt.JoltTransform in project nifi by apache.

the class TestTransformFactory method testGetDefaultTransform.

@Test
public void testGetDefaultTransform() throws Exception {
    final String defaultrSpec = new String(Files.readAllBytes(Paths.get("src/test/resources/TestTransformFactory/defaultrSpec.json")));
    JoltTransform transform = TransformFactory.getTransform(getClass().getClassLoader(), "jolt-transform-default", JsonUtils.jsonToObject(defaultrSpec));
    assertTrue(transform instanceof Defaultr);
}
Also used : Defaultr(com.bazaarvoice.jolt.Defaultr) JoltTransform(com.bazaarvoice.jolt.JoltTransform) Test(org.junit.Test)

Example 7 with JoltTransform

use of com.bazaarvoice.jolt.JoltTransform in project nifi by apache.

the class TestTransformFactory method testGetChainTransform.

@Test
public void testGetChainTransform() throws Exception {
    final String chainrSpec = new String(Files.readAllBytes(Paths.get("src/test/resources/TestTransformFactory/chainrSpec.json")));
    JoltTransform transform = TransformFactory.getTransform(getClass().getClassLoader(), "jolt-transform-chain", JsonUtils.jsonToObject(chainrSpec));
    assertTrue(transform instanceof Chainr);
}
Also used : JoltTransform(com.bazaarvoice.jolt.JoltTransform) Chainr(com.bazaarvoice.jolt.Chainr) Test(org.junit.Test)

Example 8 with JoltTransform

use of com.bazaarvoice.jolt.JoltTransform in project nifi by apache.

the class TestTransformFactory method testGetSortTransform.

@Test
public void testGetSortTransform() throws Exception {
    JoltTransform transform = TransformFactory.getTransform(getClass().getClassLoader(), "jolt-transform-sort", null);
    assertTrue(transform instanceof Sortr);
}
Also used : Sortr(com.bazaarvoice.jolt.Sortr) JoltTransform(com.bazaarvoice.jolt.JoltTransform) Test(org.junit.Test)

Example 9 with JoltTransform

use of com.bazaarvoice.jolt.JoltTransform in project nifi by apache.

the class TestTransformFactory method testGetModifierDefaultTransform.

@Test
public void testGetModifierDefaultTransform() throws Exception {
    final String cardrSpec = new String(Files.readAllBytes(Paths.get("src/test/resources/TestTransformFactory/modifierDefaultSpec.json")));
    JoltTransform transform = TransformFactory.getTransform(getClass().getClassLoader(), "jolt-transform-modify-default", JsonUtils.jsonToObject(cardrSpec));
    assertTrue(transform instanceof Modifier.Defaultr);
}
Also used : JoltTransform(com.bazaarvoice.jolt.JoltTransform) Modifier(com.bazaarvoice.jolt.Modifier) Test(org.junit.Test)

Example 10 with JoltTransform

use of com.bazaarvoice.jolt.JoltTransform in project nifi by apache.

the class TestTransformFactory method testGetCustomTransformation.

@Test
public void testGetCustomTransformation() throws Exception {
    final String chainrSpec = new String(Files.readAllBytes(Paths.get("src/test/resources/TestTransformFactory/chainrSpec.json")));
    Path jarFilePath = Paths.get("src/test/resources/TestTransformFactory/TestCustomJoltTransform.jar");
    URL[] urlPaths = new URL[1];
    urlPaths[0] = jarFilePath.toUri().toURL();
    ClassLoader customClassLoader = new URLClassLoader(urlPaths, this.getClass().getClassLoader());
    JoltTransform transform = TransformFactory.getCustomTransform(customClassLoader, "TestCustomJoltTransform", JsonUtils.jsonToObject(chainrSpec));
    assertTrue(transform != null);
    assertTrue(transform.getClass().getName().equals("TestCustomJoltTransform"));
}
Also used : Path(java.nio.file.Path) JoltTransform(com.bazaarvoice.jolt.JoltTransform) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) URL(java.net.URL) Test(org.junit.Test)

Aggregations

JoltTransform (com.bazaarvoice.jolt.JoltTransform)15 Test (org.junit.Test)10 Modifier (com.bazaarvoice.jolt.Modifier)3 CardinalityTransform (com.bazaarvoice.jolt.CardinalityTransform)1 Chainr (com.bazaarvoice.jolt.Chainr)1 Defaultr (com.bazaarvoice.jolt.Defaultr)1 Removr (com.bazaarvoice.jolt.Removr)1 Shiftr (com.bazaarvoice.jolt.Shiftr)1 Sortr (com.bazaarvoice.jolt.Sortr)1 SpecException (com.bazaarvoice.jolt.exception.SpecException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 POST (javax.ws.rs.POST)1