This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.x by this push:
     new bedfe0c8566 refactor!: remove itemType param in get/collection 
operation (#11068)
bedfe0c8566 is described below

commit bedfe0c85667737f1a427a6942f303d939e19df3
Author: Claude Mamo <823038+claudem...@users.noreply.github.com>
AuthorDate: Thu Aug 10 18:50:02 2023 +0200

    refactor!: remove itemType param in get/collection operation (#11068)
    
    * refactor!: remove itemType param in get/collection operation and instead 
use `.split().body().unmarshal().json(...)`
    
    * refactor: remove unreferenced object
---
 components/camel-dhis2/camel-dhis2-api/pom.xml     | 23 +++++---
 .../apache/camel/component/dhis2/api/Dhis2Get.java | 20 ++-----
 .../component/dhis2/api/ItemTypeConverter.java     | 69 ++++++++++++++++++++++
 .../component/dhis2/api/Dhis2GetTestCase.java      | 10 +---
 .../camel-dhis2/camel-dhis2-component/pom.xml      |  5 +-
 .../component/dhis2/Dhis2EndpointUriFactory.java   |  3 +-
 .../dhis2/Dhis2GetEndpointConfiguration.java       | 13 +---
 .../Dhis2GetEndpointConfigurationConfigurer.java   |  7 ---
 .../dhis2/internal/Dhis2ApiCollection.java         |  2 +-
 .../dhis2/internal/Dhis2GetApiMethod.java          |  3 +-
 .../org/apache/camel/component/dhis2/dhis2.json    |  4 +-
 .../src/main/docs/dhis2-component.adoc             | 19 +++---
 .../camel/component/dhis2/Dhis2DeleteIT.java       |  2 +-
 .../apache/camel/component/dhis2/Dhis2GetIT.java   | 12 ++--
 .../apache/camel/component/dhis2/Dhis2PostIT.java  |  2 +-
 .../apache/camel/component/dhis2/Dhis2PutIT.java   |  2 +-
 .../component/dhis2/Dhis2ResourceTablesIT.java     |  5 +-
 components/camel-dhis2/pom.xml                     |  2 +-
 18 files changed, 126 insertions(+), 77 deletions(-)

diff --git a/components/camel-dhis2/camel-dhis2-api/pom.xml 
b/components/camel-dhis2/camel-dhis2-api/pom.xml
index 4a24e332567..43170e728d4 100644
--- a/components/camel-dhis2/camel-dhis2-api/pom.xml
+++ b/components/camel-dhis2/camel-dhis2-api/pom.xml
@@ -36,6 +36,20 @@
         <firstVersion>3.21.0</firstVersion>
     </properties>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-support</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-junit-jupiter</artifactId>
+            <version>${mockito-version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
     <build>
         <plugins>
             <plugin>
@@ -55,13 +69,4 @@
             </plugin>
         </plugins>
     </build>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-junit-jupiter</artifactId>
-            <version>${mockito-version}</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
 </project>
diff --git 
a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java
 
b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java
index 9ccdd50ae0d..0410bca6b8e 100644
--- 
a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java
+++ 
b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java
@@ -17,10 +17,10 @@
 package org.apache.camel.component.dhis2.api;
 
 import java.io.InputStream;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.camel.support.InputStreamIterator;
 import org.hisp.dhis.integration.sdk.api.Dhis2Client;
 import org.hisp.dhis.integration.sdk.api.IterableDhis2Response;
 import org.hisp.dhis.integration.sdk.api.operation.GetOperation;
@@ -75,12 +75,11 @@ public class Dhis2Get {
         return getOperation;
     }
 
-    public <T> Iterator<T> collection(
-            String path, String itemType, String arrayName, Boolean paging, 
String fields, String filter,
+    public InputStream collection(
+            String path, String arrayName, Boolean paging, String fields, 
String filter,
             RootJunctionEnum rootJunction,
             Map<String, Object> queryParams) {
         GetOperation getOperation = newGetOperation(path, fields, filter, 
rootJunction, queryParams);
-        Iterable<T> iterable;
 
         IterableDhis2Response iteratorDhis2Response;
         if (paging == null || paging) {
@@ -89,17 +88,8 @@ public class Dhis2Get {
             iteratorDhis2Response = getOperation.withoutPaging().transfer();
         }
 
-        if (itemType == null) {
-            iterable = (Iterable<T>) iteratorDhis2Response.returnAs(Map.class, 
arrayName);
-        } else {
-            try {
-                iterable = (Iterable<T>) 
iteratorDhis2Response.returnAs(Class.forName(itemType), arrayName);
-            } catch (ClassNotFoundException e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        return iterable.iterator();
+        Iterable<Map> iterable = iteratorDhis2Response.returnAs(Map.class, 
arrayName);
+        return new InputStreamIterator(new ItemTypeConverter(dhis2Client), 
iterable.iterator());
     }
 
 }
diff --git 
a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/ItemTypeConverter.java
 
b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/ItemTypeConverter.java
new file mode 100644
index 00000000000..32a6a16198f
--- /dev/null
+++ 
b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/ItemTypeConverter.java
@@ -0,0 +1,69 @@
+/*
+ * 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.dhis2.api;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.TypeConverter;
+import org.hisp.dhis.integration.sdk.api.Dhis2Client;
+
+public class ItemTypeConverter implements TypeConverter {
+
+    private final Dhis2Client dhis2Client;
+
+    public ItemTypeConverter(Dhis2Client dhis2Client) {
+        this.dhis2Client = dhis2Client;
+    }
+
+    @Override
+    public boolean allowNull() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T> T convertTo(Class<T> type, Object value) throws 
TypeConversionException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T> T convertTo(Class<T> type, Exchange exchange, Object value) 
throws TypeConversionException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T> T mandatoryConvertTo(Class<T> type, Object value)
+            throws TypeConversionException, NoTypeConversionAvailableException 
{
+        return (T) 
dhis2Client.getConverterFactory().createConverter().convert(value).getBytes();
+    }
+
+    @Override
+    public <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object 
value)
+            throws TypeConversionException, NoTypeConversionAvailableException 
{
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T> T tryConvertTo(Class<T> type, Object value) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T> T tryConvertTo(Class<T> type, Exchange exchange, Object value) {
+        throw new UnsupportedOperationException();
+    }
+}
diff --git 
a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java
 
b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java
index 706143d5fe2..fb4570d25fe 100644
--- 
a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java
+++ 
b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java
@@ -154,10 +154,6 @@ public class Dhis2GetTestCase {
 
     @Test
     public void testCollectionGivenMapOfStringsQueryParams() {
-        DefaultPagingCollectOperation defaultPagingCollectOperation = new 
DefaultPagingCollectOperation(
-                "https://play.dhis2.org/2.39.0.1";, "", null, new 
JacksonConverterFactory(),
-                getOperation);
-
         Dhis2Response dhis2Response = new Dhis2Response() {
             @Override
             public <T> T returnAs(Class<T> responseType) {
@@ -184,7 +180,7 @@ public class Dhis2GetTestCase {
                         "https://play.dhis2.org/2.39.0.1";, "", null, new 
JacksonConverterFactory(), getOperation));
 
         Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
-        dhis2Get.collection("bunnies", null, "bunnies", null, null, null, 
null, Map.of("foo", "bar"));
+        dhis2Get.collection("bunnies", "bunnies", null, null, null, null, 
Map.of("foo", "bar"));
         verify(getOperation, times(1)).withParameter("foo", "bar");
     }
 
@@ -216,7 +212,7 @@ public class Dhis2GetTestCase {
                         new JacksonConverterFactory(), getOperation));
 
         Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
-        dhis2Get.collection("bunnies", null, "bunnies", null, null, null, 
RootJunctionEnum.OR, null);
+        dhis2Get.collection("bunnies", "bunnies", null, null, null, 
RootJunctionEnum.OR, null);
         verify(getOperation, times(1)).withOrRootJunction();
     }
 
@@ -246,7 +242,7 @@ public class Dhis2GetTestCase {
                 "https://play.dhis2.org/2.39.0.1";, "", null, new 
JacksonConverterFactory(), getOperation));
 
         Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
-        dhis2Get.collection("bunnies", null, "bunnies", null, null, null, 
RootJunctionEnum.AND, null);
+        dhis2Get.collection("bunnies", "bunnies", null, null, null, 
RootJunctionEnum.AND, null);
         verify(getOperation, times(1)).withAndRootJunction();
     }
 }
diff --git a/components/camel-dhis2/camel-dhis2-component/pom.xml 
b/components/camel-dhis2/camel-dhis2-component/pom.xml
index d8434147b5a..901430859e6 100644
--- a/components/camel-dhis2/camel-dhis2-component/pom.xml
+++ b/components/camel-dhis2/camel-dhis2-component/pom.xml
@@ -44,6 +44,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-jackson</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-dhis2-api</artifactId>
@@ -110,7 +114,6 @@
                                     
<proxyClass>org.apache.camel.component.dhis2.api.Dhis2Get</proxyClass>
                                     <fromJavasource />
                                     <nullableOptions>
-                                        
<nullableOption>itemType</nullableOption>
                                         <nullableOption>paging</nullableOption>
                                         <nullableOption>fields</nullableOption>
                                         <nullableOption>filter</nullableOption>
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java
 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java
index 0bcc1c424df..5f91905e363 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java
@@ -21,7 +21,7 @@ public class Dhis2EndpointUriFactory extends 
org.apache.camel.support.component.
     private static final Set<String> SECRET_PROPERTY_NAMES;
     private static final Set<String> MULTI_VALUE_PREFIXES;
     static {
-        Set<String> props = new HashSet<>(40);
+        Set<String> props = new HashSet<>(39);
         props.add("apiName");
         props.add("arrayName");
         props.add("backoffErrorThreshold");
@@ -39,7 +39,6 @@ public class Dhis2EndpointUriFactory extends 
org.apache.camel.support.component.
         props.add("inBody");
         props.add("initialDelay");
         props.add("interval");
-        props.add("itemType");
         props.add("lastYears");
         props.add("lazyStartProducer");
         props.add("methodName");
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java
 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java
index 7f7a9e99a38..e7f724c6bd7 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java
@@ -16,7 +16,7 @@ import org.apache.camel.spi.UriParams;
  */
 @ApiParams(apiName = "get", 
            description = "",
-           apiMethods = {@ApiMethod(methodName = "collection", 
signatures={"java.util.Iterator collection(String path, String itemType, String 
arrayName, Boolean paging, String fields, String filter, 
org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, 
java.util.Map<String, Object> queryParams)"}), @ApiMethod(methodName = 
"resource", signatures={"java.io.InputStream resource(String path, String 
fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum ro 
[...]
+           apiMethods = {@ApiMethod(methodName = "collection", 
signatures={"java.io.InputStream collection(String path, String arrayName, 
Boolean paging, String fields, String filter, 
org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, 
java.util.Map<String, Object> queryParams)"}), @ApiMethod(methodName = 
"resource", signatures={"java.io.InputStream resource(String path, String 
fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum 
rootJunction, java [...]
 @UriParams
 @Configurer(extended = true)
 public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration {
@@ -31,9 +31,6 @@ public final class Dhis2GetEndpointConfiguration extends 
Dhis2Configuration {
     private String filter;
     @UriParam
     @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = 
"collection")})
-    private String itemType;
-    @UriParam
-    @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = 
"collection")})
     private Boolean paging;
     @UriParam
     @ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = 
"collection"), @ApiMethod(methodName = "resource")})
@@ -69,14 +66,6 @@ public final class Dhis2GetEndpointConfiguration extends 
Dhis2Configuration {
         this.filter = filter;
     }
 
-    public String getItemType() {
-        return itemType;
-    }
-
-    public void setItemType(String itemType) {
-        this.itemType = itemType;
-    }
-
     public Boolean getPaging() {
         return paging;
     }
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
index 9670058b051..e11ca4c17b4 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
@@ -26,7 +26,6 @@ public class Dhis2GetEndpointConfigurationConfigurer extends 
org.apache.camel.su
         map.put("Client", org.hisp.dhis.integration.sdk.api.Dhis2Client.class);
         map.put("Fields", java.lang.String.class);
         map.put("Filter", java.lang.String.class);
-        map.put("ItemType", java.lang.String.class);
         map.put("MethodName", java.lang.String.class);
         map.put("Paging", java.lang.Boolean.class);
         map.put("Password", java.lang.String.class);
@@ -53,8 +52,6 @@ public class Dhis2GetEndpointConfigurationConfigurer extends 
org.apache.camel.su
         case "Fields": target.setFields(property(camelContext, 
java.lang.String.class, value)); return true;
         case "filter":
         case "Filter": target.setFilter(property(camelContext, 
java.lang.String.class, value)); return true;
-        case "itemtype":
-        case "ItemType": target.setItemType(property(camelContext, 
java.lang.String.class, value)); return true;
         case "methodname":
         case "MethodName": target.setMethodName(property(camelContext, 
java.lang.String.class, value)); return true;
         case "paging":
@@ -93,8 +90,6 @@ public class Dhis2GetEndpointConfigurationConfigurer extends 
org.apache.camel.su
         case "Fields": return java.lang.String.class;
         case "filter":
         case "Filter": return java.lang.String.class;
-        case "itemtype":
-        case "ItemType": return java.lang.String.class;
         case "methodname":
         case "MethodName": return java.lang.String.class;
         case "paging":
@@ -129,8 +124,6 @@ public class Dhis2GetEndpointConfigurationConfigurer 
extends org.apache.camel.su
         case "Fields": return target.getFields();
         case "filter":
         case "Filter": return target.getFilter();
-        case "itemtype":
-        case "ItemType": return target.getItemType();
         case "methodname":
         case "MethodName": return target.getMethodName();
         case "paging":
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java
 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java
index bf703853d72..9354860c8d8 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java
@@ -46,7 +46,7 @@ public final class Dhis2ApiCollection extends 
ApiCollection<Dhis2ApiName, Dhis2C
         apiMethods.put(Dhis2ResourceTablesApiMethod.class, 
Dhis2ApiName.RESOURCE_TABLES);
 
         aliases.clear();
-        nullableArgs = Arrays.asList("itemType", "paging", "fields", "filter", 
"rootJunction", "queryParams");
+        nullableArgs = Arrays.asList("paging", "fields", "filter", 
"rootJunction", "queryParams");
         apiHelpers.put(Dhis2ApiName.GET, new 
ApiMethodHelper<Dhis2GetApiMethod>(Dhis2GetApiMethod.class, aliases, 
nullableArgs));
         apiMethods.put(Dhis2GetApiMethod.class, Dhis2ApiName.GET);
 
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
index 7e37f358f5e..fccb12908a7 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
@@ -21,10 +21,9 @@ import static 
org.apache.camel.support.component.ApiMethodArg.arg;
 public enum Dhis2GetApiMethod implements ApiMethod {
 
     COLLECTION(
-        java.util.Iterator.class,
+        java.io.InputStream.class,
         "collection",
         arg("path", String.class),
-        arg("itemType", String.class),
         arg("arrayName", String.class),
         arg("paging", Boolean.class),
         arg("fields", String.class),
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json
 
b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json
index 69bc25a9b77..0e4aa849708 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json
@@ -63,14 +63,14 @@
   },
   "apis": {
     "delete": { "consumerOnly": false, "producerOnly": false, "description": 
"", "methods": { "resource": { "description": "", "signatures": [ 
"java.io.InputStream resource(String path, Object resource, 
java.util.Map<String, Object> queryParams)" ] } } },
-    "get": { "consumerOnly": false, "producerOnly": false, "description": "", 
"methods": { "collection": { "description": "", "signatures": [ 
"java.util.Iterator collection(String path, String itemType, String arrayName, 
Boolean paging, String fields, String filter, 
org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, 
java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": 
"", "signatures": [ "java.io.InputStream resource(String path, String fields, S 
[...]
+    "get": { "consumerOnly": false, "producerOnly": false, "description": "", 
"methods": { "collection": { "description": "", "signatures": [ 
"java.io.InputStream collection(String path, String arrayName, Boolean paging, 
String fields, String filter, 
org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, 
java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": 
"", "signatures": [ "java.io.InputStream resource(String path, String fields, 
String filter, or [...]
     "post": { "consumerOnly": false, "producerOnly": false, "description": "", 
"methods": { "resource": { "description": "", "signatures": [ 
"java.io.InputStream resource(String path, Object resource, 
java.util.Map<String, Object> queryParams)" ] } } },
     "put": { "consumerOnly": false, "producerOnly": false, "description": "", 
"methods": { "resource": { "description": "", "signatures": [ 
"java.io.InputStream resource(String path, Object resource, 
java.util.Map<String, Object> queryParams)" ] } } },
     "resourceTables": { "consumerOnly": false, "producerOnly": false, 
"description": "", "methods": { "analytics": { "description": "", "signatures": 
[ "void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, 
Integer interval)" ] } } }
   },
   "apiProperties": {
     "delete": { "methods": { "resource": { "properties": { "path": { "kind": 
"parameter", "displayName": "Path", "group": "common", "label": "", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "", "optional": false }, 
"queryParams": { "kind": "parameter", "displayName": "Query Params", "group": 
"common", "label": "", "required": false, "type": "object", "javaType": 
"java.util.Map<java.lang.Strin [...]
-    "get": { "methods": { "collection": { "properties": { "arrayName": { 
"kind": "parameter", "displayName": "Array Name", "group": "common", "label": 
"", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "", 
"optional": false }, "fields": { "kind": "parameter", "displayName": "Fields", 
"group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated [...]
+    "get": { "methods": { "collection": { "properties": { "arrayName": { 
"kind": "parameter", "displayName": "Array Name", "group": "common", "label": 
"", "required": false, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "description": "", 
"optional": false }, "fields": { "kind": "parameter", "displayName": "Fields", 
"group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated [...]
     "post": { "methods": { "resource": { "properties": { "path": { "kind": 
"parameter", "displayName": "Path", "group": "common", "label": "", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "", "optional": false }, 
"queryParams": { "kind": "parameter", "displayName": "Query Params", "group": 
"common", "label": "", "required": false, "type": "object", "javaType": 
"java.util.Map<java.lang.String, [...]
     "put": { "methods": { "resource": { "properties": { "path": { "kind": 
"parameter", "displayName": "Path", "group": "common", "label": "", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "", "optional": false }, 
"queryParams": { "kind": "parameter", "displayName": "Query Params", "group": 
"common", "label": "", "required": false, "type": "object", "javaType": 
"java.util.Map<java.lang.String,  [...]
     "resourceTables": { "methods": { "analytics": { "properties": { 
"interval": { "kind": "parameter", "displayName": "Interval", "group": 
"common", "label": "", "required": false, "type": "integer", "javaType": 
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, 
"description": "", "optional": true }, "lastYears": { "kind": "parameter", 
"displayName": "Last Years", "group": "common", "label": "", "required": false, 
"type": "integer", "javaType": "java.lang.Inte [...]
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc
 
b/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc
index 5a402a17f5d..7a9041d39d9 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc
@@ -91,7 +91,7 @@ public class MyRouteBuilder extends RouteBuilder {
 
 Signatures:
 
-* java.util.Iterator collection(java.lang.String path, java.lang.String 
itemType, java.lang.Boolean paging, java.lang.String fields, java.lang.String 
filter, java.util.Map<String, Object> queryParams)
+* java.util.Iterator collection(java.lang.String path, java.lang.Boolean 
paging, java.lang.String fields, java.lang.String filter, java.util.Map<String, 
Object> queryParams)
 
 The get/collection API method has the parameters listed in the table below:
 
@@ -99,7 +99,6 @@ The get/collection API method has the parameters listed in 
the table below:
 |===
 | Parameter | Description | Type
 | path | Resource URL path | String
-| itemType | Fully-qualified Java class name to deserialise items into| String
 | arrayName | JSON property name holding the array to read | String
 | paging | Turn paging on/off | Boolean
 | fields | Comma-delimited list of fields to fetch | String
@@ -121,8 +120,8 @@ public class MyRouteBuilder extends RouteBuilder {
 
     public void configure() {
         from("direct:getCollection")
-            
.to("dhis2://get/collection?path=organisationUnits&itemType=org.hisp.dhis.api.model.v2_39_1.OrganisationUnit&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api";)
-            .split().body().log("${body}");
+            
.to("dhis2://get/collection?path=organisationUnits&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api";)
+            
.split().body().unmarshal().json(org.hisp.dhis.api.model.v2_39_1.OrganisationUnit.class).log("${body}");
     }
 }
 ----
@@ -139,8 +138,10 @@ public class MyRouteBuilder extends RouteBuilder {
 
     public void configure() {
         from("direct:getCollection")
-            
.to("dhis2://get/collection?path=organisationUnits&fields=code&itemType=org.hisp.dhis.api.model.v2_39_1.OrganisationUnit&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api";)
-            .split().body().log("${body}");
+            
.to("dhis2://get/collection?path=organisationUnits&fields=code&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api";)
+            .split().body()
+            
.unmarshal().json(org.hisp.dhis.api.model.v2_39_1.OrganisationUnit.class)
+            .log("${body}");
     }
 }
 ----
@@ -157,8 +158,10 @@ public class MyRouteBuilder extends RouteBuilder {
 
     public void configure() {
         from("direct:getCollection")
-            
.to("dhis2://get/collection?path=users&filter=phoneNumber:!null:&itemType=org.hisp.dhis.api.model.v2_39_1.User&arrayName=users&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api";)
-            .split().body().log("${body}");
+            
.to("dhis2://get/collection?path=users&filter=phoneNumber:!null:&arrayName=users&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api";)
+            .split().body()
+            .unmarshal().json(org.hisp.dhis.api.model.v2_39_1.User.class)
+            .log("${body}");
     }
 }
 ----
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java
 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java
index 76c79d09097..d9bcb32f362 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java
@@ -66,7 +66,7 @@ public class Dhis2DeleteIT extends AbstractDhis2TestSupport {
         assertEquals(404, remoteDhis2ClientException.getHttpStatusCode());
 
         assertNotNull(result, "resource result");
-        LOG.debug("resource: " + result);
+        LOG.debug("Result: {}", result);
     }
 
     @Override
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java
 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java
index c580a75f5da..6870dc21718 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection;
 import org.apache.camel.component.dhis2.internal.Dhis2GetApiMethod;
+import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,17 +44,16 @@ public class Dhis2GetIT extends AbstractDhis2TestSupport {
     public void testCollection() throws Exception {
         final Map<String, Object> headers = new HashMap<String, Object>();
         headers.put("CamelDhis2.path", "organisationUnits");
-        headers.put("CamelDhis2.itemType", 
"org.hisp.dhis.api.model.v2_39_1.OrganisationUnit");
         headers.put("CamelDhis2.arrayName", "organisationUnits");
         headers.put("CamelDhis2.paging", true);
         headers.put("CamelDhis2.fields", null);
         headers.put("CamelDhis2.filter", null);
         headers.put("CamelDhis2.queryParams", new HashMap<>());
 
-        final java.util.Iterator result = 
requestBodyAndHeaders("direct://COLLECTION", null, headers);
+        final Object result = requestBodyAndHeaders("direct://COLLECTION", 
null, headers);
 
         assertNotNull(result, "collection result");
-        LOG.debug("collection: " + result);
+        LOG.debug("collection: {}", result);
     }
 
     @Test
@@ -67,7 +67,7 @@ public class Dhis2GetIT extends AbstractDhis2TestSupport {
         final java.io.InputStream result = 
requestBodyAndHeaders("direct://RESOURCE", null, headers);
 
         assertNotNull(result, "resource result");
-        LOG.debug("resource: " + result);
+        LOG.debug("Result: {}", result);
     }
 
     @Override
@@ -76,7 +76,9 @@ public class Dhis2GetIT extends AbstractDhis2TestSupport {
             public void configure() {
                 // test route for collection
                 from("direct://COLLECTION")
-                        .to("dhis2://" + PATH_PREFIX + "/collection");
+                        .to("dhis2://" + PATH_PREFIX + 
"/collection").split().body()
+                        .unmarshal()
+                        .json(OrganisationUnit.class);
 
                 // test route for resource
                 from("direct://RESOURCE")
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java
 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java
index 96b610ad862..6526debc6f4 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java
@@ -63,7 +63,7 @@ public class Dhis2PostIT extends AbstractDhis2TestSupport {
                 headers);
 
         assertNotNull(result, "resource result");
-        LOG.debug("resource: " + result);
+        LOG.debug("Result: {}", result);
     }
 
     @Override
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java
 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java
index b0289b20639..64f421c9097 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java
@@ -68,7 +68,7 @@ public class Dhis2PutIT extends AbstractDhis2TestSupport {
         assertEquals(name, organisationUnit.getName().get());
 
         assertNotNull(result, "resource result");
-        LOG.debug("resource: " + result);
+        LOG.debug("Result: {}", result);
     }
 
     @Override
diff --git 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesIT.java
 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesIT.java
index 8ee0cc686d9..7c8f52b6d01 100644
--- 
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesIT.java
+++ 
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesIT.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection;
 import org.apache.camel.component.dhis2.internal.Dhis2ResourceTablesApiMethod;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,7 +40,7 @@ public class Dhis2ResourceTablesIT extends 
AbstractDhis2TestSupport {
             = 
Dhis2ApiCollection.getCollection().getApiName(Dhis2ResourceTablesApiMethod.class).getName();
 
     @Test
-    public void testAnalytics() throws Exception {
+    public void testAnalytics() {
         final Map<String, Object> headers = new HashMap<String, Object>();
         // parameter type is Boolean
         headers.put("CamelDhis2.skipAggregate", false);
@@ -50,7 +51,7 @@ public class Dhis2ResourceTablesIT extends 
AbstractDhis2TestSupport {
         // parameter type is Integer
         headers.put("CamelDhis2.interval", 10000);
 
-        requestBodyAndHeaders("direct://ANALYTICS", null, headers);
+        Assertions.assertDoesNotThrow(() -> 
requestBodyAndHeaders("direct://ANALYTICS", null, headers));
     }
 
     @Override
diff --git a/components/camel-dhis2/pom.xml b/components/camel-dhis2/pom.xml
index d7af64e0fce..83419305923 100644
--- a/components/camel-dhis2/pom.xml
+++ b/components/camel-dhis2/pom.xml
@@ -34,7 +34,7 @@
     <description>Camel DHIS2 Component</description>
 
     <properties>
-        <dhis2-java-sdk.version>2.0.0</dhis2-java-sdk.version>
+        <dhis2-java-sdk.version>2.1.0</dhis2-java-sdk.version>
     </properties>
 
     <modules>


Reply via email to