@Test void testGetEntityTypesDependentOnDeepReferences() { when(entity0.getId()).thenReturn("0"); when(entity1.getId()).thenReturn("1"); when(entity2.getId()).thenReturn("2"); when(entity3.getId()).thenReturn("3"); when(entity4.getId()).thenReturn("4"); when(entity1.getIndexingDepth()).thenReturn(1); when(entity2.getIndexingDepth()).thenReturn(1); when(entity3.getIndexingDepth()).thenReturn(3); when(entity4.getIndexingDepth()).thenReturn(1); List<EntityType> entityTypes = ImmutableList.of(entity0, entity1, entity2, entity3, entity4); addReferences(entity1, ImmutableList.of(entity0, entity3)); addReferences(entity2, ImmutableList.of(entity1)); addReferences(entity3, ImmutableList.of(entity2)); addReferences(entity4, ImmutableList.of(entity0, entity3)); addReferences(entity0, ImmutableList.of()); IndexDependencyModel dependencyModel = new IndexDependencyModel(entityTypes); Set<String> dependencies = dependencyModel.getEntityTypesDependentOn("0").collect(toSet()); assertEquals(of("1", "3", "4"), dependencies); }
Stream<String> getEntityTypesDependentOn(String entityTypeId) { return genericDependencyResolver .getAllDependants( entityTypeId, id -> entityTypes.get(id).getIndexingDepth(), this::getReferencingEntities) .stream(); }
IndexDependencyModel { Stream<String> getEntityTypesDependentOn(String entityTypeId) { return genericDependencyResolver .getAllDependants( entityTypeId, id -> entityTypes.get(id).getIndexingDepth(), this::getReferencingEntities) .stream(); } }
IndexDependencyModel { Stream<String> getEntityTypesDependentOn(String entityTypeId) { return genericDependencyResolver .getAllDependants( entityTypeId, id -> entityTypes.get(id).getIndexingDepth(), this::getReferencingEntities) .stream(); } IndexDependencyModel(List<EntityType> entityTypes); }
IndexDependencyModel { Stream<String> getEntityTypesDependentOn(String entityTypeId) { return genericDependencyResolver .getAllDependants( entityTypeId, id -> entityTypes.get(id).getIndexingDepth(), this::getReferencingEntities) .stream(); } IndexDependencyModel(List<EntityType> entityTypes);  }
IndexDependencyModel { Stream<String> getEntityTypesDependentOn(String entityTypeId) { return genericDependencyResolver .getAllDependants( entityTypeId, id -> entityTypes.get(id).getIndexingDepth(), this::getReferencingEntities) .stream(); } IndexDependencyModel(List<EntityType> entityTypes);   }