Skip to content

Commit

Permalink
refactor(core): remove Worker constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Jun 23, 2024
1 parent 0fc39b9 commit 51ec983
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/test/java/io/kestra/plugin/couchbase/TriggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.kestra.core.repositories.LocalFlowRepositoryLoader;
import io.kestra.core.runners.Worker;
import io.kestra.core.schedulers.AbstractScheduler;
import io.kestra.core.utils.IdUtils;
import io.kestra.core.utils.TestsUtils;
import io.kestra.jdbc.runner.JdbcScheduler;
import io.kestra.core.services.FlowListenersInterface;
Expand Down Expand Up @@ -39,6 +40,7 @@ class TriggerTest extends CouchbaseTest {
@Inject
private LocalFlowRepositoryLoader localFlowRepositoryLoader;

@SuppressWarnings("unchecked")
@Test
void simpleQueryTrigger() throws Exception {
Execution execution = triggerFlow();
Expand All @@ -52,28 +54,31 @@ protected Execution triggerFlow() throws Exception {
CountDownLatch queueCount = new CountDownLatch(1);

// scheduler
Worker worker = new Worker(applicationContext, 8, null);
try (
AbstractScheduler scheduler = new JdbcScheduler(
this.applicationContext,
this.flowListenersService
);
) {
// wait for execution
Flux<Execution> receive = TestsUtils.receive(executionQueue, execution -> {
queueCount.countDown();
assertThat(execution.getLeft().getFlowId(), is("couchbase-listen"));
});
try (Worker worker = applicationContext.createBean(Worker.class, IdUtils.create(), 8, null)) {
try (
AbstractScheduler scheduler = new JdbcScheduler(
this.applicationContext,
this.flowListenersService
);
) {
// wait for execution
Flux<Execution> receive = TestsUtils.receive(executionQueue, execution -> {
queueCount.countDown();
assertThat(execution.getLeft().getFlowId(), is("couchbase-listen"));
});

worker.run();
scheduler.run();
worker.run();
scheduler.run();

localFlowRepositoryLoader.load(this.getClass().getClassLoader().getResource("flows/couchbase-listen.yml"));
localFlowRepositoryLoader.load(this.getClass()
.getClassLoader()
.getResource("flows/couchbase-listen.yml"));

boolean await = queueCount.await(1, TimeUnit.MINUTES);
assertThat(await, is(true));
boolean await = queueCount.await(1, TimeUnit.MINUTES);
assertThat(await, is(true));

return receive.blockLast();
return receive.blockLast();
}
}
}
}

0 comments on commit 51ec983

Please sign in to comment.