Skip to content

Commit 3ec260c

Browse files
committed
Minor refinements
Signed-off-by: fjtirado <ftirados@redhat.com>
1 parent f519a41 commit 3ec260c

File tree

2 files changed

+59
-21
lines changed

2 files changed

+59
-21
lines changed

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,28 @@ public WorkflowIdFactory idFactory() {
103103
}
104104

105105
public static class Builder {
106-
private static final SchemaValidatorFactory EMPTY_SCHEMA_VALIDATOR =
107-
new SchemaValidatorFactory() {
108-
109-
private final SchemaValidator NoValidation =
110-
new SchemaValidator() {
111-
@Override
112-
public void validate(WorkflowModel node) {}
113-
};
114-
115-
@Override
116-
public SchemaValidator getValidator(StaticResource resource) {
117-
118-
return NoValidation;
119-
}
120-
121-
@Override
122-
public SchemaValidator getValidator(SchemaInline inline) {
123-
return NoValidation;
124-
}
125-
};
106+
107+
private static final class EmptySchemaValidatorHolder {
108+
private static final SchemaValidatorFactory instance =
109+
new SchemaValidatorFactory() {
110+
private final SchemaValidator NoValidation =
111+
new SchemaValidator() {
112+
@Override
113+
public void validate(WorkflowModel node) {}
114+
};
115+
116+
@Override
117+
public SchemaValidator getValidator(StaticResource resource) {
118+
return NoValidation;
119+
}
120+
121+
@Override
122+
public SchemaValidator getValidator(SchemaInline inline) {
123+
return NoValidation;
124+
}
125+
};
126+
}
127+
126128
private TaskExecutorFactory taskFactory = DefaultTaskExecutorFactory.get();
127129
private ExpressionFactory exprFactory;
128130
private Collection<WorkflowExecutionListener> listeners;
@@ -207,7 +209,7 @@ public WorkflowApplication build() {
207209
schemaValidatorFactory =
208210
ServiceLoader.load(SchemaValidatorFactory.class)
209211
.findFirst()
210-
.orElse(EMPTY_SCHEMA_VALIDATOR);
212+
.orElseGet(() -> EmptySchemaValidatorHolder.instance);
211213
}
212214
return new WorkflowApplication(this);
213215
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.impl;
17+
18+
import static org.assertj.core.api.Assertions.assertThat;
19+
20+
import com.fasterxml.jackson.databind.JsonNode;
21+
import io.serverlessworkflow.impl.expressions.DateTimeDescriptor;
22+
import io.serverlessworkflow.impl.json.JsonUtils;
23+
import java.time.Instant;
24+
import org.junit.jupiter.api.Test;
25+
26+
class DateTimeDescriptorTest {
27+
28+
@Test
29+
void serializeDate() {
30+
DateTimeDescriptor descriptor = DateTimeDescriptor.from(Instant.now());
31+
32+
JsonNode node = JsonUtils.fromValue(descriptor);
33+
assertThat(node.get("iso8601").isTextual()).isTrue();
34+
assertThat(node.get("epoch").isObject()).isTrue();
35+
}
36+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy