@Override
    public Integer call() throws Exception {
        super.call();

        try (var files = Files.walk(directory)) {
            List<Template> templates = files
                .filter(Files::isRegularFile)
                .filter(YamlFlowParser::isValidExtension)
                .map(path -> yamlFlowParser.parse(path.toFile(), Template.class))
                .toList();

            if (templates.isEmpty()) {
                stdOut("No template found on '{}'", directory.toFile().getAbsolutePath());
            }

            try (DefaultHttpClient client = client()) {
                MutableHttpRequest<List<Template>> request = HttpRequest
                    .POST(apiUri("/templates/") + namespace + "?delete=" + delete, templates);

                List<UpdateResult> updated = client.toBlocking().retrieve(
                    this.requestOptions(request),
                    Argument.listOf(UpdateResult.class)
                );

                stdOut(updated.size() + " template(s) for namespace '" + namespace + "' successfully updated !");
                updated.forEach(template -> stdOut("- " + template.getNamespace() + "." + template.getId()));
            } catch (HttpClientResponseException e) {
                TemplateValidateCommand.handleHttpException(e, "template");

                return 1;
            }
        } catch (ConstraintViolationException e) {
            TemplateValidateCommand.handleException(e, "template");

            return 1;
        }

        return 0;
    }
@Test
    void invalid() {
        URL directory = TemplateNamespaceUpdateCommandTest.class.getClassLoader().getResource("invalidsTemplates");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        System.setErr(new PrintStream(out));

        try (ApplicationContext ctx = ApplicationContext.run(Map.of("kestra.templates.enabled", "true"), Environment.CLI, Environment.TEST)) {

            EmbeddedServer embeddedServer = ctx.getBean(EmbeddedServer.class);
            embeddedServer.start();

            String[] args = {
                "--server",
                embeddedServer.getURL().toString(),
                "--user",
                "myuser:pass:word",
                "io.kestra.tests",
                directory.getPath(),

            };
            Integer call = PicocliRunner.call(TemplateNamespaceUpdateCommand.class, ctx, args);

//            assertThat(call, is(1));
            assertThat(out.toString(), containsString("Unable to parse templates"));
            assertThat(out.toString(), containsString("must not be empty"));
        }
    }