@Override
    public NativeEntity<GrokPattern> createNativeEntity(Entity entity,
                                                        Map<String, ValueReference> parameters,
                                                        Map<EntityDescriptor, Object> nativeEntities,
                                                        String username) {
        if (entity instanceof EntityV1) {
            return decode((EntityV1) entity);
        } else {
            throw new IllegalArgumentException("Unsupported entity version: " + entity.getClass());
        }
    }
@Test
    public void createNativeEntity() throws NotFoundException {
        final Entity grokPatternEntity = EntityV1.builder()
                .id(ModelId.of("1"))
                .type(ModelTypes.GROK_PATTERN_V1)
                .data(objectMapper.convertValue(GrokPatternEntity.create("Test","[a-z]+"), JsonNode.class))
                .build();
        final NativeEntity<GrokPattern> nativeEntity = facade.createNativeEntity(grokPatternEntity, Collections.emptyMap(), Collections.emptyMap(), "admin");

        final GrokPattern expectedGrokPattern = GrokPattern.create("1", "Test", "[a-z]+", null);
        final NativeEntityDescriptor expectedDescriptor = NativeEntityDescriptor.create("1", "1", ModelTypes.GROK_PATTERN_V1, "Test");

        assertThat(nativeEntity.descriptor().title()).isEqualTo(expectedDescriptor.title());
        assertThat(nativeEntity.descriptor().type()).isEqualTo(expectedDescriptor.type());

        assertThat(nativeEntity.entity()).isEqualTo(expectedGrokPattern);
        assertThat(grokPatternService.load("1")).isEqualTo(expectedGrokPattern);
    }