@Test
public void testOnRemove2() throws Exception {

    Process p1 = new Process();
    p1.setName("ap1");
    Process p2 = new Process();
    p2.setName("ap2");
    Cluster cluster = new Cluster();
    cluster.setName("ac1");
    cluster.setColo("3");
    Feed f1 = addInput(p1, "af1", cluster);
    Feed f3 = addOutput(p1, "af3", cluster);
    Feed f2 = addOutput(p2, "af2", cluster);
    attachInput(p2, f3);
    org.apache.ivory.entity.v0.process.Cluster processCluster = new org.apache.ivory.entity.v0.process.Cluster();
    processCluster.setName("ac1");
    p1.setClusters(new org.apache.ivory.entity.v0.process.Clusters());
    p1.getClusters().getClusters().add(processCluster);
    processCluster = new org.apache.ivory.entity.v0.process.Cluster();
    processCluster.setName("ac1");
    p2.setClusters(new org.apache.ivory.entity.v0.process.Clusters());
    p2.getClusters().getClusters().add(processCluster);
    store.publish(EntityType.CLUSTER, cluster);
    store.publish(EntityType.FEED, f1);
    store.publish(EntityType.FEED, f2);
    store.publish(EntityType.FEED, f3);
    store.publish(EntityType.PROCESS, p1);
    store.publish(EntityType.PROCESS, p2);
    Set<Entity> entities = graph.getDependents(p1);
    Assert.assertEquals(entities.size(), 3);
    Assert.assertTrue(entities.contains(cluster));
    Assert.assertTrue(entities.contains(f1));
    Assert.assertTrue(entities.contains(f3));
    entities = graph.getDependents(p2);
    Assert.assertEquals(entities.size(), 3);
    Assert.assertTrue(entities.contains(cluster));
    Assert.assertTrue(entities.contains(f2));
    Assert.assertTrue(entities.contains(f3));
    entities = graph.getDependents(f1);
    Assert.assertEquals(entities.size(), 2);
    Assert.assertTrue(entities.contains(p1));
    Assert.assertTrue(entities.contains(cluster));
    entities = graph.getDependents(f2);
    Assert.assertEquals(entities.size(), 2);
    Assert.assertTrue(entities.contains(p2));
    Assert.assertTrue(entities.contains(cluster));
    entities = graph.getDependents(f3);
    Assert.assertEquals(entities.size(), 3);
    Assert.assertTrue(entities.contains(p2));
    Assert.assertTrue(entities.contains(p1));
    Assert.assertTrue(entities.contains(cluster));
    entities = graph.getDependents(cluster);
    Assert.assertEquals(entities.size(), 5);
    Assert.assertTrue(entities.contains(p1));
    Assert.assertTrue(entities.contains(p2));
    Assert.assertTrue(entities.contains(f1));
    Assert.assertTrue(entities.contains(f2));
    Assert.assertTrue(entities.contains(f3));
    store.remove(EntityType.PROCESS, p2.getName());
    store.remove(EntityType.FEED, f2.getName());
    entities = graph.getDependents(p1);
    Assert.assertEquals(entities.size(), 3);
    Assert.assertTrue(entities.contains(cluster));
    Assert.assertTrue(entities.contains(f1));
    Assert.assertTrue(entities.contains(f3));
    entities = graph.getDependents(p2);
    Assert.assertTrue(entities == null);
    entities = graph.getDependents(f1);
    Assert.assertEquals(entities.size(), 2);
    Assert.assertTrue(entities.contains(p1));
    Assert.assertTrue(entities.contains(cluster));
    entities = graph.getDependents(f2);
    Assert.assertTrue(entities == null);
    entities = graph.getDependents(f3);
    Assert.assertEquals(entities.size(), 2);
    Assert.assertTrue(entities.contains(p1));
    Assert.assertTrue(entities.contains(cluster));
    entities = graph.getDependents(cluster);
    Assert.assertEquals(entities.size(), 3);
    Assert.assertTrue(entities.contains(p1));
    Assert.assertTrue(entities.contains(f1));
    Assert.assertTrue(entities.contains(f3));
}