[ 
https://issues.apache.org/jira/browse/CAMEL-12206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16343207#comment-16343207
 ] 

ASF GitHub Bot commented on CAMEL-12206:
----------------------------------------

oscerd closed pull request #2196: CAMEL-12206: use Bson instead of Document
URL: https://github.com/apache/camel/pull/2196
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbProducer.java
 
b/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbProducer.java
index d56e83b3384..17cd024a8a4 100644
--- 
a/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbProducer.java
+++ 
b/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbProducer.java
@@ -492,7 +492,7 @@ private void processAndTransferResult(Object result, 
Exchange exchange, MongoDbO
         return exchange -> {
             try {
                 MongoCollection<Document> dbCol = 
calculateCollection(exchange);
-                Document removeObj = 
exchange.getIn().getMandatoryBody(Document.class);
+                Bson removeObj = exchange.getIn().getMandatoryBody(Bson.class);
 
                 DeleteResult result = dbCol.deleteMany(removeObj);
                 if (result.wasAcknowledged()) {
diff --git 
a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOperationsTest.java
 
b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOperationsTest.java
index fb7e09dea89..f4e643e59c3 100644
--- 
a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOperationsTest.java
+++ 
b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/MongoDbOperationsTest.java
@@ -24,6 +24,7 @@
 import static java.util.Arrays.asList;
 
 import com.mongodb.MongoClient;
+import com.mongodb.client.model.Filters;
 import com.mongodb.client.result.DeleteResult;
 import com.mongodb.client.result.UpdateResult;
 
@@ -271,7 +272,7 @@ public void testRemove() throws Exception {
         assertEquals(0, testCollection.count());
         for (int i = 1; i <= 100; i++) {
             String body = null;
-            try (Formatter f = new Formatter();) {
+            try (Formatter f = new Formatter()) {
                 if (i % 2 == 0) {
                     body = f.format("{\"_id\":\"testSave%d\", 
\"scientist\":\"Einstein\"}", i).toString();
                 } else {
@@ -284,7 +285,7 @@ public void testRemove() throws Exception {
         assertEquals(100L, testCollection.count());
 
         // Testing the update logic
-        Document extraField = new Document("extraField", true);
+        Bson extraField = Filters.eq("extraField", true);
         assertEquals("Number of records with 'extraField' flag on must equal 
50", 50L, testCollection.count(extraField));
 
         Exchange resultExchange = template.request("direct:remove", new 
Processor() {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> createDoRemove in MongoDbProducer should expect org.bson.conversions.Bson 
> instead of org.bson.Document
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-12206
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12206
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-mongodb3
>    Affects Versions: 2.19.4
>            Reporter: Oliver Koch
>            Assignee: Andrea Cosentino
>            Priority: Minor
>             Fix For: 2.21.0
>
>
> The {{MongoDdProducer}} Method {{createDoRemove}} should expect 
> {{org.bson.conversions.Bson}} in the Body, because it is one of the Main 
> Features of the MongoDb 3.x Driver.
> It is also expected everywhere else in the Producer for Queries and is easier 
> to use because of 
> [Filters|https://mongodb.github.io/mongo-java-driver/3.4/javadoc/?com/mongodb/client/model/Filters.html]
>  Helper Class.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to