public void test_removeSources_nullContext() throws Exception { // record { store.recordRelationship(IndexConstants.UNIVERSE, relationship, location); assertEquals(1, store.internalGetLocationCount()); } // remove "null" context, should never happen - ignored SourceContainer sourceContainer = new DirectoryBasedSourceContainer("/path/"); store.removeSources(null, sourceContainer); assertEquals(1, store.internalGetLocationCount()); }
public void test_removeSources_withRelationship() throws Exception { Location locationB = mockLocation(elementB); Location locationC = mockLocation(elementC); // record: [B -> A] and [C -> A] { store.recordRelationship(elementA, relationship, locationB); store.recordRelationship(elementA, relationship, locationC); assertEquals(2, store.internalGetLocationCount()); Location[] locations = store.getRelationships(elementA, relationship); assertLocations(locations, locationB, locationC); } // remove container with [B], 1 relation and 1 location left SourceContainer containerB = mockSourceContainer(sourceB); store.removeSources(contextA, containerB); assertEquals(1, store.internalGetLocationCount()); assertEquals(1, store.internalGetLocationCount(contextA)); Location[] locations = store.getRelationships(elementA, relationship); assertLocations(locations, locationC); }
public void test_removeSources_withDeclaration() throws Exception { Location locationB = mockLocation(elementB); Location locationC = mockLocation(elementC); // record: A, [B -> A], [C -> A] and [B -> C] { store.recordRelationship(elementA, relationship, locationB); store.recordRelationship(elementA, relationship, locationC); store.recordRelationship(elementC, relationship, locationB); assertEquals(3, store.internalGetLocationCount()); Location[] locations = store.getRelationships(elementA, relationship); assertLocations(locations, locationB, locationC); } // remove container with [A], only [B -> C] left SourceContainer containerA = mockSourceContainer(sourceA); store.removeSources(contextA, containerA); assertEquals(1, store.internalGetLocationCount()); assertEquals(1, store.internalGetLocationCount(contextA)); { Location[] locations = store.getRelationships(elementC, relationship); assertLocations(locations, locationB); } }