Example #1
0
  @Test
  public void testDependentDependingSync() throws Exception {
    sm.removeAll();
    sm.register("file", testFile);
    String sql = "select 2*(file.id :: int) from file " + "where file.id <> '234';";
    sm.register("sql", sql);
    sql = "select * from \"sql\", file;";
    sm.register("sql2", sql);
    // Anonimous ds should not been taken into account for dependencies
    dsf.executeSQL(sql);
    Source src = sm.getSource("file");
    assertTrue(setIs(src.getReferencingSources(), new String[] {"sql", "sql2"}));
    assertTrue(setIs(src.getReferencedSources(), new String[] {}));
    src = sm.getSource("sql");
    assertTrue(setIs(src.getReferencingSources(), new String[] {"sql2"}));
    src = sm.getSource("sql2");
    assertTrue(setIs(src.getReferencingSources(), new String[] {}));
    assertTrue(setIs(src.getReferencedSources(), new String[] {"file", "sql"}));

    sm.remove("sql2");
    src = sm.getSource("file");
    assertTrue(setIs(src.getReferencingSources(), new String[] {"sql"}));
    assertTrue(setIs(src.getReferencedSources(), new String[] {}));
    src = sm.getSource("sql");
    assertTrue(setIs(src.getReferencingSources(), new String[] {}));
    src = sm.getSource("sql2");
    assertNull(src);

    sm.remove("sql");
    src = sm.getSource("file");
    assertTrue(setIs(src.getReferencingSources(), new String[] {}));
    assertTrue(setIs(src.getReferencedSources(), new String[] {}));
    src = sm.getSource("sql");
    assertNull(src);
  }