@Override
    public Graph<EntityDescriptor> resolveNativeEntity(EntityDescriptor entityDescriptor) {
        final MutableGraph<EntityDescriptor> mutableGraph = GraphBuilder.directed().build();
        mutableGraph.addNode(entityDescriptor);

        final ModelId modelId = entityDescriptor.id();
        try {
            final PipelineDao pipelineDao = pipelineService.load(modelId.id());
            final String pipelineSource = pipelineDao.source();
            final Collection<String> referencedRules = referencedRules(pipelineSource);
            referencedRules.stream()
                    .map(ModelId::of)
                    .map(id -> EntityDescriptor.create(id, ModelTypes.PIPELINE_RULE_V1))
                    .forEach(rule -> mutableGraph.putEdge(entityDescriptor, rule));

            final Set<PipelineConnections> pipelineConnections = connectionsService.loadByPipelineId(pipelineDao.id());
            pipelineConnections.stream()
                    .map(PipelineConnections::streamId)
                    .map(ModelId::of)
                    .map(id -> EntityDescriptor.create(id, ModelTypes.STREAM_REF_V1))
                    .forEach(stream -> mutableGraph.putEdge(entityDescriptor, stream));
        } catch (NotFoundException e) {
            LOG.debug("Couldn't find pipeline {}", entityDescriptor, e);
        }

        return ImmutableGraph.copyOf(mutableGraph);
    }
@Test
    @MongoDBFixtures("PipelineFacadeTest/pipelines.json")
    public void resolveEntityDescriptor() {
        final Stage stage = Stage.builder()
                .stage(0)
                .match(Stage.Match.EITHER)
                .ruleReferences(Collections.singletonList("no-op"))
                .build();
        final Pipeline pipeline = Pipeline.builder()
                .id("5a85c4854b900afd5d662be3")
                .name("Test")
                .stages(ImmutableSortedSet.of(stage))
                .build();
        when(pipelineRuleParser.parsePipeline("dummy", "pipeline \"Test\"\nstage 0 match either\nrule \"debug\"\nrule \"no-op\"\nend"))
                .thenReturn(pipeline);
        RuleDao ruleDao = RuleDao.builder()
                .id("2342353045938450345")
                .title("no-op")
                .source("rule \\\"debug\\\"\\nrule \\\"no-op\\\"\\nend\"")
                .build();

        when(ruleService.findByName("no-op")).thenReturn(Optional.of(ruleDao));
        final EntityDescriptor descriptor = EntityDescriptor.create("5a85c4854b900afd5d662be3", ModelTypes.PIPELINE_V1);
        final Graph<EntityDescriptor> graph = facade.resolveNativeEntity(descriptor);
        assertThat(graph.nodes()).containsOnly(
                descriptor,
                EntityDescriptor.create("5adf23894b900a0fdb4e517d", ModelTypes.STREAM_REF_V1),
                EntityDescriptor.create("2342353045938450345", ModelTypes.PIPELINE_RULE_V1));
    }