@Test
  public void test() throws Exception {
    InputStream fis = getClass().getResourceAsStream("../mappingFiles/test17.ttl");

    JenaR2RMLMappingManager mm = JenaR2RMLMappingManager.getInstance();

    Model m = ModelFactory.createDefaultModel();
    m = m.read(fis, "testMapping", "TURTLE");
    Collection<TriplesMap> coll = mm.importMappings(m);

    Assert.assertTrue(coll.size() == 1);

    Iterator<TriplesMap> it = coll.iterator();
    while (it.hasNext()) {
      TriplesMap current = it.next();

      Iterator<PredicateObjectMap> iter = current.getPredicateObjectMaps().iterator();
      while (iter.hasNext()) {
        PredicateObjectMap pom = iter.next();

        int cont = 0;
        Iterator<PredicateMap> ii = pom.getPredicateMaps().iterator();
        while (ii.hasNext()) {
          ii.next();
          cont++;
        }
        Assert.assertTrue(cont == 2);
      }
    }
  }
Esempio n. 2
0
  @Test
  public void test1() throws Exception {

    InputStream fis = getClass().getResourceAsStream("../mappingFiles/test5.ttl");

    JenaR2RMLMappingManager mm = JenaR2RMLMappingManager.getInstance();

    Model m = ModelFactory.createDefaultModel();
    m = m.read(fis, "testMapping", "TURTLE");
    Collection<TriplesMap> coll = mm.importMappings(m);

    Assert.assertTrue(coll.size() == 1);

    Iterator<TriplesMap> it = coll.iterator();
    while (it.hasNext()) {
      TriplesMap current = it.next();

      SubjectMap s = current.getSubjectMap();
      Template t = s.getTemplate();
      Assert.assertTrue(t.getColumnName(0).contains("EMPNO"));

      LogicalTable table = current.getLogicalTable();

      SQLBaseTableOrViewImpl ta = (SQLBaseTableOrViewImpl) table;
      Assert.assertTrue(ta.getTableName().contains("EMP2DEPT"));
    }
  }
Esempio n. 3
0
  @Test
  public void test2() throws Exception {

    InputStream fis = getClass().getResourceAsStream("../mappingFiles/test5.ttl");

    JenaR2RMLMappingManager mm = JenaR2RMLMappingManager.getInstance();

    Model m = ModelFactory.createDefaultModel();
    m = m.read(fis, "testMapping", "TURTLE");
    Collection<TriplesMap> coll = mm.importMappings(m);

    Assert.assertTrue(coll.size() == 1);

    Iterator<TriplesMap> it = coll.iterator();
    while (it.hasNext()) {
      TriplesMap current = it.next();

      Iterator<PredicateObjectMap> pomit = current.getPredicateObjectMaps().iterator();
      PredicateObjectMap pom = pomit.next();

      Iterator<PredicateMap> pmit = pom.getPredicateMaps().iterator();
      while (pmit.hasNext()) {
        PredicateMap p = pmit.next();
        boolean first = p.getConstant().contains("department");

        Assert.assertTrue(first);
      }

      Iterator<ObjectMap> omit = pom.getObjectMaps().iterator();
      while (omit.hasNext()) {
        ObjectMap o = omit.next();

        boolean first = o.getTemplate().getColumnName(0).contains("DEPTNO");

        Assert.assertTrue(first);
      }
    }
  }