gnodet-bot commented on code in PR #30554:
URL: https://github.com/apache/camel/pull/30554#discussion_r4652494018


##########
components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/SslAwareMongoClientTest.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * 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.component.mongodb;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.mongodb.MongoClientSettings;
+import com.mongodb.MongoCredential;
+import com.mongodb.ReadPreference;
+import com.mongodb.ServerAddress;
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.PropertyBindingSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;

Review Comment:
   The existing `camel-mongodb` test module uses JUnit 5 assertions exclusively 
across all 43 test files. These two AssertJ imports introduce an inconsistency.
   
   ```suggestion
   import static org.junit.jupiter.api.Assertions.assertEquals;
   import static org.junit.jupiter.api.Assertions.assertThrows;
   ```
   
   Please replace `assertThat(...).isEqualTo(x)` with `assertEquals(x, ...)` 
and `assertThatThrownBy(...)` with `assertThrows(...)` to stay consistent with 
the module's established style.



##########
components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/integration/SslAwareMongoClientIT.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.component.mongodb.integration;
+
+import com.mongodb.MongoSecurityException;
+import com.mongodb.ReadPreference;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.mongodb.MongoDbEndpoint;
+import org.apache.camel.component.mongodb.SslAwareMongoClient;
+import org.apache.camel.test.infra.core.annotations.ContextFixture;
+import org.bson.Document;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;

Review Comment:
   Same as `SslAwareMongoClientTest.java`: the IT tests in this module use 
JUnit 5 assertions; AssertJ is not used elsewhere. Please replace AssertJ 
assertions with their JUnit 5 equivalents (`assertEquals`, `assertThrows`) for 
consistency.



##########
components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/SslAwareMongoClient.java:
##########
@@ -101,6 +77,51 @@ public MongoClient get() {
     private boolean ssl = true;
 
     private boolean sslValidationEnabled = true;
+    private String readPreference;
+
+    /**
+     * The settings of the client: the hosts, the credentials (authenticated 
against the admin database), TLS and the
+     * read preference.
+     */
+    MongoClientSettings createSettings() {

Review Comment:
   The package-private visibility of `createSettings()` looks intentional here 
(same-package tests call it directly without reflection), but it means other 
classes in the package can call it too. If that's the design intent, a brief 
Javadoc explaining *why* it's package-private (testability) would make it 
clearer. If it should be truly internal, `private` + a package-private test 
helper method would be safer.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to