Skip to content

Commit fd7eaf6

Browse files
committed
Fix tests folder
1 parent 2dafe4f commit fd7eaf6

File tree

8 files changed

+59
-8
lines changed

8 files changed

+59
-8
lines changed

src/main/java/com/github/parser/source/OperationBinder.java

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.github.parser.source;
22

3+
import com.fasterxml.jackson.databind.JsonNode;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import com.fasterxml.jackson.databind.node.TextNode;
36
import com.github.model.OpenAPIWorkflow;
47
import com.github.model.SourceDescription;
58
import com.github.model.Step;
@@ -13,6 +16,9 @@
1316
import org.slf4j.Logger;
1417
import org.slf4j.LoggerFactory;
1518

19+
import java.io.IOException;
20+
import java.net.MalformedURLException;
21+
import java.net.URL;
1622
import java.nio.file.Path;
1723
import java.nio.file.Paths;
1824
import java.util.ArrayList;
@@ -36,7 +42,11 @@ public void bind(OpenAPIWorkflow openAPIWorkflow) {
3642

3743
for(Workflow workflow : openAPIWorkflow.getWorkflows()) {
3844
for(Step step : workflow.getSteps()) {
39-
step.setOperation(findOperationById(step.getOperationId(), operations));
45+
if(step.getOperationId() != null) {
46+
step.setOperation(findOperationById(step.getOperationId(), operations));
47+
} else if(step.getOperationRef() != null) {
48+
step.setOperation(findOperationByRef(step.getOperationRef(), operations));
49+
}
4050
}
4151
}
4252
}
@@ -71,6 +81,46 @@ Operation findOperationById(String operationId, List<Operation> operations) {
7181
return operation;
7282
}
7383

84+
Operation findOperationByRef(String operationRef, List<Operation> operations) {
85+
Operation operation = null;
86+
87+
// TODO
88+
89+
// for(Operation o : operations) {
90+
//
91+
// if(operationRef != null && operationRef.equals(o.getOperationId())) {
92+
// operation = o;
93+
// }
94+
// }
95+
96+
return operation;
97+
}
98+
99+
100+
//
101+
// String getJsonReference(String jsonReference) throws IOException {
102+
// ObjectMapper objectMapper = new ObjectMapper();
103+
//
104+
// JsonNode jsonNode;
105+
//
106+
// if(isUrl(jsonReference)) {
107+
// jsonNode = objectMapper.readTree(new URL(jsonReference));
108+
// } else {
109+
// jsonNode = objectMapper.readTree(new URL(jsonReference));
110+
// }
111+
//
112+
// // Navigate to the node containing the reference
113+
// JsonNode referenceNode = jsonNode.at("/paths/users/~1findbystatus~1{status}/get");
114+
//
115+
// // Get the JSON reference as a string
116+
// String r = referenceNode.toString();
117+
//
118+
//
119+
// // Unescape the JSON reference
120+
// return jsonNode.isTextual() ? ((TextNode) jsonNode).asText() : jsonReference;
121+
//
122+
// }
123+
74124
String getRootFolder(String location) {
75125
if(isUrl(location)) {
76126
return location.substring(0, location.lastIndexOf("/") + 1);

src/test/com/github/parser/OpenAPIWorkflowParserTest.java renamed to src/test/java/com/github/parser/OpenAPIWorkflowParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class OpenAPIWorkflowParserTest {
99

1010
@Test
1111
void parse() {
12-
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
12+
final String WORKFLOWS_SPEC_FILE = "src/test/java/resources/1.0.0/pet-coupons.workflow.yaml";
1313

1414
OpenAPIWorkflowParserResult result = parser.parse(WORKFLOWS_SPEC_FILE);
1515
assertNotNull(result.getOpenAPIWorkflow());

src/test/com/github/parser/source/OperationBinderTest.java renamed to src/test/java/com/github/parser/source/OperationBinderTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.swagger.v3.oas.models.Operation;
77
import org.junit.jupiter.api.Test;
88

9+
import java.net.MalformedURLException;
910
import java.util.List;
1011

1112
import static org.junit.jupiter.api.Assertions.*;
@@ -16,7 +17,7 @@ class OperationBinderTest {
1617

1718
@Test
1819
void getOperations() {
19-
final String OPENAPI_FILE = "src/test/resources/1.0.0/pet-coupons.openapi.yaml";
20+
final String OPENAPI_FILE = "src/test/java/resources/1.0.0/pet-coupons.openapi.yaml";
2021
List<Operation> operations = binder.getOperations(OPENAPI_FILE);
2122

2223
assertNotNull(operations);
@@ -35,7 +36,7 @@ void getOperationsFromUrl() {
3536

3637
@Test
3738
void bind() {
38-
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
39+
final String WORKFLOWS_SPEC_FILE = "src/test/java/resources/1.0.0/pet-coupons.workflow.yaml";
3940

4041
OpenAPIWorkflowParserResult result = new OpenAPIWorkflowParser().parse(WORKFLOWS_SPEC_FILE);
4142

@@ -78,4 +79,6 @@ void bindFromUrl() {
7879
assertNull(workflowApplyCoupon.getSteps().get(2).getOperationId());
7980
assertEquals("place-order", workflowApplyCoupon.getSteps().get(2).getWorkflowId());
8081
}
82+
83+
8184
}

src/test/com/github/parser/source/WorkflowBinderTest.java renamed to src/test/java/com/github/parser/source/WorkflowBinderTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ class WorkflowBinderTest {
1414

1515
private WorkflowBinder binder = new WorkflowBinder();
1616

17-
18-
1917
@Test
2018
void bind() {
21-
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
19+
final String WORKFLOWS_SPEC_FILE = "src/test/java/resources/1.0.0/pet-coupons.workflow.yaml";
2220

2321
OpenAPIWorkflowParserResult result = new OpenAPIWorkflowParser().parse(WORKFLOWS_SPEC_FILE);
2422

File renamed without changes.

src/test/com/github/parser/util/PathUtilTest.java renamed to src/test/java/com/github/parser/util/PathUtilTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class PathUtilTest {
1010

1111
@Test
1212
void getFromFile() {
13-
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
13+
final String WORKFLOWS_SPEC_FILE = "src/test/java/resources/1.0.0/pet-coupons.workflow.yaml";
1414
assertFalse(pathUtil.getFromFile(WORKFLOWS_SPEC_FILE).isEmpty());
1515
}
1616

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)