Skip to content

Commit bcab9db

Browse files
committed
[Fix #737] Adding test module
Signed-off-by: fjtirado <[email protected]>
1 parent 3f1a2f6 commit bcab9db

File tree

69 files changed

+136
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+136
-177
lines changed

impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public SchemaValidator getValidator(SchemaInline inline) {
141141
private WorkflowPositionFactory positionFactory = () -> new QueueWorkflowPosition();
142142
private WorkflowIdFactory idFactory = () -> UlidCreator.getMonotonicUlid().toString();
143143
private ExecutorServiceFactory executorFactory = new DefaultExecutorServiceFactory();
144-
private EventConsumer<?, ?> eventConsumer = InMemoryEvents.get();
145-
private EventPublisher eventPublisher = InMemoryEvents.get();
144+
private EventConsumer<?, ?> eventConsumer;
145+
private EventPublisher eventPublisher;
146146
private RuntimeDescriptorFactory descriptorFactory =
147147
() -> new RuntimeDescriptor("reference impl", "1.0.0_alpha", Collections.emptyMap());
148148

@@ -193,12 +193,9 @@ public Builder withDescriptorFactory(RuntimeDescriptorFactory factory) {
193193
return this;
194194
}
195195

196-
public Builder withEventConsumer(EventConsumer<?, ?> eventConsumer) {
196+
public Builder withEventHandler(
197+
EventPublisher eventPublisher, EventConsumer<?, ?> eventConsumer) {
197198
this.eventConsumer = eventConsumer;
198-
return this;
199-
}
200-
201-
public Builder withEventPublisher(EventPublisher eventPublisher) {
202199
this.eventPublisher = eventPublisher;
203200
return this;
204201
}
@@ -222,6 +219,11 @@ public WorkflowApplication build() {
222219
.findFirst()
223220
.orElseGet(() -> DefaultTaskExecutorFactory.get());
224221
}
222+
if (eventConsumer == null && eventPublisher == null) {
223+
InMemoryEvents inMemory = new InMemoryEvents(executorFactory);
224+
eventPublisher = inMemory;
225+
eventConsumer = inMemory;
226+
}
225227
return new WorkflowApplication(this);
226228
}
227229
}

impl/core/src/main/java/io/serverlessworkflow/impl/events/InMemoryEvents.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package io.serverlessworkflow.impl.events;
1717

1818
import io.cloudevents.CloudEvent;
19-
import io.serverlessworkflow.impl.DefaultExecutorServiceFactory;
2019
import io.serverlessworkflow.impl.ExecutorServiceFactory;
2120
import java.util.Map;
2221
import java.util.concurrent.CompletableFuture;
@@ -30,15 +29,11 @@
3029
*/
3130
public class InMemoryEvents extends AbstractTypeConsumer implements EventPublisher {
3231

33-
private static InMemoryEvents instance = new InMemoryEvents();
34-
35-
private InMemoryEvents() {}
36-
37-
public static InMemoryEvents get() {
38-
return instance;
32+
public InMemoryEvents(ExecutorServiceFactory serviceFactory) {
33+
this.serviceFactory = serviceFactory;
3934
}
4035

41-
private ExecutorServiceFactory serviceFactory = new DefaultExecutorServiceFactory();
36+
private ExecutorServiceFactory serviceFactory;
4237

4338
private Map<String, Consumer<CloudEvent>> topicMap = new ConcurrentHashMap<>();
4439

impl/http/pom.xml

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,58 +16,5 @@
1616
<groupId>io.serverlessworkflow</groupId>
1717
<artifactId>serverlessworkflow-impl-core</artifactId>
1818
</dependency>
19-
<dependency>
20-
<groupId>io.serverlessworkflow</groupId>
21-
<artifactId>serverlessworkflow-jwt</artifactId>
22-
</dependency>
23-
<dependency>
24-
<groupId>org.glassfish.jersey.media</groupId>
25-
<artifactId>jersey-media-json-jackson</artifactId>
26-
</dependency>
27-
<dependency>
28-
<groupId>org.glassfish.jersey.core</groupId>
29-
<artifactId>jersey-client</artifactId>
30-
</dependency>
31-
<dependency>
32-
<groupId>io.serverlessworkflow</groupId>
33-
<artifactId>serverlessworkflow-api</artifactId>
34-
<scope>test</scope>
35-
</dependency>
36-
<dependency>
37-
<groupId>io.serverlessworkflow</groupId>
38-
<artifactId>serverlessworkflow-impl-jackson</artifactId>
39-
<scope>test</scope>
40-
</dependency>
41-
<dependency>
42-
<groupId>io.serverlessworkflow</groupId>
43-
<artifactId>serverlessworkflow-impl-jackson-jwt</artifactId>
44-
<scope>test</scope>
45-
</dependency>
46-
<dependency>
47-
<groupId>org.junit.jupiter</groupId>
48-
<artifactId>junit-jupiter-api</artifactId>
49-
</dependency>
50-
<dependency>
51-
<groupId>org.junit.jupiter</groupId>
52-
<artifactId>junit-jupiter-engine</artifactId>
53-
</dependency>
54-
<dependency>
55-
<groupId>org.junit.jupiter</groupId>
56-
<artifactId>junit-jupiter-params</artifactId>
57-
</dependency>
58-
<dependency>
59-
<groupId>org.assertj</groupId>
60-
<artifactId>assertj-core</artifactId>
61-
</dependency>
62-
<dependency>
63-
<groupId>ch.qos.logback</groupId>
64-
<artifactId>logback-classic</artifactId>
65-
<scope>test</scope>
66-
</dependency>
67-
<dependency>
68-
<groupId>com.squareup.okhttp3</groupId>
69-
<artifactId>mockwebserver</artifactId>
70-
<scope>test</scope>
71-
</dependency>
7219
</dependencies>
7320
</project>

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/OAuth2AuthProvider.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import io.serverlessworkflow.api.types.OAuth2AuthenticationPolicy;
1919
import io.serverlessworkflow.api.types.Oauth2;
2020
import io.serverlessworkflow.api.types.Workflow;
21-
import io.serverlessworkflow.http.jwt.JWT;
2221
import io.serverlessworkflow.impl.TaskContext;
2322
import io.serverlessworkflow.impl.WorkflowApplication;
2423
import io.serverlessworkflow.impl.WorkflowContext;
2524
import io.serverlessworkflow.impl.WorkflowModel;
25+
import io.serverlessworkflow.impl.executors.http.oauth.JWT;
2626
import io.serverlessworkflow.impl.executors.http.oauth.OAuthRequestBuilder;
2727
import jakarta.ws.rs.client.Invocation;
2828
import jakarta.ws.rs.client.Invocation.Builder;
@@ -54,11 +54,7 @@ public void preRequest(
5454
Invocation.Builder builder, WorkflowContext workflow, TaskContext task, WorkflowModel model) {
5555
JWT jwt = requestBuilder.build(workflow, task, model).validateAndGet();
5656
String type =
57-
jwt.claim("typ", String.class)
58-
.map(String::trim)
59-
.filter(t -> !t.isEmpty())
60-
.orElseThrow(() -> new IllegalStateException("Token type is not present"));
61-
57+
jwt.type().orElseThrow(() -> new IllegalStateException("Token type is not present"));
6258
builder.header(
6359
AuthProviderFactory.AUTH_HEADER_NAME, String.format(BEARER_TOKEN, type, jwt.token()));
6460
}

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/AccessTokenProvider.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package io.serverlessworkflow.impl.executors.http.oauth;
1717

18-
import io.serverlessworkflow.http.jwt.JWT;
19-
import io.serverlessworkflow.http.jwt.JWTConverter;
2018
import io.serverlessworkflow.impl.TaskContext;
2119
import java.util.List;
2220
import java.util.Map;

impl/jwt/src/main/java/io/serverlessworkflow/http/jwt/JWT.java renamed to impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/JWT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.serverlessworkflow.http.jwt;
16+
package io.serverlessworkflow.impl.executors.http.oauth;
1717

1818
import java.time.Instant;
1919
import java.util.List;

impl/jwt/src/main/java/io/serverlessworkflow/http/jwt/JWTConverter.java renamed to impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/oauth/JWTConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.serverlessworkflow.http.jwt;
16+
package io.serverlessworkflow.impl.executors.http.oauth;
1717

1818
public interface JWTConverter {
1919

impl/jackson/pom.xml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,5 @@
2828
<groupId>net.thisptr</groupId>
2929
<artifactId>jackson-jq</artifactId>
3030
</dependency>
31-
<dependency>
32-
<groupId>org.junit.jupiter</groupId>
33-
<artifactId>junit-jupiter-api</artifactId>
34-
<scope>test</scope>
35-
</dependency>
36-
<dependency>
37-
<groupId>org.junit.jupiter</groupId>
38-
<artifactId>junit-jupiter-engine</artifactId>
39-
<scope>test</scope>
40-
</dependency>
41-
<dependency>
42-
<groupId>org.junit.jupiter</groupId>
43-
<artifactId>junit-jupiter-params</artifactId>
44-
<scope>test</scope>
45-
</dependency>
46-
<dependency>
47-
<groupId>org.assertj</groupId>
48-
<artifactId>assertj-core</artifactId>
49-
<scope>test</scope>
50-
</dependency>
51-
<dependency>
52-
<groupId>ch.qos.logback</groupId>
53-
<artifactId>logback-classic</artifactId>
54-
<scope>test</scope>
55-
</dependency>
56-
<dependency>
57-
<groupId>org.mockito</groupId>
58-
<artifactId>mockito-core</artifactId>
59-
</dependency>
6031
</dependencies>
6132
</project>

impl/jackson/src/main/java/io/serverlessworkflow/impl/expressions/jq/JacksonModelFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import io.serverlessworkflow.impl.WorkflowModel;
2828
import io.serverlessworkflow.impl.WorkflowModelCollection;
2929
import io.serverlessworkflow.impl.WorkflowModelFactory;
30-
import io.serverlessworkflow.impl.events.json.JacksonCloudEventUtils;
3130
import io.serverlessworkflow.impl.jackson.JsonUtils;
31+
import io.serverlessworkflow.impl.jackson.events.JacksonCloudEventUtils;
3232
import java.math.BigDecimal;
3333
import java.time.OffsetDateTime;
3434
import java.util.Map;

impl/jackson/src/main/java/io/serverlessworkflow/impl/events/json/JacksonCloudEventUtils.java renamed to impl/jackson/src/main/java/io/serverlessworkflow/impl/jackson/events/JacksonCloudEventUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.serverlessworkflow.impl.events.json;
16+
package io.serverlessworkflow.impl.jackson.events;
1717

1818
import com.fasterxml.jackson.databind.JsonNode;
1919
import com.fasterxml.jackson.databind.node.NullNode;

0 commit comments

Comments
 (0)