You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/08/26 14:42:34 UTC

[GitHub] [camel-quarkus] osmman opened a new pull request, #4053: Fix #4007 increase JPA extension test coverage

osmman opened a new pull request, #4053:
URL: https://github.com/apache/camel-quarkus/pull/4053

   <!-- Uncomment and fill this section if your PR is not trivial
   [ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
   [ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
   [ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
   [ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] zhfeng commented on pull request #4053: Fix #4007 increase JPA extension test coverage

Posted by GitBox <gi...@apache.org>.
zhfeng commented on PR #4053:
URL: https://github.com/apache/camel-quarkus/pull/4053#issuecomment-1230205863

   Thanks @osmman and it is great work!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4053: Fix #4007 increase JPA extension test coverage

Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4053:
URL: https://github.com/apache/camel-quarkus/pull/4053#discussion_r956163013


##########
integration-tests/jpa/src/test/java/org/apache/camel/quarkus/component/jpa/it/JpaTest.java:
##########
@@ -16,63 +16,153 @@
  */
 package org.apache.camel.quarkus.component.jpa.it;
 
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.h2.H2DatabaseTestResource;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.jpa.it.model.Fruit;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
+import static org.awaitility.Awaitility.await;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
 
 @QuarkusTest
-@QuarkusTestResource(H2DatabaseTestResource.class)
 class JpaTest {
 
-    @Test
-    public void testJpaComponent() {
-        String[] fruits = new String[] { "Orange", "Lemon", "Plum" };
+    static final String[] FRUITS = new String[] { "Orange", "Lemon", "Plum" };
 
-        // Create Fruit entities
-        for (String fruit : fruits) {
+    @BeforeAll
+    public static void storeFruits() {
+        final Config config = ConfigProvider.getConfig();
+        int port = config.getValue("quarkus.http.test-port", int.class);
+        RestAssured.port = port;
+        for (String fruit : FRUITS) {
             RestAssured.given()
-                    .contentType(ContentType.TEXT)
-                    .body(fruit)
-                    .post("/jpa/post")
+                    .contentType(ContentType.JSON)
+                    .body(new Fruit(fruit))
+                    .post("/jpa/fruit")
                     .then()
                     .statusCode(201);
         }
+    }
+
+    @Test
+    public void testProducerQuery() {
+        RestAssured.get("/jpa/fruit")
+                .then()
+                .statusCode(200)
+                .body("name", containsInAnyOrder(FRUITS));
+    }
+
+    @Test
+    public void testProducerNamedQuery() {
+        RestAssured.get("/jpa/fruit/named/" + FRUITS[0])
+                .then()
+                .statusCode(200)
+                .body("name", contains(FRUITS[0]));
+    }
+
+    @Test
+    public void testProducerNativeQuery() {
+        RestAssured.get("/jpa/fruit/native/2")
+                .then()
+                .statusCode(200)
+                .body("name", contains(FRUITS[1]));
+    }
+
+    @Test
+    public void testConsumer() {

Review Comment:
   Does this one test `findById` ? If yes, maybe we could rename the test ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] aldettinger commented on pull request #4053: Fix #4007 increase JPA extension test coverage

Posted by GitBox <gi...@apache.org>.
aldettinger commented on PR #4053:
URL: https://github.com/apache/camel-quarkus/pull/4053#issuecomment-1228641640

   Nice addition, most documented features seems to be tested with this PR :+1: 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] osmman commented on a diff in pull request #4053: Fix #4007 increase JPA extension test coverage

Posted by GitBox <gi...@apache.org>.
osmman commented on code in PR #4053:
URL: https://github.com/apache/camel-quarkus/pull/4053#discussion_r956180190


##########
integration-tests/jpa/src/test/java/org/apache/camel/quarkus/component/jpa/it/JpaTest.java:
##########
@@ -16,63 +16,153 @@
  */
 package org.apache.camel.quarkus.component.jpa.it;
 
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.h2.H2DatabaseTestResource;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.jpa.it.model.Fruit;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
+import static org.awaitility.Awaitility.await;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
 
 @QuarkusTest
-@QuarkusTestResource(H2DatabaseTestResource.class)
 class JpaTest {
 
-    @Test
-    public void testJpaComponent() {
-        String[] fruits = new String[] { "Orange", "Lemon", "Plum" };
+    static final String[] FRUITS = new String[] { "Orange", "Lemon", "Plum" };
 
-        // Create Fruit entities
-        for (String fruit : fruits) {
+    @BeforeAll
+    public static void storeFruits() {
+        final Config config = ConfigProvider.getConfig();
+        int port = config.getValue("quarkus.http.test-port", int.class);
+        RestAssured.port = port;
+        for (String fruit : FRUITS) {
             RestAssured.given()
-                    .contentType(ContentType.TEXT)
-                    .body(fruit)
-                    .post("/jpa/post")
+                    .contentType(ContentType.JSON)
+                    .body(new Fruit(fruit))
+                    .post("/jpa/fruit")
                     .then()
                     .statusCode(201);
         }
+    }
+
+    @Test
+    public void testProducerQuery() {
+        RestAssured.get("/jpa/fruit")
+                .then()
+                .statusCode(200)
+                .body("name", containsInAnyOrder(FRUITS));
+    }
+
+    @Test
+    public void testProducerNamedQuery() {
+        RestAssured.get("/jpa/fruit/named/" + FRUITS[0])
+                .then()
+                .statusCode(200)
+                .body("name", contains(FRUITS[0]));
+    }
+
+    @Test
+    public void testProducerNativeQuery() {
+        RestAssured.get("/jpa/fruit/native/2")
+                .then()
+                .statusCode(200)
+                .body("name", contains(FRUITS[1]));
+    }
+
+    @Test
+    public void testConsumer() {

Review Comment:
   It tests `from("jpa:Fruit?namedQuery=unprocessed)` route with usage of `@Consumed` and `@PreConsumed` annotations. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4053: Fix #4007 increase JPA extension test coverage

Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4053:
URL: https://github.com/apache/camel-quarkus/pull/4053#discussion_r956223816


##########
integration-tests/jpa/src/test/java/org/apache/camel/quarkus/component/jpa/it/JpaTest.java:
##########
@@ -16,63 +16,153 @@
  */
 package org.apache.camel.quarkus.component.jpa.it;
 
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.h2.H2DatabaseTestResource;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.jpa.it.model.Fruit;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
+import static org.awaitility.Awaitility.await;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
 
 @QuarkusTest
-@QuarkusTestResource(H2DatabaseTestResource.class)
 class JpaTest {
 
-    @Test
-    public void testJpaComponent() {
-        String[] fruits = new String[] { "Orange", "Lemon", "Plum" };
+    static final String[] FRUITS = new String[] { "Orange", "Lemon", "Plum" };
 
-        // Create Fruit entities
-        for (String fruit : fruits) {
+    @BeforeAll
+    public static void storeFruits() {
+        final Config config = ConfigProvider.getConfig();
+        int port = config.getValue("quarkus.http.test-port", int.class);
+        RestAssured.port = port;
+        for (String fruit : FRUITS) {
             RestAssured.given()
-                    .contentType(ContentType.TEXT)
-                    .body(fruit)
-                    .post("/jpa/post")
+                    .contentType(ContentType.JSON)
+                    .body(new Fruit(fruit))
+                    .post("/jpa/fruit")
                     .then()
                     .statusCode(201);
         }
+    }
+
+    @Test
+    public void testProducerQuery() {
+        RestAssured.get("/jpa/fruit")
+                .then()
+                .statusCode(200)
+                .body("name", containsInAnyOrder(FRUITS));
+    }
+
+    @Test
+    public void testProducerNamedQuery() {
+        RestAssured.get("/jpa/fruit/named/" + FRUITS[0])
+                .then()
+                .statusCode(200)
+                .body("name", contains(FRUITS[0]));
+    }
+
+    @Test
+    public void testProducerNativeQuery() {
+        RestAssured.get("/jpa/fruit/native/2")
+                .then()
+                .statusCode(200)
+                .body("name", contains(FRUITS[1]));
+    }
+
+    @Test
+    public void testConsumer() {

Review Comment:
   Indeed, with the last comment, the intent is clearer now. Renaming the test to something like `testConsumedAnnotations()` could possibly make it even clearer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] zhfeng merged pull request #4053: Fix #4007 increase JPA extension test coverage

Posted by GitBox <gi...@apache.org>.
zhfeng merged PR #4053:
URL: https://github.com/apache/camel-quarkus/pull/4053


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org