use of org.apache.gobblin.config.store.api.ConfigKeyPath in project incubator-gobblin by apache.
the class TestCircularDependency method testSelfIndirectlyImportDescendant.
@Test
public void testSelfIndirectlyImportDescendant() {
ConfigKeyPath tag = SingleLinkedListConfigKeyPath.ROOT.createChild("tag");
ConfigKeyPath highPriorityTag = tag.createChild("highPriorityTag");
ConfigKeyPath nertzHighPriorityTag = highPriorityTag.createChild("nertzHighPriorityTag");
ConfigKeyPath tag2 = SingleLinkedListConfigKeyPath.ROOT.createChild("tag2");
ConfigStore mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStore.getCurrentVersion()).thenReturn(version);
addConfigStoreChildren(mockConfigStore, version, SingleLinkedListConfigKeyPath.ROOT, tag, tag2);
addConfigStoreChildren(mockConfigStore, version, tag, highPriorityTag);
addConfigStoreChildren(mockConfigStore, version, highPriorityTag, nertzHighPriorityTag);
// self import descendant
// formed the loop /tag -> /tag2 -> /tag/highPriorityTag/nertzHighPriorityTag -> /tag/highPriorityTag -> /tag
addConfigStoreImports(mockConfigStore, version, tag, tag2);
addConfigStoreImports(mockConfigStore, version, tag2, nertzHighPriorityTag);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
try {
inMemory.getImportsRecursively(tag);
Assert.fail("Did not catch expected CircularDependencyException");
} catch (CircularDependencyException e) {
Assert.assertTrue(e.getMessage().indexOf("/tag/highPriorityTag/nertzHighPriorityTag") > 0 && e.getMessage().indexOf("/tag/highPriorityTag ") > 0 && e.getMessage().indexOf("/tag ") > 0 && e.getMessage().indexOf("/tag2 ") > 0);
}
}
use of org.apache.gobblin.config.store.api.ConfigKeyPath in project incubator-gobblin by apache.
the class TestCircularDependency method testSelfImportChild.
@Test
public void testSelfImportChild() {
ConfigKeyPath tag = SingleLinkedListConfigKeyPath.ROOT.createChild("tag");
ConfigKeyPath highPriorityTag = tag.createChild("highPriorityTag");
ConfigStore mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStore.getCurrentVersion()).thenReturn(version);
addConfigStoreChildren(mockConfigStore, version, SingleLinkedListConfigKeyPath.ROOT, tag);
addConfigStoreChildren(mockConfigStore, version, tag, highPriorityTag);
// parent import direct child
addConfigStoreImports(mockConfigStore, version, tag, highPriorityTag);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
try {
inMemory.getImportsRecursively(tag);
Assert.fail("Did not catch expected CircularDependencyException");
} catch (CircularDependencyException e) {
Assert.assertTrue(e.getMessage().indexOf("/tag/highPriorityTag") > 0 && e.getMessage().indexOf("/tag ") > 0);
}
}
use of org.apache.gobblin.config.store.api.ConfigKeyPath in project incubator-gobblin by apache.
the class TestCircularDependency method testNoCircular.
@Test
public void testNoCircular() {
ConfigKeyPath tag = SingleLinkedListConfigKeyPath.ROOT.createChild("tag");
ConfigKeyPath highPriorityTag = tag.createChild("highPriorityTag");
ConfigKeyPath nertzHighPriorityTag = highPriorityTag.createChild("nertzHighPriorityTag");
ConfigKeyPath tag2 = SingleLinkedListConfigKeyPath.ROOT.createChild("tag2");
ConfigStore mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStore.getCurrentVersion()).thenReturn(version);
addConfigStoreChildren(mockConfigStore, version, SingleLinkedListConfigKeyPath.ROOT, tag, tag2);
addConfigStoreChildren(mockConfigStore, version, tag, highPriorityTag);
addConfigStoreChildren(mockConfigStore, version, highPriorityTag, nertzHighPriorityTag);
// mock up imports, point to same node but without circular
addConfigStoreImports(mockConfigStore, version, nertzHighPriorityTag, tag2);
addConfigStoreImports(mockConfigStore, version, tag2, tag);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
List<ConfigKeyPath> result = inMemory.getImportsRecursively(nertzHighPriorityTag);
Assert.assertEquals(result.size(), 4);
Iterator<ConfigKeyPath> it = result.iterator();
Assert.assertEquals(it.next(), tag2);
Assert.assertEquals(it.next(), tag);
Assert.assertTrue(it.next().isRootPath());
Assert.assertEquals(it.next(), highPriorityTag);
}
use of org.apache.gobblin.config.store.api.ConfigKeyPath in project incubator-gobblin by apache.
the class TestCircularDependency method testSelfImportSelf.
@Test
public void testSelfImportSelf() {
ConfigKeyPath tag = SingleLinkedListConfigKeyPath.ROOT.createChild("tag");
ConfigStore mockConfigStore = mock(ConfigStore.class, Mockito.RETURNS_SMART_NULLS);
when(mockConfigStore.getCurrentVersion()).thenReturn(version);
addConfigStoreChildren(mockConfigStore, version, SingleLinkedListConfigKeyPath.ROOT, tag);
// self import self
addConfigStoreImports(mockConfigStore, version, tag, tag);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
try {
inMemory.getImportsRecursively(tag);
Assert.fail("Did not catch expected CircularDependencyException");
} catch (CircularDependencyException e) {
Assert.assertTrue(e.getMessage().indexOf("/tag") > 0);
}
}
use of org.apache.gobblin.config.store.api.ConfigKeyPath in project incubator-gobblin by apache.
the class TestInMemoryTopology method testNonRootTopology.
@Test
public void testNonRootTopology() {
Assert.assertEquals(mockConfigStore.getCurrentVersion(), version);
ConfigStoreBackedTopology csTopology = new ConfigStoreBackedTopology(this.mockConfigStore, this.version);
InMemoryTopology inMemory = new InMemoryTopology(csTopology);
Collection<ConfigKeyPath> result = inMemory.getChildren(data);
Assert.assertTrue(result.size() == 1);
Assert.assertEquals(result.iterator().next(), databases);
// test own imports
result = inMemory.getOwnImports(identity);
Assert.assertTrue(result.size() == 2);
Iterator<ConfigKeyPath> it = result.iterator();
Assert.assertEquals(it.next(), espressoTag);
Assert.assertEquals(it.next(), highPriorityTag);
// test import recursively
result = inMemory.getImportsRecursively(identity);
Assert.assertEquals(result.size(), 8);
Assert.assertEquals(result, Lists.newArrayList(highPriorityTag, tag, SingleLinkedListConfigKeyPath.ROOT, espressoTag, nertzTag2, tag2, databases, data));
// test own imported by
result = inMemory.getImportedBy(nertzTag2);
Assert.assertTrue(result.size() == 1);
Assert.assertEquals(result.iterator().next(), espressoTag);
// test imported by recursively, as the imported by recursively do not care about
// order, need to use HashSet to test
result = inMemory.getImportedByRecursively(nertzTag2);
Set<ConfigKeyPath> expected = new HashSet<ConfigKeyPath>();
expected.add(espressoTag);
expected.add(identity);
Assert.assertTrue(result.size() == 2);
it = result.iterator();
while (it.hasNext()) {
ConfigKeyPath tmp = it.next();
Assert.assertTrue(expected.contains(tmp));
expected.remove(tmp);
}
}
Aggregations