@Override
    public NativeEntity<PipelineDao> createNativeEntity(Entity entity,
                                                        Map<String, ValueReference> parameters,
                                                        Map<EntityDescriptor, Object> nativeEntities,
                                                        String username) {
        if (entity instanceof EntityV1) {
            return decode((EntityV1) entity, parameters, nativeEntities);
        } else {
            throw new IllegalArgumentException("Unsupported entity version: " + entity.getClass());
        }
    }
@Test
    public void createNativeEntity() throws NotFoundException {
        final Entity entity = EntityV1.builder()
                .id(ModelId.of("1"))
                .type(ModelTypes.PIPELINE_V1)
                .data(objectMapper.convertValue(PipelineEntity.create(
                        ValueReference.of("Title"),
                        ValueReference.of("Description"),
                        ValueReference.of("pipeline \"Title\"\nstage 0 match either\nrule \"debug\"\nrule \"no-op\"\nend"),
                        Collections.singleton(ValueReference.of("5adf23894b900a0f00000001"))), JsonNode.class))
                .build();

        final EntityDescriptor streamDescriptor = EntityDescriptor.create("5adf23894b900a0f00000001", ModelTypes.STREAM_V1);
        final Stream stream = mock(Stream.class);
        when(stream.getId()).thenReturn("5adf23894b900a0f00000001");
        final Map<EntityDescriptor, Object> nativeEntities = Collections.singletonMap(streamDescriptor, stream);
        final NativeEntity<PipelineDao> nativeEntity = facade.createNativeEntity(entity, Collections.emptyMap(), nativeEntities, "username");

        assertThat(nativeEntity.descriptor().type()).isEqualTo(ModelTypes.PIPELINE_V1);
        assertThat(nativeEntity.entity().title()).isEqualTo("Title");
        assertThat(nativeEntity.entity().description()).isEqualTo("Description");
        assertThat(nativeEntity.entity().source()).startsWith("pipeline \"Title\"");

        assertThat(connectionsService.load("5adf23894b900a0f00000001").pipelineIds())
                .containsOnly(nativeEntity.entity().id());
    }