Skip to content

Commit

Permalink
feat(core): add FlowService.findByNamespace
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mulier-p committed Dec 15, 2023
1 parent f61e974 commit 7716d64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/io/kestra/core/services/FlowService.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public Optional<Flow> findById(String tenantId, String namespace, String id) {
return flowRepository.findById(tenantId, namespace, id);
}

public List<Flow> findByNamespace(String tenantId, String namespace) {
return flowRepository.findByNamespace(tenantId, namespace);
}

public Stream<Flow> keepLastVersion(Stream<Flow> stream) {
return keepLastVersionCollector(stream);
}
Expand Down
12 changes: 12 additions & 0 deletions core/src/test/java/io/kestra/core/services/FlowServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit 7716d64

Please sign in to comment.