Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
test: Refactor IntegrationResourceTest v2
Browse files Browse the repository at this point in the history
  • Loading branch information
mkralik3 authored and Delawen committed Jul 19, 2023
1 parent acffcff commit 5be6866
Show file tree
Hide file tree
Showing 10 changed files with 325 additions and 576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.kaoto.backend.camel.model.deployment.kamelet.KameletBinding;
import io.kaoto.backend.model.step.Step;
import io.quarkus.test.common.http.TestHTTPEndpoint;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -124,7 +125,7 @@ void amqAmq() throws Exception {
@Test
void amqAmqFromJson() throws Exception {
String json = Files.readString(Path.of(
DeploymentsResourceTest.class.getResource("../amq-amq.json").toURI()));
DeploymentsResourceTest.class.getResource("../integrationsV1only/amq-amq.json").toURI()));

var res = given()
.when()
Expand Down Expand Up @@ -171,7 +172,7 @@ void amqAmqFromJson() throws Exception {
void newBranchStep() throws Exception {
String json = Files.readString(Path.of(
IntegrationsResourceTestAbstract.class.getResource(
"../new-branch-step.json")
"../integrationsV1only/new-branch-step.json")
.toURI()));
var res = given()
.when()
Expand All @@ -190,7 +191,7 @@ void newBranchStep() throws Exception {
void scriptStep() throws Exception {
String json = Files.readString(Path.of(
IntegrationsResourceTestAbstract.class.getResource(
"../script.json")
"../integrationsV1only/script.json")
.toURI()));
var res = given()
.when()
Expand All @@ -210,7 +211,7 @@ void scriptStep() throws Exception {
.statusCode(Response.Status.OK.getStatusCode());

var flow = res.extract().body().as(Integration.class);
assertEquals(2, flow.getSteps().size());
assertThat(flow.getSteps()).hasSize(2);
Step script = flow.getSteps().get(1);
var groovy = script.getParameters().stream().filter(p -> "groovy".equals(p.getId())).findAny();
assertTrue(groovy.isPresent());
Expand All @@ -234,7 +235,7 @@ void expressionObject() throws Exception {

res = given()
.when()
.contentType("application/json")
.contentType(MediaType.APPLICATION_JSON)
.body(json)
.post("?dsl=Camel Route")
.then()
Expand All @@ -250,39 +251,39 @@ void expressionObject() throws Exception {
var delay = (Map<String, Object>) ((Map<String, Object>) steps.get(1)).get("delay");
assertExpression("delay", "simple", delay);
var drouter = (Map<String, Object>) ((Map<String, Object>) steps.get(2)).get("dynamic-router");
assertExpression("dynamic-router", "simple", drouter);
assertExpression("dynamic-router-exp", "simple", drouter);
var enrich = (Map<String, Object>) ((Map<String, Object>) steps.get(3)).get("enrich");
assertExpression("enrich", "simple", enrich);
assertExpression("enrich-exp", "simple", enrich);
var filter = (Map<String, Object>) ((Map<String, Object>) steps.get(4)).get("filter");
assertExpression("filter", "simple", filter);
assertExpression("filter-exp", "simple", filter);
var penrich = (Map<String, Object>) ((Map<String, Object>) steps.get(5)).get("poll-enrich");
assertExpression("poll-enrich", "simple", penrich);
assertExpression("poll-enrich-exp", "simple", penrich);
var rlist = (Map<String, Object>) ((Map<String, Object>) steps.get(6)).get("recipient-list");
assertExpression("recipient-list", "simple", rlist);
assertExpression("recipient-list-exp", "simple", rlist);
var resequence = (Map<String, Object>) ((Map<String, Object>) steps.get(7)).get("resequence");
assertExpression("resequence", "simple", resequence);
assertExpression("resequence-exp", "simple", resequence);
var rslip = (Map<String, Object>) ((Map<String, Object>) steps.get(8)).get("routing-slip");
assertExpression("routing-slip", "simple", rslip);
assertExpression("routing-slip-exp", "simple", rslip);
var script = (Map<String, Object>) ((Map<String, Object>) steps.get(9)).get("script");
assertExpression("script", "groovy", script);
assertExpression("script-exp", "groovy", script);
var scall = (Map<String, Object>) ((Map<String, Object>) steps.get(10)).get("service-call");
assertExpression("service-call", "jsonpath", scall);
assertExpression("service-call-exp", "jsonpath", scall);
var sbody = (Map<String, Object>) ((Map<String, Object>) steps.get(11)).get("set-body");
assertExpression("set-body", "constant", sbody);
assertExpression("set-body-exp", "constant", sbody);
var sheader = (Map<String, Object>) ((Map<String, Object>) steps.get(12)).get("set-header");
assertExpression("set-header", "jq", sheader);
assertExpression("set-header-exp", "jq", sheader);
var sprop = (Map<String, Object>) ((Map<String, Object>) steps.get(13)).get("set-property");
assertExpression("set-property", "jq", sprop);
assertExpression("set-property-exp", "jq", sprop);
var sort = (Map<String, Object>) ((Map<String, Object>) steps.get(14)).get("sort");
assertExpression("sort", "simple", sort);
assertExpression("sort-exp", "simple", sort);
var split = (Map<String, Object>) ((Map<String, Object>) steps.get(15)).get("split");
assertExpression("split", "simple", split);
assertExpression("split-exp", "simple", split);
var throttle = (Map<String, Object>) ((Map<String, Object>) steps.get(16)).get("throttle");
assertExpression("throttle", "simple", throttle);
assertExpression("throttle-exp", "simple", throttle);
var transform = (Map<String, Object>) ((Map<String, Object>) steps.get(17)).get("transform");
assertExpression("transform", "jq", transform);
assertExpression("transform-exp", "jq", transform);
var validate = (Map<String, Object>) ((Map<String, Object>) steps.get(18)).get("validate");
assertExpression("validate", "simple", validate);
assertExpression("validate-exp", "simple", validate);
var dotry = (Map<String, Object>) ((Map<String, Object>) steps.get(19)).get("do-try");
var docatch0 = (Map<String, Object>) ((List<Object>) dotry.get("do-catch")).get(0);
var onwhen = (Map<String, Object>) docatch0.get("on-when");
Expand Down Expand Up @@ -356,7 +357,7 @@ void uriLogStop() throws Exception {
void noFrom() throws Exception {
String json = Files.readString(Path.of(
IntegrationsResourceTestAbstract.class.getResource(
"../no-from.json")
"../integrationsV1only/no-from.json")
.toURI()));
var res = given()
.when()
Expand Down
Loading

0 comments on commit 5be6866

Please sign in to comment.