test.resources.test-cases.ion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ion-java-path-extraction Show documentation
Show all versions of ion-java-path-extraction Show documentation
Ion Path Extraction API aims to combine the convenience of a DOM API with the speed of a streaming API.
The newest version!
/*
Test case spec:
single search path:
{
searchPath: ,
data: ,
expected:
}
multiple search paths:
{
searchPaths: ,
data: ,
expected:
}
Only difference is that for multiple the searchPath key is pluralized to searchPaths and expects an Ion sequence of
search paths
*/
// zero search paths ---------------------------------------------------------------------
// no-op extractor, data doesn't matter
{ searchPaths: [], expected: [], data: {foo: 1} }
{ searchPaths: [], expected: [], data: (3 4) }
{ searchPaths: [], expected: [], data: 99 }
{ searchPaths: [], expected: [], data: [1, 2] }
// Field only ----------------------------------------------------------------------------
// matches
{ searchPath: (foo), data: {foo: 1}, expected: [1] }
{ searchPath: [foo], data: {foo: 1}, expected: [1] }
{ searchPath: (foo bar), data: {foo: {bar : 2}}, expected: [2] }
// escaped wildcard
{ searchPath: ('$ion_extractor_field'::*), data: {'*': 1, foo: 2}, expected: [1]}
// matches one sibling
{ searchPath: (foo baz), data: {foo: {bar : 2, baz: 3}}, expected: [3] }
// multiple matches
{ searchPath: (foo bar), data: {foo: {bar : 2, bar: 3}}, expected: [2, 3] }
// no match
{ searchPath: (foo), data: {baz: 10}, expected: [] }
{ searchPath: (foo baz), data: {foo: {bar : 2}}, expected: [] }
// stepOut
{ searchPath: (foo bar), data: {foo: {bar : 2, bar: 3}}, expected: [2], stepOutN: 1 }
{
searchPath: (foo bar baz),
data: { foo: { bar: {baz: 1}, bar: {baz: 2} } },
expected: [1],
stepOutN: 2
}
// empty containers
{ searchPath: (foo), data: {}, expected: [] }
{ searchPath: (foo), data: (), expected: [] }
{ searchPath: (foo), data: [], expected: [] }
// not containers
{ searchPath: (foo), data: null, expected: [] }
{ searchPath: (foo), data: true, expected: [] }
{ searchPath: (foo), data: 1, expected: [] }
{ searchPath: (foo), data: 1e0, expected: [] }
{ searchPath: (foo), data: 1.0, expected: [] }
{ searchPath: (foo), data: 2018T, expected: [] }
{ searchPath: (foo), data: "", expected: [] }
{ searchPath: (foo), data: '', expected: [] }
{ searchPath: (foo), data: {{ }}, expected: [] }
{ searchPath: (foo), data: {{ "" }}, expected: [] }
// Ordinal only --------------------------------------------------------------------------
// matches
{ searchPath: (0), data: [1], expected: [1] }
{ searchPath: [0], data: [1], expected: [1] }
{ searchPath: (0), data: (1), expected: [1] }
{ searchPath: (0), data: {f: 1}, expected: [1] }
{ searchPath: (1), data: [1, 2], expected: [2] }
{ searchPath: (1), data: (1 3), expected: [3] }
{ searchPath: (1), data: {f1: 1, f2: 2}, expected: [2] }
{ searchPath: (0), data: [1, 2], expected: [1] }
{ searchPath: (0), data: (1 3), expected: [1] }
{ searchPath: (0), data: {f1: 1, f2: 2}, expected: [1] }
// out of bounds
{ searchPath: (1), data: [1], expected: [] }
{ searchPath: (1), data: (1), expected: [] }
{ searchPath: (1), data: {foo: 1}, expected: [] }
// empty containers
{ searchPath: (0), data: [], expected: [] }
{ searchPath: (0), data: (), expected: [] }
{ searchPath: (0), data: {}, expected: [] }
// not containers
{ searchPath: (0), data: null, expected: [] }
{ searchPath: (0), data: true, expected: [] }
{ searchPath: (0), data: 1, expected: [] }
{ searchPath: (0), data: 1e0, expected: [] }
{ searchPath: (0), data: 1.0, expected: [] }
{ searchPath: (0), data: 2018T, expected: [] }
{ searchPath: (0), data: "", expected: [] }
{ searchPath: (0), data: '', expected: [] }
{ searchPath: (0), data: {{ }}, expected: [] }
{ searchPath: (0), data: {{ "" }}, expected: [] }
// Wildcard only -------------------------------------------------------------------------
// matches
{ searchPath: (*), data: [1], expected: [1] }
{ searchPath: ['*'], data: [1], expected: [1] }
{ searchPath: (*), data: (1), expected: [1] }
{ searchPath: (*), data: {f: 1}, expected: [1] }
{ searchPath: (*), data: [1, 2], expected: [1, 2] }
{ searchPath: (*), data: (1 3), expected: [1, 3] }
{ searchPath: (*), data: {f1: 1, f2: 2}, expected: [1, 2] }
{ searchPath: (* *), data: [1, [2]], expected: [2] }
{ searchPath: (* *), data: (1 (3)), expected: [3] }
{ searchPath: (* *), data: {f1: 1, f2: {f3: 2}}, expected: [2] }
// escape annotation is only valid as the first annotation
{
searchPath: (foo::'$ion_extractor_field'::*),
data: [foo::'$ion_extractor_field'::1, foo::'$ion_extractor_field'::2],
expected: [foo::'$ion_extractor_field'::1, foo::'$ion_extractor_field'::2]
}
// insufficient depth
{ searchPath: (* *), data: [1], expected: [] }
{ searchPath: (* *), data: (1), expected: [] }
{ searchPath: (* *), data: {f1: 1}, expected: [] }
{ searchPath: (* *), data: [1, 2], expected: [] }
{ searchPath: (* *), data: (1 2), expected: [] }
{ searchPath: (* *), data: {f1: 1, f2: 2}, expected: [] }
// step out
{ searchPath: (* *), data: [[1], [2]], expected: [1], stepOutN: 2 }
// empty containers
{ searchPath: (*), data: [], expected: [] }
{ searchPath: (*), data: (), expected: [] }
{ searchPath: (*), data: {}, expected: [] }
// not containers
{ searchPath: (*), data: null, expected: [] }
{ searchPath: (*), data: true, expected: [] }
{ searchPath: (*), data: 1, expected: [] }
{ searchPath: (*), data: 1e0, expected: [] }
{ searchPath: (*), data: 1.0, expected: [] }
{ searchPath: (*), data: 2018T, expected: [] }
{ searchPath: (*), data: "", expected: [] }
{ searchPath: (*), data: '', expected: [] }
{ searchPath: (*), data: {{ }}, expected: [] }
{ searchPath: (*), data: {{ "" }}, expected: [] }
// Empty search path ---------------------------------------------------------------------
// containers
{ searchPath: (), data: [1], expected: [[1]] }
{ searchPath: [], data: [1], expected: [[1]] }
{ searchPath: (), data: (1), expected: [(1)] }
{ searchPath: (), data: {foo: 1}, expected: [{foo: 1}] }
// empty containers
{ searchPath: (), data: [], expected: [[]] }
{ searchPath: (), data: (), expected: [()] }
{ searchPath: (), data: {}, expected: [{}] }
// not containers
{ searchPath: (), data: null, expected: [null] }
{ searchPath: (), data: true, expected: [true] }
{ searchPath: (), data: 1, expected: [1] }
{ searchPath: (), data: 1e0, expected: [1e0] }
{ searchPath: (), data: 1.0, expected: [1.0] }
{ searchPath: (), data: 2018T, expected: [2018T] }
{ searchPath: (), data: "", expected: [""] }
{ searchPath: (), data: '', expected: [''] }
{ searchPath: (), data: {{ }}, expected: [{{ }}] }
{ searchPath: (), data: {{ "" }}, expected: [{{ "" }}] }
// Mixed path components -----------------------------------------------------------------
{
searchPath: (foo 1),
data: { foo: [0, 1], foo: (0 2), foo: {a: 1, b: 3}, foo: 1, bar: [0, 1] },
expected: [1, 2, 3]
}
{
searchPath: [foo, '*'],
data: { foo: [1], foo: (2), foo: {bar: 3}, foo: 1, bar: (9) },
expected: [1, 2, 3]
}
{
searchPath: (foo * bar),
data: { foo: [ {bar: 1} ], foo: { baz: {bar: 2} } },
expected: [1, 2]
}
{
searchPath: (foo * 0),
data: { foo: [1, [2]], foo: {bar: (3)} },
expected: [2, 3]
}
{
searchPath: (foo bar 2),
data: {abc: def, foo: {bar:[1, 2, 3]}},
expected: [3]
}
{
searchPath: (foo bar *),
data: {abc: def, foo: {bar:[1, 2, 3]}},
expected: [1, 2, 3]
}
{
searchPath: (foo bar * baz),
data: {abc: def, foo: {bar:[{baz:1}, {zar:2}, {baz:3}]}},
expected: [1, 3]
}
// stepOut
{
searchPath: (foo * 0),
data: {
foo: { first: [1], second: [2] },
foo: { first: [10], second: [20] }
},
expected: [1,10],
stepOutN: 2
}
// Multiple search paths -----------------------------------------------------------------
// all match
legacy::{ searchPaths: [(0), (foo)], data: {bar: 1, foo: 2}, expected: [1, 2] }
// none match
legacy::{ searchPaths: [(1), [foo]], data: [0], expected: [] }
// multiple matchers match the same value
legacy::{ searchPaths: [(1), (*)], data: [1, 2, 3], expected: [1, 2, 2, 3] }
{ searchPaths: [(foo 1), (foo 2)], data: {foo: [0, 1, 2]}, expected: [1, 2] }
// With annotations ----------------------------------------------------------------------
{ searchPath: A::(), data: A::1, expected: [A::1] }
{ searchPath: A::(), data: 1, expected: [] }
{
searchPath: A::(foo),
data: $datagram::[
A::{bar: 1},
A::{foo: 2},
{foo: 3}
],
expected: [2]
}
{ searchPath: (A::'*'), data: [A::1, 2], expected: [A::1] }
{ searchPath: ('$ion_extractor_field'::*), data: {'*': A::1, foo: 2}, expected: [A::1]}
{ searchPath: (A::B::C::*), data: [A::B::C::1, B::A::C::2], expected: [A::B::C::1] }
legacy::{
// annotations on ordinals or fields _could_ be supported in the FSM impl
// but usage appears non-existent at time of writing (Sep 2024)
searchPath: (foo A::2 bar),
data: {
foo: [0, 1, A::{bar: 1}],
foo: [0, 1, {bar: 2}]
},
expected: [1]
}
legacy::{
searchPath: (f::foo),
data: { foo: f::17, foo: F::31, Foo: f::51, Foo: F::67 },
expected: [f::17],
// default is None but explicit here as it is essential to the test case
caseInsensitive: None
}
// case insensitivity
{
searchPath: (foo),
data: $datagram::[{FOO: 1, foO: 2},{foo: 3},{fOo: 4},{bar: 5}],
expected: [1, 2, 3, 4],
caseInsensitive: Both
}
legacy::{
// these resolve to the same path for the Fsm Impl
searchPaths: [(foo), (Foo)],
data: $datagram::[{FOO: 1, foO: 2},{foo: 3},{Foo: 4},{bar: 5}],
expected: [1, 1, 2, 2, 3, 3, 4, 4],
caseInsensitive: Both
}
{
searchPath: (foo),
data: $datagram::[{FOO: 1, foO: 2},{foo: 3},{Foo: 4},{bar: 5}],
expected: [1, 2, 3, 4],
caseInsensitive: Fields
}
legacy::{
searchPath: F::(),
data: $datagram::[F::17, g::31, f::51],
expected: [F::17, f::51],
caseInsensitive: Both
}
{
searchPath: F::(),
data: $datagram::[F::17, g::31, f::51],
expected: [F::17],
caseInsensitive: Fields
}