Skip to content

Commit b6d4fee

Browse files
committed
Adding tests for Accessors, constructors and other methods
1 parent 6f23b61 commit b6d4fee

File tree

5 files changed

+379
-13
lines changed

5 files changed

+379
-13
lines changed

conductor-clients/java/conductor-java-sdk/conductor-client/src/test/java/com/netflix/conductor/common/metadata/tasks/TestTaskDefPojoMethods.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ void testToString() {
377377
assertEquals(name, taskDef.toString());
378378
}
379379

380+
private final SchemaDef inputSchema = new SchemaDef();
381+
private final SchemaDef outputSchema = new SchemaDef();
382+
380383
@Test
381384
void testEqualsAndHashCode() {
382385
TaskDef taskDef1 = createFullTaskDef("task1");
@@ -429,10 +432,8 @@ private TaskDef createFullTaskDef(String name) {
429432
taskDef.setBackoffScaleFactor(2);
430433
taskDef.setBaseType("baseType");
431434

432-
SchemaDef inputSchema = new SchemaDef();
435+
// Use the shared schema instances
433436
taskDef.setInputSchema(inputSchema);
434-
435-
SchemaDef outputSchema = new SchemaDef();
436437
taskDef.setOutputSchema(outputSchema);
437438

438439
taskDef.setEnforceSchema(true);

conductor-clients/java/conductor-java-sdk/conductor-client/src/test/java/com/netflix/conductor/common/metadata/workflow/TestDynamicForkJoinTaskPojoMethods.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void testConstructorWithFiveParams() {
5858
Map<String, Object> input = new HashMap<>();
5959
input.put("key1", "value1");
6060

61-
DynamicForkJoinTask task = new DynamicForkJoinTask(taskName, workflowName, referenceName, input, type);
61+
DynamicForkJoinTask task = new DynamicForkJoinTask(taskName, workflowName, referenceName, type, input);
6262

6363
assertEquals(taskName, task.getTaskName());
6464
assertEquals(workflowName, task.getWorkflowName());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* Copyright 2025 Conductor Authors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
* <p>
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* <p>
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package io.orkes.conductor.client.model;
14+
15+
import org.junit.jupiter.api.Test;
16+
17+
import static org.junit.jupiter.api.Assertions.*;
18+
19+
class TestConductorApplicationPojoMethods {
20+
21+
@Test
22+
void testConstructor() {
23+
ConductorApplication application = new ConductorApplication();
24+
assertNotNull(application);
25+
assertNull(application.getId());
26+
assertNull(application.getName());
27+
assertNull(application.getCreatedBy());
28+
}
29+
30+
@Test
31+
void testGetSetId() {
32+
ConductorApplication application = new ConductorApplication();
33+
String id = "app123";
34+
application.setId(id);
35+
assertEquals(id, application.getId());
36+
}
37+
38+
@Test
39+
void testGetSetName() {
40+
ConductorApplication application = new ConductorApplication();
41+
String name = "testApp";
42+
application.setName(name);
43+
assertEquals(name, application.getName());
44+
}
45+
46+
@Test
47+
void testGetSetCreatedBy() {
48+
ConductorApplication application = new ConductorApplication();
49+
String createdBy = "user1";
50+
application.setCreatedBy(createdBy);
51+
assertEquals(createdBy, application.getCreatedBy());
52+
}
53+
54+
@Test
55+
void testFluentId() {
56+
String id = "app123";
57+
ConductorApplication application = new ConductorApplication().id(id);
58+
assertEquals(id, application.getId());
59+
}
60+
61+
@Test
62+
void testFluentName() {
63+
String name = "testApp";
64+
ConductorApplication application = new ConductorApplication().name(name);
65+
assertEquals(name, application.getName());
66+
}
67+
68+
@Test
69+
void testFluentCreatedBy() {
70+
String createdBy = "user1";
71+
ConductorApplication application = new ConductorApplication().createdBy(createdBy);
72+
assertEquals(createdBy, application.getCreatedBy());
73+
}
74+
75+
@Test
76+
void testChainedFluent() {
77+
String id = "app123";
78+
String name = "testApp";
79+
String createdBy = "user1";
80+
81+
ConductorApplication application = new ConductorApplication()
82+
.id(id)
83+
.name(name)
84+
.createdBy(createdBy);
85+
86+
assertEquals(id, application.getId());
87+
assertEquals(name, application.getName());
88+
assertEquals(createdBy, application.getCreatedBy());
89+
}
90+
91+
@Test
92+
void testEquals() {
93+
ConductorApplication app1 = new ConductorApplication()
94+
.id("app123")
95+
.name("testApp")
96+
.createdBy("user1");
97+
98+
ConductorApplication app2 = new ConductorApplication()
99+
.id("app123")
100+
.name("testApp")
101+
.createdBy("user1");
102+
103+
ConductorApplication app3 = new ConductorApplication()
104+
.id("app456")
105+
.name("testApp")
106+
.createdBy("user1");
107+
108+
assertEquals(app1, app2);
109+
assertNotEquals(app1, app3);
110+
assertNotEquals(app1, null);
111+
assertNotEquals(app1, new Object());
112+
}
113+
114+
@Test
115+
void testHashCode() {
116+
ConductorApplication app1 = new ConductorApplication()
117+
.id("app123")
118+
.name("testApp")
119+
.createdBy("user1");
120+
121+
ConductorApplication app2 = new ConductorApplication()
122+
.id("app123")
123+
.name("testApp")
124+
.createdBy("user1");
125+
126+
assertEquals(app1.hashCode(), app2.hashCode());
127+
}
128+
129+
@Test
130+
void testToString() {
131+
ConductorApplication application = new ConductorApplication()
132+
.id("app123")
133+
.name("testApp")
134+
.createdBy("user1");
135+
136+
String toString = application.toString();
137+
138+
assertTrue(toString.contains("app123"));
139+
assertTrue(toString.contains("testApp"));
140+
assertTrue(toString.contains("user1"));
141+
}
142+
}

conductor-clients/java/conductor-java-sdk/orkes-client/src/test/java/io/orkes/conductor/client/model/TestGrantedAccessPojoMethods.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ void testAllArgsConstructor() {
3737
);
3838
TargetRef targetRef = new TargetRef();
3939

40-
GrantedAccess grantedAccess = new GrantedAccess(accessList, targetRef);
40+
// Create using available methods instead of constructor
41+
GrantedAccess grantedAccess = new GrantedAccess();
42+
grantedAccess.setAccess(accessList);
43+
grantedAccess.setTarget(targetRef);
4144

4245
assertEquals(accessList, grantedAccess.getAccess());
4346
assertEquals(targetRef, grantedAccess.getTarget());
@@ -51,10 +54,10 @@ void testBuilder() {
5154
);
5255
TargetRef targetRef = new TargetRef();
5356

54-
GrantedAccess grantedAccess = GrantedAccess.builder()
57+
// Use fluent interface methods instead of builder
58+
GrantedAccess grantedAccess = new GrantedAccess()
5559
.access(accessList)
56-
.target(targetRef)
57-
.build();
60+
.target(targetRef);
5861

5962
assertEquals(accessList, grantedAccess.getAccess());
6063
assertEquals(targetRef, grantedAccess.getTarget());
@@ -142,12 +145,17 @@ void testFluentTargetMethod() {
142145

143146
@Test
144147
void testEqualsAndHashCode() {
145-
// Create two identical objects
148+
// Create two identical objects using available methods
146149
List<GrantedAccess.AccessEnum> accessList1 = Arrays.asList(GrantedAccess.AccessEnum.READ);
147150
TargetRef targetRef1 = new TargetRef();
148151

149-
GrantedAccess grantedAccess1 = new GrantedAccess(accessList1, targetRef1);
150-
GrantedAccess grantedAccess2 = new GrantedAccess(accessList1, targetRef1);
152+
GrantedAccess grantedAccess1 = new GrantedAccess();
153+
grantedAccess1.setAccess(accessList1);
154+
grantedAccess1.setTarget(targetRef1);
155+
156+
GrantedAccess grantedAccess2 = new GrantedAccess();
157+
grantedAccess2.setAccess(accessList1);
158+
grantedAccess2.setTarget(targetRef1);
151159

152160
// Test equals
153161
assertEquals(grantedAccess1, grantedAccess2);
@@ -156,7 +164,9 @@ void testEqualsAndHashCode() {
156164

157165
// Create different object
158166
List<GrantedAccess.AccessEnum> accessList2 = Arrays.asList(GrantedAccess.AccessEnum.UPDATE);
159-
GrantedAccess grantedAccess3 = new GrantedAccess(accessList2, targetRef1);
167+
GrantedAccess grantedAccess3 = new GrantedAccess();
168+
grantedAccess3.setAccess(accessList2);
169+
grantedAccess3.setTarget(targetRef1);
160170

161171
// Test not equals
162172
assertNotEquals(grantedAccess1, grantedAccess3);
@@ -205,4 +215,4 @@ void testAccessEnumToString() {
205215
assertEquals("DELETE", GrantedAccess.AccessEnum.DELETE.toString());
206216
assertEquals("EXECUTE", GrantedAccess.AccessEnum.EXECUTE.toString());
207217
}
208-
}
218+
}

0 commit comments

Comments
 (0)