use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleMap method map_transforms.
@Test
public void map_transforms() {
TupleMap x = TupleMap.create("SPO", "POS");
List<Integer> listGet = x.transformPut();
List<Integer> listGetExpected = Arrays.asList(2, 0, 1);
assertEquals(listGetExpected, listGet);
List<Integer> listPut = x.transformGet();
List<Integer> listPutExpected = Arrays.asList(1, 2, 0);
assertEquals(listPutExpected, listPut);
}
use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleMap method map_slot_1.
@Test
public void map_slot_1() {
TupleMap tmap = TupleMap.create("SPO", "POS");
Tuple<String> tuple = TupleFactory.tuple("S", "P", "O");
assertEquals("P", tmap.mapSlot(0, tuple));
assertEquals("O", tmap.mapSlot(1, tuple));
assertEquals("S", tmap.mapSlot(2, tuple));
Tuple<String> tuple1 = tmap.map(tuple);
assertEquals("S", tmap.unmapSlot(0, tuple1));
assertEquals("P", tmap.unmapSlot(1, tuple1));
assertEquals("O", tmap.unmapSlot(2, tuple1));
}
use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleMap method map_tuple_4.
@Test
public void map_tuple_4() {
String[] x = { "G", "S", "P", "O" };
String[] y = { "O", "S", "P", "G" };
TupleMap tmap = TupleMap.create("Test", x, y);
Tuple<String> tuple = TupleFactory.tuple(x);
Tuple<String> mapped = tmap.map(tuple);
Tuple<String> expected = TupleFactory.tuple(y);
assertEquals(expected, mapped);
Tuple<String> unmapped = tmap.unmap(mapped);
assertEquals(TupleFactory.tuple(x), unmapped);
}
use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleMap method map_array_2.
@Test
public void map_array_2() {
// (0,1,2) -> (2,0,1) S->2 etc
// so (0,1,2) <- (1,2,0)
TupleMap x = TupleMap.create("SPO", "POS");
String[] array = { "Y", "Z", "X" };
// The index 0 comes from position 3.
assertEquals("X", x.unmapSlot(0, array));
assertEquals("Y", x.unmapSlot(1, array));
assertEquals("Z", x.unmapSlot(2, array));
}
use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleMap method map_tuple_2.
@Test
public void map_tuple_2() {
TupleMap x = TupleMap.create("SPO", "POS");
Tuple<String> tuple = TupleFactory.tuple("S", "P", "O");
Tuple<String> mapped = x.map(tuple);
Tuple<String> expected = TupleFactory.tuple("P", "O", "S");
assertEquals(expected, mapped);
}
Aggregations