-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflow & activities discovery unit test
- Loading branch information
Loic Hermann
authored and
Loic Hermann
committed
Aug 12, 2024
1 parent
dcc8bbf
commit d5d9201
Showing
14 changed files
with
234 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...t/java/io/quarkiverse/temporal/deployment/SameActivityDiscoveryOnDifferentWorkerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.quarkiverse.temporal.deployment; | ||
|
||
import io.quarkiverse.temporal.deployment.discovery.DefaultSimpleActivityImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.DefaultSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.NamedSimpleActivityImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.NamedSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.SimpleActivity; | ||
import io.quarkiverse.temporal.deployment.discovery.SimpleWorkflow; | ||
import io.quarkus.maven.dependency.Dependency; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.util.List; | ||
|
||
public class SameActivityDiscoveryOnDifferentWorkerTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setForcedDependencies(List.of(Dependency.of("io.quarkiverse.temporal", "quarkus-temporal-test", "999-SNAPSHOT"))) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(SimpleActivity.class) | ||
.addClass(DefaultSimpleActivityImpl.class) | ||
.addClass(NamedSimpleActivityImpl.class) | ||
.addAsResource( | ||
new StringAsset("quarkus.temporal.enable-mock: true\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testSameActivityDiscoveryOnSameWorker() { | ||
// should be called, this deployment is valid: | ||
// it is legal to to have two different implementation of the same workflow on different workers | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...c/test/java/io/quarkiverse/temporal/deployment/SameActivityDiscoveryOnSameWorkerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkiverse.temporal.deployment; | ||
|
||
import io.quarkiverse.temporal.deployment.discovery.DefaultSimpleActivityImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.DefaultSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.DuplicateDefaultSimpleActivityImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.DuplicateDefaultSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.NamedSimpleActivityImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.SimpleActivity; | ||
import io.quarkiverse.temporal.deployment.discovery.SimpleWorkflow; | ||
import io.quarkus.maven.dependency.Dependency; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.util.List; | ||
|
||
public class SameActivityDiscoveryOnSameWorkerTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setForcedDependencies(List.of(Dependency.of("io.quarkiverse.temporal", "quarkus-temporal-test", "999-SNAPSHOT"))) | ||
.assertException(ex -> { | ||
Assertions.assertEquals(IllegalStateException.class, ex.getClass()); | ||
Assertions.assertEquals("Activity io.quarkiverse.temporal.deployment.discovery.SimpleActivity has more than one implementor on worker", ex.getMessage()); | ||
}) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(SimpleActivity.class) | ||
.addClass(DefaultSimpleActivityImpl.class) | ||
.addClass(DuplicateDefaultSimpleActivityImpl.class) | ||
.addAsResource( | ||
new StringAsset("quarkus.temporal.enable-mock: true\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testSameActivityDiscoveryOnSameWorker() { | ||
// should not be called, deployment exception should happen first: | ||
// it's illegal to have two workflow implementation on the same worker | ||
Assertions.fail(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...t/java/io/quarkiverse/temporal/deployment/SameWorkflowDiscoveryOnDifferentWorkerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.quarkiverse.temporal.deployment; | ||
|
||
import io.quarkiverse.temporal.deployment.discovery.DefaultSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.DuplicateDefaultSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.NamedSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.SimpleWorkflow; | ||
import io.quarkus.maven.dependency.Dependency; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.util.List; | ||
|
||
public class SameWorkflowDiscoveryOnDifferentWorkerTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setForcedDependencies(List.of(Dependency.of("io.quarkiverse.temporal", "quarkus-temporal-test", "999-SNAPSHOT"))) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(SimpleWorkflow.class) | ||
.addClass(DefaultSimpleWorkflowImpl.class) | ||
.addClass(NamedSimpleWorkflowImpl.class) | ||
.addAsResource( | ||
new StringAsset("quarkus.temporal.enable-mock: true\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testSameWorkflowDiscoveryOnSameWorker() { | ||
// should be called, this deployment is valid: | ||
// it is legal to to have two different implementation of the same workflow on different workers | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...c/test/java/io/quarkiverse/temporal/deployment/SameWorkflowDiscoveryOnSameWorkerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkiverse.temporal.deployment; | ||
|
||
import io.quarkiverse.temporal.deployment.discovery.DefaultSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.DuplicateDefaultSimpleWorkflowImpl; | ||
import io.quarkiverse.temporal.deployment.discovery.SimpleWorkflow; | ||
import io.quarkus.maven.dependency.Dependency; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.util.List; | ||
|
||
public class SameWorkflowDiscoveryOnSameWorkerTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setForcedDependencies(List.of(Dependency.of("io.quarkiverse.temporal", "quarkus-temporal-test", "999-SNAPSHOT"))) | ||
.assertException(ex -> { | ||
Assertions.assertEquals(IllegalStateException.class, ex.getClass()); | ||
Assertions.assertEquals("Workflow io.quarkiverse.temporal.deployment.discovery.SimpleWorkflow has more than one implementor on worker", ex.getMessage()); | ||
}) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(SimpleWorkflow.class) | ||
.addClass(DefaultSimpleWorkflowImpl.class) | ||
.addClass(DuplicateDefaultSimpleWorkflowImpl.class) | ||
.addAsResource( | ||
new StringAsset("quarkus.temporal.enable-mock: true\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testSameWorkflowDiscoveryOnSameWorker() { | ||
// should not be called, deployment exception should happen first: | ||
// it's illegal to have two workflow implementation on the same worker | ||
Assertions.fail(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...src/test/java/io/quarkiverse/temporal/deployment/discovery/DefaultSimpleActivityImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.quarkiverse.temporal.deployment.discovery; | ||
|
||
public class DefaultSimpleActivityImpl implements SimpleActivity { | ||
@Override | ||
public void withdraw() { | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...src/test/java/io/quarkiverse/temporal/deployment/discovery/DefaultSimpleWorkflowImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.quarkiverse.temporal.deployment.discovery; | ||
|
||
public class DefaultSimpleWorkflowImpl implements SimpleWorkflow { | ||
|
||
@Override | ||
public void transfer() { | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...java/io/quarkiverse/temporal/deployment/discovery/DuplicateDefaultSimpleActivityImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.quarkiverse.temporal.deployment.discovery; | ||
|
||
public class DuplicateDefaultSimpleActivityImpl implements SimpleActivity { | ||
@Override | ||
public void withdraw() { | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...java/io/quarkiverse/temporal/deployment/discovery/DuplicateDefaultSimpleWorkflowImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.quarkiverse.temporal.deployment.discovery; | ||
|
||
public class DuplicateDefaultSimpleWorkflowImpl implements SimpleWorkflow { | ||
|
||
@Override | ||
public void transfer() { | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...t/src/test/java/io/quarkiverse/temporal/deployment/discovery/NamedSimpleActivityImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.quarkiverse.temporal.deployment.discovery; | ||
|
||
import io.quarkiverse.temporal.ActivityImpl; | ||
|
||
@ActivityImpl(workers = "namedWorker") | ||
public class NamedSimpleActivityImpl implements SimpleActivity { | ||
@Override | ||
public void withdraw() { | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...t/src/test/java/io/quarkiverse/temporal/deployment/discovery/NamedSimpleWorkflowImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.quarkiverse.temporal.deployment.discovery; | ||
|
||
import io.quarkiverse.temporal.WorkflowImpl; | ||
|
||
@WorkflowImpl(workers = "namedWorker") | ||
public class NamedSimpleWorkflowImpl implements SimpleWorkflow { | ||
|
||
@Override | ||
public void transfer() { | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...deployment/src/test/java/io/quarkiverse/temporal/deployment/discovery/SimpleActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.quarkiverse.temporal.deployment.discovery; | ||
|
||
import io.temporal.activity.ActivityInterface; | ||
import io.temporal.activity.ActivityMethod; | ||
|
||
@ActivityInterface | ||
public interface SimpleActivity { | ||
@ActivityMethod | ||
void withdraw(); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...deployment/src/test/java/io/quarkiverse/temporal/deployment/discovery/SimpleWorkflow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.quarkiverse.temporal.deployment.discovery; | ||
|
||
import io.temporal.workflow.WorkflowInterface; | ||
import io.temporal.workflow.WorkflowMethod; | ||
|
||
@WorkflowInterface | ||
public interface SimpleWorkflow { | ||
|
||
@WorkflowMethod | ||
void transfer(); | ||
} |