ppalaga commented on code in PR #4838:
URL: https://github.com/apache/camel-quarkus/pull/4838#discussion_r1179458521


##########
integration-tests-jvm/mapstruct/pom.xml:
##########
@@ -81,4 +85,22 @@
             </dependencies>
         </profile>
     </profiles>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <annotationProcessorPaths>
+                        <path>
+                            <groupId>org.mapstruct</groupId>
+                            <artifactId>mapstruct-processor</artifactId>
+                            <version>${mapstruct-version}</version>

Review Comment:
   We stick to the convention that we always wrap Camel's `foo-version` in our 
own `foo.version` in the top level pom.xml. This is to have single place where 
one can see which versions come from where. Some come from Camel, some come 
from Quarkus, or from elsewhere. So if you could please create 
`<mapstruct.version>${mapstruct-version}</mapstruct.version>` in the top pom 
and then use `<version>${mapstruct.version}</version>` here.
   
   



##########
integration-tests-jvm/mapstruct/src/test/java/org/apache/camel/quarkus/component/mapstruct/it/MapStructTest.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.quarkus.component.mapstruct.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+@QuarkusTest
+public class MapStructTest {
+
+    @ParameterizedTest
+    @ValueSource(strings = { "component", "converter" })

Review Comment:
   Nice usage of `@ParameterizedTest`!



##########
integration-tests-jvm/mapstruct/pom.xml:
##########
@@ -37,17 +37,21 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-mapstruct</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-resteasy</artifactId>
         </dependency>
-
-        <!-- test dependencies -->
         <dependency>
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-junit5</artifactId>
-            <scope>test</scope>

Review Comment:
   I'd vote for keeping junit in the test scope. It is primarily to keep the 
application under test minimal and as close to end user apps as possible. End 
users are unlikely to include junit in their production apps. Moreover adding 
more code makes the native compilation slower and may cause unecessary native 
compilation issues.
   
   Just pass the data on which you want to do the assertions over HTTP/REST and 
do the assertions in the test classes. If you look around this is a common 
practice in Camel Quarkus.



##########
integration-tests-jvm/mapstruct/src/main/java/org/apache/camel/quarkus/component/mapstruct/it/MapStructResource.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.quarkus.component.mapstruct.it;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.quarkus.component.mapstruct.it.model.Car;
+import org.apache.camel.quarkus.component.mapstruct.it.model.Vehicle;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@Path("/mapstruct")
+@ApplicationScoped
+public class MapStructResource {
+    private static final Vehicle VEHICLE = new Vehicle("Volvo", "XC60", 
"true", 2021);
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Path("/component")
+    @GET
+    public void componentTest() {
+        testMapping("component");
+    }
+
+    @Path("/converter")
+    @GET
+    public void converterTest() {
+        testMapping("converter");
+    }
+
+    private void testMapping(String endpoint) {
+        Car car = producerTemplate.requestBody("direct:" + endpoint, VEHICLE, 
Car.class);
+        assertEquals(car.getBrand(), VEHICLE.getCompany());
+        assertEquals(car.getModel(), VEHICLE.getName());
+        assertEquals(car.getYear(), VEHICLE.getYear());
+        assertEquals(car.isElectric(), 
Boolean.parseBoolean(VEHICLE.getPower()));

Review Comment:
   As noted above it would be better to have both these assertions and VEHICLE 
= new Vehicle("Volvo", "XC60", "true", 2021); in the test class. To avoid 
adding quarkus-resteasy-jackson or quarkus-resteasy-jsonb (because we really do 
not want any additional dependencies), you can use some add-hoc serialization, 
like you pass "Volvo,XC60,true,2021" over HTTP and create the Car out of the 
String.split(",") array. 



-- 
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-unsubscr...@camel.apache.org

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

Reply via email to