Skip to content

Commit b4e14f0

Browse files
committed
test: create validation scenarion
Signed-off-by: Otavio Santana <[email protected]>
1 parent fd7de86 commit b4e14f0

File tree

6 files changed

+254
-7
lines changed

6 files changed

+254
-7
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
15+
package org.eclipse.jnosql.mapping.document.entities;
16+
17+
public enum MainStepType {
18+
MAIN, ENTRY
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
15+
package org.eclipse.jnosql.mapping.document.entities;
16+
17+
18+
public enum StepTransitionReason {
19+
20+
REPEAT
21+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
15+
package org.eclipse.jnosql.mapping.document.entities;
16+
17+
import jakarta.nosql.Column;
18+
import org.eclipse.jnosql.mapping.Embeddable;
19+
20+
import java.util.List;
21+
22+
@Embeddable
23+
public class Transition {
24+
25+
@Column
26+
private String targetWorkflowStepKey;
27+
@Column
28+
private StepTransitionReason stepTransitionReason;
29+
@Column
30+
private String mailTemplateKey;
31+
@Column
32+
private List<String> restrictedRoleGroups;
33+
34+
public Transition(String targetWorkflowStepKey,
35+
StepTransitionReason stepTransitionReason,
36+
String mailTemplateKey,
37+
List<String> restrictedRoleGroups) {
38+
this.targetWorkflowStepKey = targetWorkflowStepKey;
39+
this.stepTransitionReason = stepTransitionReason;
40+
this.mailTemplateKey = mailTemplateKey;
41+
this.restrictedRoleGroups = restrictedRoleGroups;
42+
}
43+
44+
public Transition() {
45+
}
46+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
15+
package org.eclipse.jnosql.mapping.document.entities;
16+
17+
import jakarta.nosql.Column;
18+
import jakarta.nosql.Entity;
19+
import jakarta.nosql.Id;
20+
21+
import java.util.List;
22+
23+
@Entity("workflow_step")
24+
public class WorkflowStep {
25+
26+
@Id
27+
private String id;
28+
29+
@Column("_key")
30+
private String key;
31+
32+
@Column
33+
private String workflowSchemaKey;
34+
35+
@Column
36+
private String stepName;
37+
38+
@Column
39+
private MainStepType mainStepType;
40+
41+
@Column
42+
private Integer stepNo;
43+
44+
@Column
45+
private String componentConfigurationKey;
46+
47+
@Column
48+
private String relationTypeKey;
49+
50+
@Column
51+
private List<Transition> availableTransitions;
52+
53+
WorkflowStep(String id, String key, String workflowSchemaKey,
54+
String stepName, MainStepType mainStepType,
55+
Integer stepNo, String componentConfigurationKey,
56+
String relationTypeKey, List<Transition> availableTransitions) {
57+
this.id = id;
58+
this.key = key;
59+
this.workflowSchemaKey = workflowSchemaKey;
60+
this.stepName = stepName;
61+
this.mainStepType = mainStepType;
62+
this.stepNo = stepNo;
63+
this.componentConfigurationKey = componentConfigurationKey;
64+
this.relationTypeKey = relationTypeKey;
65+
this.availableTransitions = availableTransitions;
66+
}
67+
68+
WorkflowStep() {
69+
}
70+
71+
public static WorkflowStepBuilder builder() {
72+
return new WorkflowStepBuilder();
73+
}
74+
75+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
15+
package org.eclipse.jnosql.mapping.document.entities;
16+
17+
import java.util.List;
18+
19+
public class WorkflowStepBuilder {
20+
private String id;
21+
private String key;
22+
private String workflowSchemaKey;
23+
private String stepName;
24+
private MainStepType mainStepType;
25+
private Integer stepNo;
26+
private String componentConfigurationKey;
27+
private String relationTypeKey;
28+
private List<Transition> availableTransitions;
29+
30+
public WorkflowStepBuilder id(String id) {
31+
this.id = id;
32+
return this;
33+
}
34+
35+
public WorkflowStepBuilder key(String key) {
36+
this.key = key;
37+
return this;
38+
}
39+
40+
public WorkflowStepBuilder workflowSchemaKey(String workflowSchemaKey) {
41+
this.workflowSchemaKey = workflowSchemaKey;
42+
return this;
43+
}
44+
45+
public WorkflowStepBuilder stepName(String stepName) {
46+
this.stepName = stepName;
47+
return this;
48+
}
49+
50+
public WorkflowStepBuilder mainStepType(MainStepType mainStepType) {
51+
this.mainStepType = mainStepType;
52+
return this;
53+
}
54+
55+
public WorkflowStepBuilder stepNo(Integer stepNo) {
56+
this.stepNo = stepNo;
57+
return this;
58+
}
59+
60+
public WorkflowStepBuilder componentConfigurationKey(String componentConfigurationKey) {
61+
this.componentConfigurationKey = componentConfigurationKey;
62+
return this;
63+
}
64+
65+
public WorkflowStepBuilder relationTypeKey(String relationTypeKey) {
66+
this.relationTypeKey = relationTypeKey;
67+
return this;
68+
}
69+
70+
public WorkflowStepBuilder availableTransitions(List<Transition> availableTransitions) {
71+
this.availableTransitions = availableTransitions;
72+
return this;
73+
}
74+
75+
public WorkflowStep build() {
76+
return new WorkflowStep(id, key, workflowSchemaKey, stepName, mainStepType,
77+
stepNo, componentConfigurationKey, relationTypeKey, availableTransitions);
78+
}
79+
}

jnosql-database-commons/src/test/java/org/eclipse/jnosql/communication/driver/ValueUtilTest.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package org.eclipse.jnosql.communication.driver;
1616

1717
import org.eclipse.jnosql.communication.Value;
18+
import org.junit.jupiter.api.Assertions;
1819
import org.junit.jupiter.api.Test;
1920

2021
import java.util.Arrays;
@@ -26,48 +27,54 @@
2627
class ValueUtilTest {
2728

2829
@Test
29-
public void shouldConvert() {
30+
void shouldConvert() {
3031
Value value = Value.of(10);
3132
assertEquals(10, ValueUtil.convert(value));
3233
}
3334

3435
@Test
35-
public void shouldConvert2() {
36+
void shouldConvert2() {
3637
Value value = Value.of(Arrays.asList(10, 20));
3738
assertEquals(Arrays.asList(10, 20), ValueUtil.convert(value));
3839
}
3940

4041
@Test
41-
public void shouldConvert3() {
42+
void shouldConvert3() {
4243
Value value = Value.of(Arrays.asList(Value.of(10), Value.of(20)));
4344
assertEquals(Arrays.asList(10, 20), ValueUtil.convert(value));
4445
}
4546

4647
@Test
47-
public void shouldConvertList() {
48+
void shouldConvertList() {
4849
Value value = Value.of(10);
4950
assertEquals(Collections.singletonList(10), ValueUtil.convertToList(value));
5051
}
5152

5253
@Test
53-
public void shouldConvertList2() {
54+
void shouldConvertList2() {
5455
Value value = Value.of(Arrays.asList(10, 20));
5556
assertEquals(Arrays.asList(10, 20), ValueUtil.convertToList(value));
5657
}
5758

5859

5960
@Test
60-
public void shouldConvertList3() {
61+
void shouldConvertList3() {
6162
Value value = Value.of(Arrays.asList(Value.of(10), Value.of(20)));
6263
assertEquals(Arrays.asList(10, 20), ValueUtil.convertToList(value));
6364
}
6465

6566
@Test
66-
public void shouldConvertNull() {
67+
void shouldConvertNull() {
6768
Value value = Value.of(null);
6869
assertNull(ValueUtil.convert(value));
6970
}
7071

72+
@Test
73+
void shouldReturnNullWhenValueUtilHasNullValue() {
74+
Object result = ValueUtil.convert(Value.ofNull());
75+
Assertions.assertNull(result);
76+
}
77+
7178

7279

7380
}

0 commit comments

Comments
 (0)