@Override
    public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
        final ModelId modelId = entityDescriptor.id();
        try {
            final RuleDao ruleDao = ruleService.load(modelId.id());
            return Optional.of(exportNativeEntity(ruleDao, entityDescriptorIds));
        } catch (NotFoundException e) {
            LOG.debug("Couldn't find pipeline rule {}", entityDescriptor, e);
            return Optional.empty();
        }
    }
@Test
    public void exportEntity() {
        final RuleDao pipelineRule = RuleDao.builder()
                .id("id")
                .title("title")
                .description("description")
                .source("rule \"debug\"\nwhen\n  true\nthen\n  debug($message.message);\nend")
                .build();
        final EntityDescriptor descriptor = EntityDescriptor.create("id", ModelTypes.PIPELINE_RULE_V1);
        final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor);
        final Entity entity = facade.exportNativeEntity(pipelineRule, entityDescriptorIds);

        assertThat(entity).isInstanceOf(EntityV1.class);
        assertThat(entity.id()).isEqualTo(ModelId.of(entityDescriptorIds.get(descriptor).orElse(null)));
        assertThat(entity.type()).isEqualTo(ModelTypes.PIPELINE_RULE_V1);

        final EntityV1 entityV1 = (EntityV1) entity;
        final PipelineRuleEntity ruleEntity = objectMapper.convertValue(entityV1.data(), PipelineRuleEntity.class);
        assertThat(ruleEntity.title()).isEqualTo(ValueReference.of("title"));
        assertThat(ruleEntity.description()).isEqualTo(ValueReference.of("description"));
        assertThat(ruleEntity.source().asString(Collections.emptyMap())).startsWith("rule \"debug\"\n");
    }