-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KOGITO-1943 - Add integration tests with Infinispan
- Loading branch information
1 parent
7cbe765
commit 2ee8fed
Showing
8 changed files
with
360 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
process-infinispan-persistence-quarkus/src/test/java/org/acme/deals/DealsRestIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.acme.deals; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.restassured.http.ContentType; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.notNullValue; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@QuarkusTest | ||
public class DealsRestIT { | ||
|
||
@Test | ||
public void testDealsRest() { | ||
// test adding new deal | ||
String addDealPayload = "{\"name\" : \"my fancy deal\", \"traveller\" : { \"firstName\" : \"John\", \"lastName\" : \"Doe\", \"email\" : \"[email protected]\", \"nationality\" : \"American\",\"address\" : { \"street\" : \"main street\", \"city\" : \"Boston\", \"zipCode\" : \"10005\", \"country\" : \"US\" }}}"; | ||
String dealId = given().contentType(ContentType.JSON).accept(ContentType.JSON).body(addDealPayload) | ||
.when().post("/deals") | ||
.then().log().ifValidationFails().statusCode(200).body("id", notNullValue()).extract().path("id"); | ||
|
||
// test getting the created deal | ||
given().accept(ContentType.JSON) | ||
.when().get("/deals") | ||
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(1), "[0].id", is(dealId)); | ||
|
||
// test getting order by id | ||
given().accept(ContentType.JSON) | ||
.when().get("/deals/" + dealId) | ||
.then().log().ifValidationFails().statusCode(200).body("id", is(dealId)); | ||
|
||
// get deals for review | ||
String dealReviewId = given().accept(ContentType.JSON) | ||
.when().get("/dealreviews") | ||
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(1)).body("[0].id", notNullValue()).extract().path("[0].id"); | ||
|
||
// get task for john | ||
Map<String, String> tasks = given().accept(ContentType.JSON) | ||
.when().get("/dealreviews/{uuid}/tasks?user=john", dealReviewId) | ||
.then().log().ifValidationFails().statusCode(200).extract().as(Map.class); | ||
assertNotNull(tasks); | ||
assertEquals(1, tasks.size()); | ||
|
||
// complete review task | ||
given().contentType(ContentType.JSON).accept(ContentType.JSON).body("{\"review\" : \"very good work\"}") | ||
.when().post("/dealreviews/{uuid}/review/{tuuid}?user=john", dealReviewId, tasks.keySet().iterator().next()) | ||
.then().log().ifValidationFails().statusCode(200); | ||
|
||
//verify no deals to review | ||
given().accept(ContentType.JSON) | ||
.when().get("/dealreviews") | ||
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(0)); | ||
|
||
//verify no deals | ||
given().accept(ContentType.JSON) | ||
.when().get("/deals") | ||
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(0)); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
process-infinispan-persistence-quarkus/src/test/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Infinispan | ||
quarkus.infinispan-client.use-auth=true | ||
quarkus.infinispan-client.auth-username=admin | ||
quarkus.infinispan-client.auth-password=admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...finispan-persistence-springboot/src/main/java/org/kie/kogito/tests/KogitoApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.kogito.tests; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication(scanBasePackages = {"org.kie.kogito.**", "org.acme.deals.**"}) | ||
public class KogitoApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(KogitoApplication.class, args); | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
...-springboot/src/main/java/org/kie/kogito/tests/KogitoInfinispanSpringbootApplication.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.