diff --git a/core/src/main/java/io/kestra/core/services/FlowService.java b/core/src/main/java/io/kestra/core/services/FlowService.java index 222f1949829..5e27c716b5e 100644 --- a/core/src/main/java/io/kestra/core/services/FlowService.java +++ b/core/src/main/java/io/kestra/core/services/FlowService.java @@ -72,6 +72,10 @@ public Optional findById(String tenantId, String namespace, String id) { return flowRepository.findById(tenantId, namespace, id); } + public List findByNamespace(String tenantId, String namespace) { + return flowRepository.findByNamespace(tenantId, namespace); + } + public Stream keepLastVersion(Stream stream) { return keepLastVersionCollector(stream); } diff --git a/core/src/test/java/io/kestra/core/services/FlowServiceTest.java b/core/src/test/java/io/kestra/core/services/FlowServiceTest.java index 9af285330f0..9fb36492478 100644 --- a/core/src/test/java/io/kestra/core/services/FlowServiceTest.java +++ b/core/src/test/java/io/kestra/core/services/FlowServiceTest.java @@ -116,4 +116,16 @@ public void findById() { assertThat(flowService.findById("my-tenant", "io.kestra.unittest", "test").isPresent(), is(true)); assertThat(flowService.findById(null, "io.kestra.unittest", "test").isPresent(), is(false)); } + + @Test + public void findByNamespace() { + Flow flow = create("my-tenant", "test", "test", 1); + flowRepository.create(flow, flow.generateSource(), flow); + flow = create("my-tenant", "test2", "test", 1); + flowRepository.create(flow, flow.generateSource(), flow); + + assertThat(flowService.findByNamespace("my-tenant", "io.kestra.unittest").size(), is(2)); + assertThat(flowService.findByNamespace("my-tenant", "io.kestra.unittes").isEmpty(), is(true)); + assertThat(flowService.findByNamespace(null, "io.kestra.unittest").isEmpty(), is(true)); + } } \ No newline at end of file