Sha256: 6fb9fe4f9d6a8c0291014091fdad6565a95845339a78db7f1f82a2dd07915f11

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

package org.embulk.filter.column;

import org.embulk.spi.type.Types;
import org.junit.Test;
import org.msgpack.value.Value;
import org.msgpack.value.ValueFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

public class TestJsonColumn
{
    @Test
    public void initialize()
    {
        try {
            JsonColumn column = new JsonColumn("$.foo.bar", Types.BOOLEAN);
            assertEquals("$.foo.bar", column.getSrc());
            assertEquals(ValueFactory.newNil(), column.getDefaultValue());
        }
        catch (Exception e) {
            fail();
        }

        try {
            Value defaultValue = ValueFactory.newBoolean(true);
            JsonColumn column = new JsonColumn("$.foo.bar", Types.BOOLEAN, defaultValue);
            assertEquals("$.foo.bar", column.getSrc());
            assertEquals(defaultValue, column.getDefaultValue());
        }
        catch (Exception e) {
            fail();
        }
    }

    @Test
    public void parentPath()
    {
        assertEquals("$.foo.bar", JsonColumn.parentPath("$.foo.bar.baz"));
        assertEquals("$.foo", JsonColumn.parentPath("$.foo.bar"));
        assertEquals("$", JsonColumn.parentPath("$.foo"));
        assertEquals("$.foo[0]", JsonColumn.parentPath("$.foo[0][1]"));
        assertEquals("$.foo", JsonColumn.parentPath("$.foo[0]"));
        assertEquals("$", JsonColumn.parentPath("$[0]"));
    }

    @Test
    public void baseName()
    {
        assertEquals("baz", JsonColumn.baseName("$.foo.bar.baz"));
        assertEquals("bar", JsonColumn.baseName("$.foo.bar"));
        assertEquals("foo", JsonColumn.baseName("$.foo"));
        assertEquals("[1]", JsonColumn.baseName("$.foo[0][1]"));
        assertEquals("[0]", JsonColumn.baseName("$.foo[0]"));
        assertEquals("[0]", JsonColumn.baseName("$[0]"));
    }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
embulk-filter-column-0.5.4 src/test/java/org/embulk/filter/column/TestJsonColumn.java
embulk-filter-column-0.5.3 src/test/java/org/embulk/filter/column/TestJsonColumn.java