You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/04/20 04:07:12 UTC
[camel] branch camel-3.x updated: Add API methods for deleting and updating resources & some other minor changes (#9899)
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 7750409ccce Add API methods for deleting and updating resources & some other minor changes (#9899)
7750409ccce is described below
commit 7750409cccedd471c0a25b19d59e217800d0a686
Author: Claude Mamo <82...@users.noreply.github.com>
AuthorDate: Thu Apr 20 06:07:05 2023 +0200
Add API methods for deleting and updating resources & some other minor changes (#9899)
* Add API methods for deleting and updating resources
Point resource param to inBody by default
Add support for rootJunction param for GET method
Update to latest dhis2-java-sdk
* Add missing generated files
---
.../dhis2/api/{Dhis2Post.java => Dhis2Delete.java} | 19 ++-
.../apache/camel/component/dhis2/api/Dhis2Get.java | 25 ++--
.../camel/component/dhis2/api/Dhis2Post.java | 3 -
.../dhis2/api/{Dhis2Post.java => Dhis2Put.java} | 20 ++--
.../component/dhis2/api/RootJunctionEnum.java} | 14 +--
...2PostTestCase.java => Dhis2DeleteTestCase.java} | 24 ++--
.../component/dhis2/api/Dhis2GetTestCase.java | 122 +++++++++++++++++++-
.../component/dhis2/api/Dhis2PostTestCase.java | 4 +-
...his2PostTestCase.java => Dhis2PutTestCase.java} | 24 ++--
.../camel-dhis2/camel-dhis2-component/pom.xml | 19 +++
.../signatures/file-sig-api.txt | 4 +-
....java => Dhis2DeleteEndpointConfiguration.java} | 8 +-
...his2DeleteEndpointConfigurationConfigurer.java} | 43 ++-----
.../component/dhis2/Dhis2EndpointUriFactory.java | 3 +-
.../dhis2/Dhis2GetEndpointConfiguration.java | 15 ++-
.../Dhis2GetEndpointConfigurationConfigurer.java | 7 ++
.../dhis2/Dhis2PostEndpointConfiguration.java | 2 +-
...ion.java => Dhis2PutEndpointConfiguration.java} | 8 +-
...> Dhis2PutEndpointConfigurationConfigurer.java} | 43 ++-----
.../dhis2/internal/Dhis2ApiCollection.java | 20 +++-
.../component/dhis2/internal/Dhis2ApiName.java | 6 +-
...GetApiMethod.java => Dhis2DeleteApiMethod.java} | 23 +---
.../dhis2/internal/Dhis2GetApiMethod.java | 2 +
...is2GetApiMethod.java => Dhis2PutApiMethod.java} | 23 +---
...omponent.dhis2.Dhis2DeleteEndpointConfiguration | 2 +
...l.component.dhis2.Dhis2PutEndpointConfiguration | 2 +
.../org/apache/camel/component/dhis2/dhis2.json | 12 +-
.../src/main/docs/dhis2-component.adoc | 128 +++++++++++++++++++++
.../camel/component/dhis2/Dhis2Endpoint.java | 17 ++-
.../camel/component/dhis2/Dhis2Producer.java | 14 +++
.../dhis2/{Dhis2PostIT.java => Dhis2DeleteIT.java} | 40 ++++---
.../apache/camel/component/dhis2/Dhis2GetIT.java | 2 +-
.../apache/camel/component/dhis2/Dhis2PostIT.java | 23 +++-
.../dhis2/{Dhis2PostIT.java => Dhis2PutIT.java} | 43 ++++---
.../component/dhis2/Dhis2ResourceTablesIT.java | 1 -
.../apache/camel/component/dhis2/Environment.java | 10 +-
components/camel-dhis2/pom.xml | 22 +++-
37 files changed, 551 insertions(+), 246 deletions(-)
diff --git a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Delete.java
similarity index 72%
copy from components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java
copy to components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Delete.java
index 1123acf7e3c..b67a448e51d 100644
--- a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Delete.java
@@ -21,37 +21,34 @@ import java.util.List;
import java.util.Map;
import org.hisp.dhis.integration.sdk.api.Dhis2Client;
-import org.hisp.dhis.integration.sdk.api.operation.PostOperation;
+import org.hisp.dhis.integration.sdk.api.operation.DeleteOperation;
-/**
- * Sample API used by Dhis2 Component whose method signatures are read from Java source.
- */
-public class Dhis2Post {
+public class Dhis2Delete {
private final Dhis2Client dhis2Client;
- public Dhis2Post(Dhis2Client dhis2Client) {
+ public Dhis2Delete(Dhis2Client dhis2Client) {
this.dhis2Client = dhis2Client;
}
public InputStream resource(String path, Object resource, Map<String, Object> queryParams) {
- PostOperation postOperation = dhis2Client.post(path);
+ DeleteOperation deleteOperation = dhis2Client.delete(path);
if (queryParams != null) {
for (Map.Entry<String, Object> queryParam : queryParams.entrySet()) {
if (queryParam.getValue() instanceof List) {
for (String queryValue : (List<String>) queryParam.getValue()) {
- postOperation.withParameter(queryParam.getKey(), queryValue);
+ deleteOperation.withParameter(queryParam.getKey(), queryValue);
}
} else {
- postOperation.withParameter(queryParam.getKey(), (String) queryParam.getValue());
+ deleteOperation.withParameter(queryParam.getKey(), (String) queryParam.getValue());
}
}
}
if (resource != null) {
- postOperation.withResource(resource);
+ deleteOperation.withResource(resource);
}
- return postOperation.transfer().read();
+ return deleteOperation.transfer().read();
}
}
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 099bbc3403b..fcefb54a9eb 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
@@ -25,9 +25,6 @@ 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;
-/**
- * Sample API used by Dhis2 Component whose method signatures are read from Java source.
- */
public class Dhis2Get {
private final Dhis2Client dhis2Client;
@@ -35,13 +32,17 @@ public class Dhis2Get {
this.dhis2Client = dhis2Client;
}
- public InputStream resource(String path, String fields, String filter, Map<String, Object> queryParams) {
- GetOperation getOperation = newGetOperation(path, fields, filter, queryParams);
+ public InputStream resource(
+ String path, String fields, String filter, RootJunctionEnum rootJunction,
+ Map<String, Object> queryParams) {
+ GetOperation getOperation = newGetOperation(path, fields, filter, rootJunction, queryParams);
return getOperation.withParameter("paging", "false").transfer().read();
}
- protected GetOperation newGetOperation(String path, String fields, String filter, Map<String, Object> queryParams) {
+ protected GetOperation newGetOperation(
+ String path, String fields, String filter, RootJunctionEnum rootJunction,
+ Map<String, Object> queryParams) {
GetOperation getOperation = dhis2Client.get(path);
if (fields != null) {
getOperation.withFields(fields);
@@ -51,6 +52,14 @@ public class Dhis2Get {
getOperation.withFilter(filter);
}
+ if (rootJunction != null) {
+ if (rootJunction.equals(RootJunctionEnum.AND)) {
+ getOperation.withAndRootJunction();
+ } else {
+ getOperation.withOrRootJunction();
+ }
+ }
+
if (queryParams != null) {
for (Map.Entry<String, Object> queryParam : queryParams.entrySet()) {
if (queryParam.getValue() instanceof List) {
@@ -67,9 +76,9 @@ public class Dhis2Get {
}
public <T> Iterator<T> collection(
- String path, String itemType, Boolean paging, String fields, String filter,
+ String path, String itemType, Boolean paging, String fields, String filter, RootJunctionEnum rootJunction,
Map<String, Object> queryParams) {
- GetOperation getOperation = newGetOperation(path, fields, filter, queryParams);
+ GetOperation getOperation = newGetOperation(path, fields, filter, rootJunction, queryParams);
Iterable<T> iterable;
IterableDhis2Response iteratorDhis2Response;
diff --git a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java
index 1123acf7e3c..b00d2e524f8 100644
--- a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java
@@ -23,9 +23,6 @@ import java.util.Map;
import org.hisp.dhis.integration.sdk.api.Dhis2Client;
import org.hisp.dhis.integration.sdk.api.operation.PostOperation;
-/**
- * Sample API used by Dhis2 Component whose method signatures are read from Java source.
- */
public class Dhis2Post {
private final Dhis2Client dhis2Client;
diff --git a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Put.java
similarity index 72%
copy from components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java
copy to components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Put.java
index 1123acf7e3c..98ebeba4ca6 100644
--- a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Post.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Put.java
@@ -21,37 +21,33 @@ import java.util.List;
import java.util.Map;
import org.hisp.dhis.integration.sdk.api.Dhis2Client;
-import org.hisp.dhis.integration.sdk.api.operation.PostOperation;
+import org.hisp.dhis.integration.sdk.api.operation.PutOperation;
-/**
- * Sample API used by Dhis2 Component whose method signatures are read from Java source.
- */
-public class Dhis2Post {
+public class Dhis2Put {
private final Dhis2Client dhis2Client;
- public Dhis2Post(Dhis2Client dhis2Client) {
+ public Dhis2Put(Dhis2Client dhis2Client) {
this.dhis2Client = dhis2Client;
}
public InputStream resource(String path, Object resource, Map<String, Object> queryParams) {
- PostOperation postOperation = dhis2Client.post(path);
+ PutOperation putOperation = dhis2Client.put(path);
if (queryParams != null) {
for (Map.Entry<String, Object> queryParam : queryParams.entrySet()) {
if (queryParam.getValue() instanceof List) {
for (String queryValue : (List<String>) queryParam.getValue()) {
- postOperation.withParameter(queryParam.getKey(), queryValue);
+ putOperation.withParameter(queryParam.getKey(), queryValue);
}
} else {
- postOperation.withParameter(queryParam.getKey(), (String) queryParam.getValue());
+ putOperation.withParameter(queryParam.getKey(), (String) queryParam.getValue());
}
}
}
if (resource != null) {
- postOperation.withResource(resource);
+ putOperation.withResource(resource);
}
- return postOperation.transfer().read();
-
+ return putOperation.transfer().read();
}
}
diff --git a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Producer.java b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/RootJunctionEnum.java
similarity index 62%
copy from components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Producer.java
copy to components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/RootJunctionEnum.java
index 50634f93d85..42f654c5a3b 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Producer.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/RootJunctionEnum.java
@@ -14,15 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.dhis2;
+package org.apache.camel.component.dhis2.api;
-import org.apache.camel.component.dhis2.internal.Dhis2ApiName;
-import org.apache.camel.component.dhis2.internal.Dhis2PropertiesHelper;
-import org.apache.camel.support.component.AbstractApiProducer;
-
-public class Dhis2Producer extends AbstractApiProducer<Dhis2ApiName, Dhis2Configuration> {
-
- public Dhis2Producer(Dhis2Endpoint endpoint) {
- super(endpoint, Dhis2PropertiesHelper.getHelper(endpoint.getCamelContext()));
- }
+public enum RootJunctionEnum {
+ AND,
+ OR
}
diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2DeleteTestCase.java
similarity index 73%
copy from components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java
copy to components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2DeleteTestCase.java
index c989718e76f..4a79565809f 100644
--- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2DeleteTestCase.java
@@ -17,14 +17,13 @@
package org.apache.camel.component.dhis2.api;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import org.hisp.dhis.integration.sdk.api.Dhis2Client;
import org.hisp.dhis.integration.sdk.api.Dhis2Response;
-import org.hisp.dhis.integration.sdk.api.operation.PostOperation;
+import org.hisp.dhis.integration.sdk.api.operation.DeleteOperation;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -35,18 +34,18 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
-public class Dhis2PostTestCase {
+public class Dhis2DeleteTestCase {
@Mock
private Dhis2Client dhis2Client;
@Mock
- private PostOperation postOperation;
+ private DeleteOperation deleteOperation;
@BeforeEach
public void beforeEach() {
- when(dhis2Client.post(any())).thenReturn(postOperation);
- when(postOperation.withParameter(any(), any())).thenReturn(postOperation);
- when(postOperation.transfer()).thenReturn(new Dhis2Response() {
+ when(dhis2Client.delete(any())).thenReturn(deleteOperation);
+ when(deleteOperation.withParameter(any(), any())).thenReturn(deleteOperation);
+ when(deleteOperation.transfer()).thenReturn(new Dhis2Response() {
@Override
public <T> T returnAs(Class<T> responseType) {
return null;
@@ -58,8 +57,7 @@ public class Dhis2PostTestCase {
}
@Override
- public void close()
- throws IOException {
+ public void close() {
}
});
@@ -67,13 +65,13 @@ public class Dhis2PostTestCase {
@Test
public void testResourceGivenMapOfListsQueryParams() {
- Dhis2Post dhis2Post = new Dhis2Post(dhis2Client);
- dhis2Post.resource(null, null, Map.of("foo", List.of("bar")));
+ Dhis2Delete dhis2Delete = new Dhis2Delete(dhis2Client);
+ dhis2Delete.resource(null, null, Map.of("foo", List.of("bar")));
}
@Test
public void testResourceGivenMapOfStringsQueryParams() {
- Dhis2Post dhis2Post = new Dhis2Post(dhis2Client);
- dhis2Post.resource(null, null, Map.of("foo", "bar"));
+ Dhis2Delete dhis2Delete = new Dhis2Delete(dhis2Client);
+ dhis2Delete.resource(null, null, Map.of("foo", "bar"));
}
}
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 261cdbc99fa..325a4f692ec 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
@@ -74,7 +74,7 @@ public class Dhis2GetTestCase {
};
when(getOperation.transfer()).thenReturn(dhis2Response);
Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
- dhis2Get.resource(null, null, null, Map.of("foo", List.of("bar")));
+ dhis2Get.resource(null, null, null, null, Map.of("foo", List.of("bar")));
verify(getOperation, times(1)).withParameter("foo", "bar");
}
@@ -98,14 +98,65 @@ public class Dhis2GetTestCase {
};
when(getOperation.transfer()).thenReturn(dhis2Response);
Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
- dhis2Get.resource(null, null, null, Map.of("foo", "bar"));
+ dhis2Get.resource(null, null, null, null, Map.of("foo", "bar"));
verify(getOperation, times(1)).withParameter("foo", "bar");
}
+ @Test
+ public void testResourceGivenOrRootJunction() {
+ Dhis2Response dhis2Response = new Dhis2Response() {
+ @Override
+ public <T> T returnAs(Class<T> responseType) {
+ return null;
+ }
+
+ @Override
+ public InputStream read() {
+ return new ByteArrayInputStream(new byte[] {});
+ }
+
+ @Override
+ public void close() {
+
+ }
+ };
+ when(getOperation.withParameter(any(), any())).thenReturn(getOperation);
+ when(getOperation.transfer()).thenReturn(dhis2Response);
+ Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
+ dhis2Get.resource(null, null, null, RootJunctionEnum.OR, null);
+ verify(getOperation, times(1)).withOrRootJunction();
+ }
+
+ @Test
+ public void testResourceGivenAndRootJunction() {
+ Dhis2Response dhis2Response = new Dhis2Response() {
+ @Override
+ public <T> T returnAs(Class<T> responseType) {
+ return null;
+ }
+
+ @Override
+ public InputStream read() {
+ return new ByteArrayInputStream(new byte[] {});
+ }
+
+ @Override
+ public void close() {
+
+ }
+ };
+ when(getOperation.withParameter(any(), any())).thenReturn(getOperation);
+ when(getOperation.transfer()).thenReturn(dhis2Response);
+ Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
+ dhis2Get.resource(null, null, null, RootJunctionEnum.AND, null);
+ verify(getOperation, times(1)).withAndRootJunction();
+ }
+
@Test
public void testCollectionGivenMapOfStringsQueryParams() {
DefaultPagingCollectOperation defaultPagingCollectOperation = new DefaultPagingCollectOperation(
- "https://play.dhis2.org/2.39.0.1", "", null, new JacksonConverterFactory(), getOperation);
+ "https://play.dhis2.org/2.39.0.1", "", null, new JacksonConverterFactory(),
+ getOperation);
Dhis2Response dhis2Response = new Dhis2Response() {
@Override
@@ -128,13 +179,74 @@ public class Dhis2GetTestCase {
}
};
when(getOperation.transfer()).thenReturn(dhis2Response);
+ when(getOperation.withPaging()).thenReturn(
+ new DefaultPagingCollectOperation(
+ "https://play.dhis2.org/2.39.0.1", "", null, new JacksonConverterFactory(), getOperation));
+
+ Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
+ dhis2Get.collection("bunnies", null, null, null, null, null, Map.of("foo", "bar"));
+ verify(getOperation, times(1)).withParameter("foo", "bar");
+ }
+
+ @Test
+ public void testCollectionGivenOrRootJunction() {
+ Dhis2Response dhis2Response = new Dhis2Response() {
+ @Override
+ public <T> T returnAs(Class<T> responseType) {
+ Page page = new Page();
+ page.setAdditionalProperty("bunnies", new ArrayList<>());
+
+ return (T) page;
+ }
+
+ @Override
+ public InputStream read() {
+ return new ByteArrayInputStream(new byte[] {});
+ }
+
+ @Override
+ public void close() {
+
+ }
+ };
+ when(getOperation.transfer()).thenReturn(dhis2Response);
when(getOperation.withPaging()).thenReturn(
new DefaultPagingCollectOperation(
"https://play.dhis2.org/2.39.0.1", "", null,
new JacksonConverterFactory(), getOperation));
Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
- dhis2Get.collection("bunnies", null, null, null, null, Map.of("foo", "bar"));
- verify(getOperation, times(1)).withParameter("foo", "bar");
+ dhis2Get.collection("bunnies", null, null, null, null, RootJunctionEnum.OR, null);
+ verify(getOperation, times(1)).withOrRootJunction();
+ }
+
+ @Test
+ public void testCollectionGivenAndRootJunction() {
+ Dhis2Response dhis2Response = new Dhis2Response() {
+ @Override
+ public <T> T returnAs(Class<T> responseType) {
+ Page page = new Page();
+ page.setAdditionalProperty("bunnies", new ArrayList<>());
+
+ return (T) page;
+ }
+
+ @Override
+ public InputStream read() {
+ return new ByteArrayInputStream(new byte[] {});
+ }
+
+ @Override
+ public void close() {
+
+ }
+ };
+ when(getOperation.transfer()).thenReturn(dhis2Response);
+ when(getOperation.withPaging()).thenReturn(new DefaultPagingCollectOperation(
+ "https://play.dhis2.org/2.39.0.1", "", null, new JacksonConverterFactory(), getOperation));
+
+ Dhis2Get dhis2Get = new Dhis2Get(dhis2Client);
+ dhis2Get.collection("bunnies", null, null, null, null, RootJunctionEnum.AND, null);
+ verify(getOperation, times(1)).withAndRootJunction();
}
}
diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java
index c989718e76f..f01d1390e91 100644
--- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.dhis2.api;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
@@ -58,8 +57,7 @@ public class Dhis2PostTestCase {
}
@Override
- public void close()
- throws IOException {
+ public void close() {
}
});
diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PutTestCase.java
similarity index 73%
copy from components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java
copy to components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PutTestCase.java
index c989718e76f..4db76f0d6a7 100644
--- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java
+++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PutTestCase.java
@@ -17,14 +17,13 @@
package org.apache.camel.component.dhis2.api;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import org.hisp.dhis.integration.sdk.api.Dhis2Client;
import org.hisp.dhis.integration.sdk.api.Dhis2Response;
-import org.hisp.dhis.integration.sdk.api.operation.PostOperation;
+import org.hisp.dhis.integration.sdk.api.operation.PutOperation;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -35,18 +34,18 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
-public class Dhis2PostTestCase {
+public class Dhis2PutTestCase {
@Mock
private Dhis2Client dhis2Client;
@Mock
- private PostOperation postOperation;
+ private PutOperation putOperation;
@BeforeEach
public void beforeEach() {
- when(dhis2Client.post(any())).thenReturn(postOperation);
- when(postOperation.withParameter(any(), any())).thenReturn(postOperation);
- when(postOperation.transfer()).thenReturn(new Dhis2Response() {
+ when(dhis2Client.put(any())).thenReturn(putOperation);
+ when(putOperation.withParameter(any(), any())).thenReturn(putOperation);
+ when(putOperation.transfer()).thenReturn(new Dhis2Response() {
@Override
public <T> T returnAs(Class<T> responseType) {
return null;
@@ -58,8 +57,7 @@ public class Dhis2PostTestCase {
}
@Override
- public void close()
- throws IOException {
+ public void close() {
}
});
@@ -67,13 +65,13 @@ public class Dhis2PostTestCase {
@Test
public void testResourceGivenMapOfListsQueryParams() {
- Dhis2Post dhis2Post = new Dhis2Post(dhis2Client);
- dhis2Post.resource(null, null, Map.of("foo", List.of("bar")));
+ Dhis2Put dhis2Put = new Dhis2Put(dhis2Client);
+ dhis2Put.resource(null, null, Map.of("foo", List.of("bar")));
}
@Test
public void testResourceGivenMapOfStringsQueryParams() {
- Dhis2Post dhis2Post = new Dhis2Post(dhis2Client);
- dhis2Post.resource(null, null, Map.of("foo", "bar"));
+ Dhis2Put dhis2Put = new Dhis2Put(dhis2Client);
+ dhis2Put.resource(null, null, Map.of("foo", "bar"));
}
}
diff --git a/components/camel-dhis2/camel-dhis2-component/pom.xml b/components/camel-dhis2/camel-dhis2-component/pom.xml
index 054ed9f6bff..111e8bfba3e 100644
--- a/components/camel-dhis2/camel-dhis2-component/pom.xml
+++ b/components/camel-dhis2/camel-dhis2-component/pom.xml
@@ -109,6 +109,25 @@
<nullableOption>paging</nullableOption>
<nullableOption>fields</nullableOption>
<nullableOption>filter</nullableOption>
+ <nullableOption>rootJunction</nullableOption>
+ <nullableOption>queryParams</nullableOption>
+ </nullableOptions>
+ </api>
+ <api>
+ <apiName>delete</apiName>
+ <proxyClass>org.apache.camel.component.dhis2.api.Dhis2Delete</proxyClass>
+ <fromJavasource />
+ <nullableOptions>
+ <nullableOption>resource</nullableOption>
+ <nullableOption>queryParams</nullableOption>
+ </nullableOptions>
+ </api>
+ <api>
+ <apiName>put</apiName>
+ <proxyClass>org.apache.camel.component.dhis2.api.Dhis2Put</proxyClass>
+ <fromJavasource />
+ <nullableOptions>
+ <nullableOption>resource</nullableOption>
<nullableOption>queryParams</nullableOption>
</nullableOptions>
</api>
diff --git a/components/camel-dhis2/camel-dhis2-component/signatures/file-sig-api.txt b/components/camel-dhis2/camel-dhis2-component/signatures/file-sig-api.txt
index a7b58c7a5c5..5912a2e4dca 100644
--- a/components/camel-dhis2/camel-dhis2-component/signatures/file-sig-api.txt
+++ b/components/camel-dhis2/camel-dhis2-component/signatures/file-sig-api.txt
@@ -18,4 +18,6 @@
public String get(String resource);
public String get(String collection);
public String post(String resource);
-public String resourceTables(String analytics);
\ No newline at end of file
+public String delete(String resource);
+public String put(String resource);
+public String resourceTables(String analytics);
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2DeleteEndpointConfiguration.java
similarity index 86%
copy from components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java
copy to components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2DeleteEndpointConfiguration.java
index 4b1e5cc4216..a636eb75a24 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2DeleteEndpointConfiguration.java
@@ -12,14 +12,14 @@ import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
/**
- * Camel endpoint configuration for {@link org.apache.camel.component.dhis2.api.Dhis2Post}.
+ * Camel endpoint configuration for {@link org.apache.camel.component.dhis2.api.Dhis2Delete}.
*/
-@ApiParams(apiName = "post",
- description = "Sample API used by Dhis2 Component whose method signatures are read from Java source",
+@ApiParams(apiName = "delete",
+ description = "",
apiMethods = {@ApiMethod(methodName = "resource", signatures={"java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)"})}, aliases = {})
@UriParams
@Configurer(extended = true)
-public final class Dhis2PostEndpointConfiguration extends Dhis2Configuration {
+public final class Dhis2DeleteEndpointConfiguration extends Dhis2Configuration {
@UriParam
@ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = "resource")})
private String path;
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/Dhis2DeleteEndpointConfigurationConfigurer.java
similarity index 71%
copy from components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
copy to components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2DeleteEndpointConfigurationConfigurer.java
index 3c8fcb29397..4d833792ba1 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/Dhis2DeleteEndpointConfigurationConfigurer.java
@@ -9,13 +9,13 @@ import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.spi.ConfigurerStrategy;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.util.CaseInsensitiveMap;
-import org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration;
+import org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration;
/**
* Generated by camel build tools - do NOT edit this file!
*/
@SuppressWarnings("unchecked")
-public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, ExtendedPropertyConfigurerGetter {
+public class Dhis2DeleteEndpointConfigurationConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, ExtendedPropertyConfigurerGetter {
private static final Map<String, Object> ALL_OPTIONS;
static {
@@ -23,21 +23,18 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
map.put("ApiName", org.apache.camel.component.dhis2.internal.Dhis2ApiName.class);
map.put("BaseApiUrl", java.lang.String.class);
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);
map.put("Path", java.lang.String.class);
map.put("QueryParams", java.util.Map.class);
+ map.put("Resource", java.lang.Object.class);
map.put("Username", java.lang.String.class);
ALL_OPTIONS = map;
}
@Override
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
- org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration target = (org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration) obj;
+ org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration target = (org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "apiname":
case "ApiName": target.setApiName(property(camelContext, org.apache.camel.component.dhis2.internal.Dhis2ApiName.class, value)); return true;
@@ -45,22 +42,16 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "BaseApiUrl": target.setBaseApiUrl(property(camelContext, java.lang.String.class, value)); return true;
case "client":
case "Client": target.setClient(property(camelContext, org.hisp.dhis.integration.sdk.api.Dhis2Client.class, value)); return true;
- case "fields":
- 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":
- case "Paging": target.setPaging(property(camelContext, java.lang.Boolean.class, value)); return true;
case "password":
case "Password": target.setPassword(property(camelContext, java.lang.String.class, value)); return true;
case "path":
case "Path": target.setPath(property(camelContext, java.lang.String.class, value)); return true;
case "queryparams":
case "QueryParams": target.setQueryParams(property(camelContext, java.util.Map.class, value)); return true;
+ case "resource":
+ case "Resource": target.setResource(property(camelContext, java.lang.Object.class, value)); return true;
case "username":
case "Username": target.setUsername(property(camelContext, java.lang.String.class, value)); return true;
default: return false;
@@ -81,22 +72,16 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "BaseApiUrl": return java.lang.String.class;
case "client":
case "Client": return org.hisp.dhis.integration.sdk.api.Dhis2Client.class;
- case "fields":
- 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":
- case "Paging": return java.lang.Boolean.class;
case "password":
case "Password": return java.lang.String.class;
case "path":
case "Path": return java.lang.String.class;
case "queryparams":
case "QueryParams": return java.util.Map.class;
+ case "resource":
+ case "Resource": return java.lang.Object.class;
case "username":
case "Username": return java.lang.String.class;
default: return null;
@@ -105,7 +90,7 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
@Override
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
- org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration target = (org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration) obj;
+ org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration target = (org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "apiname":
case "ApiName": return target.getApiName();
@@ -113,22 +98,16 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "BaseApiUrl": return target.getBaseApiUrl();
case "client":
case "Client": return target.getClient();
- case "fields":
- 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":
- case "Paging": return target.getPaging();
case "password":
case "Password": return target.getPassword();
case "path":
case "Path": return target.getPath();
case "queryparams":
case "QueryParams": return target.getQueryParams();
+ case "resource":
+ case "Resource": return target.getResource();
case "username":
case "Username": return target.getUsername();
default: return null;
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 bfd9ec411b1..4a7b44074cd 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<>(38);
+ Set<String> props = new HashSet<>(39);
props.add("apiName");
props.add("backoffErrorThreshold");
props.add("backoffIdleThreshold");
@@ -49,6 +49,7 @@ public class Dhis2EndpointUriFactory extends org.apache.camel.support.component.
props.add("queryParams");
props.add("repeatCount");
props.add("resource");
+ props.add("rootJunction");
props.add("runLoggingLevel");
props.add("scheduledExecutorService");
props.add("scheduler");
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 228bc3f7127..9ec1227a69f 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
@@ -15,8 +15,8 @@ import org.apache.camel.spi.UriParams;
* Camel endpoint configuration for {@link org.apache.camel.component.dhis2.api.Dhis2Get}.
*/
@ApiParams(apiName = "get",
- description = "Sample API used by Dhis2 Component whose method signatures are read from Java source",
- apiMethods = {@ApiMethod(methodName = "collection", signatures={"java.util.Iterator collection(String path, String itemType, Boolean paging, String fields, String filter, java.util.Map<String, Object> queryParams)"}), @ApiMethod(methodName = "resource", signatures={"java.io.InputStream resource(String path, String fields, String filter, java.util.Map<String, Object> queryParams)"})}, aliases = {})
+ description = "",
+ apiMethods = {@ApiMethod(methodName = "collection", signatures={"java.util.Iterator collection(String path, String itemType, 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.u [...]
@UriParams
@Configurer(extended = true)
public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration {
@@ -38,6 +38,9 @@ public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration {
@UriParam
@ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "collection"), @ApiMethod(methodName = "resource")})
private java.util.Map<String, Object> queryParams;
+ @UriParam
+ @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "collection"), @ApiMethod(methodName = "resource")})
+ private org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction;
public String getFields() {
return fields;
@@ -86,4 +89,12 @@ public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration {
public void setQueryParams(java.util.Map<String, Object> queryParams) {
this.queryParams = queryParams;
}
+
+ public org.apache.camel.component.dhis2.api.RootJunctionEnum getRootJunction() {
+ return rootJunction;
+ }
+
+ public void setRootJunction(org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction) {
+ this.rootJunction = rootJunction;
+ }
}
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 3c8fcb29397..d68646f3074 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
@@ -31,6 +31,7 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
map.put("Password", java.lang.String.class);
map.put("Path", java.lang.String.class);
map.put("QueryParams", java.util.Map.class);
+ map.put("RootJunction", org.apache.camel.component.dhis2.api.RootJunctionEnum.class);
map.put("Username", java.lang.String.class);
ALL_OPTIONS = map;
}
@@ -61,6 +62,8 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "Path": target.setPath(property(camelContext, java.lang.String.class, value)); return true;
case "queryparams":
case "QueryParams": target.setQueryParams(property(camelContext, java.util.Map.class, value)); return true;
+ case "rootjunction":
+ case "RootJunction": target.setRootJunction(property(camelContext, org.apache.camel.component.dhis2.api.RootJunctionEnum.class, value)); return true;
case "username":
case "Username": target.setUsername(property(camelContext, java.lang.String.class, value)); return true;
default: return false;
@@ -97,6 +100,8 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "Path": return java.lang.String.class;
case "queryparams":
case "QueryParams": return java.util.Map.class;
+ case "rootjunction":
+ case "RootJunction": return org.apache.camel.component.dhis2.api.RootJunctionEnum.class;
case "username":
case "Username": return java.lang.String.class;
default: return null;
@@ -129,6 +134,8 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "Path": return target.getPath();
case "queryparams":
case "QueryParams": return target.getQueryParams();
+ case "rootjunction":
+ case "RootJunction": return target.getRootJunction();
case "username":
case "Username": return target.getUsername();
default: return null;
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java
index 4b1e5cc4216..ec69c4cfdf9 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java
@@ -15,7 +15,7 @@ import org.apache.camel.spi.UriParams;
* Camel endpoint configuration for {@link org.apache.camel.component.dhis2.api.Dhis2Post}.
*/
@ApiParams(apiName = "post",
- description = "Sample API used by Dhis2 Component whose method signatures are read from Java source",
+ description = "",
apiMethods = {@ApiMethod(methodName = "resource", signatures={"java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)"})}, aliases = {})
@UriParams
@Configurer(extended = true)
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PutEndpointConfiguration.java
similarity index 86%
copy from components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java
copy to components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PutEndpointConfiguration.java
index 4b1e5cc4216..a921b7c07cf 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfiguration.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PutEndpointConfiguration.java
@@ -12,14 +12,14 @@ import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
/**
- * Camel endpoint configuration for {@link org.apache.camel.component.dhis2.api.Dhis2Post}.
+ * Camel endpoint configuration for {@link org.apache.camel.component.dhis2.api.Dhis2Put}.
*/
-@ApiParams(apiName = "post",
- description = "Sample API used by Dhis2 Component whose method signatures are read from Java source",
+@ApiParams(apiName = "put",
+ description = "",
apiMethods = {@ApiMethod(methodName = "resource", signatures={"java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)"})}, aliases = {})
@UriParams
@Configurer(extended = true)
-public final class Dhis2PostEndpointConfiguration extends Dhis2Configuration {
+public final class Dhis2PutEndpointConfiguration extends Dhis2Configuration {
@UriParam
@ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = "resource")})
private String path;
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/Dhis2PutEndpointConfigurationConfigurer.java
similarity index 73%
copy from components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java
copy to components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PutEndpointConfigurationConfigurer.java
index 3c8fcb29397..279be9a78ed 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/Dhis2PutEndpointConfigurationConfigurer.java
@@ -9,13 +9,13 @@ import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.spi.ConfigurerStrategy;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.util.CaseInsensitiveMap;
-import org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration;
+import org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration;
/**
* Generated by camel build tools - do NOT edit this file!
*/
@SuppressWarnings("unchecked")
-public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, ExtendedPropertyConfigurerGetter {
+public class Dhis2PutEndpointConfigurationConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, ExtendedPropertyConfigurerGetter {
private static final Map<String, Object> ALL_OPTIONS;
static {
@@ -23,21 +23,18 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
map.put("ApiName", org.apache.camel.component.dhis2.internal.Dhis2ApiName.class);
map.put("BaseApiUrl", java.lang.String.class);
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);
map.put("Path", java.lang.String.class);
map.put("QueryParams", java.util.Map.class);
+ map.put("Resource", java.lang.Object.class);
map.put("Username", java.lang.String.class);
ALL_OPTIONS = map;
}
@Override
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
- org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration target = (org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration) obj;
+ org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration target = (org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "apiname":
case "ApiName": target.setApiName(property(camelContext, org.apache.camel.component.dhis2.internal.Dhis2ApiName.class, value)); return true;
@@ -45,22 +42,16 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "BaseApiUrl": target.setBaseApiUrl(property(camelContext, java.lang.String.class, value)); return true;
case "client":
case "Client": target.setClient(property(camelContext, org.hisp.dhis.integration.sdk.api.Dhis2Client.class, value)); return true;
- case "fields":
- 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":
- case "Paging": target.setPaging(property(camelContext, java.lang.Boolean.class, value)); return true;
case "password":
case "Password": target.setPassword(property(camelContext, java.lang.String.class, value)); return true;
case "path":
case "Path": target.setPath(property(camelContext, java.lang.String.class, value)); return true;
case "queryparams":
case "QueryParams": target.setQueryParams(property(camelContext, java.util.Map.class, value)); return true;
+ case "resource":
+ case "Resource": target.setResource(property(camelContext, java.lang.Object.class, value)); return true;
case "username":
case "Username": target.setUsername(property(camelContext, java.lang.String.class, value)); return true;
default: return false;
@@ -81,22 +72,16 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "BaseApiUrl": return java.lang.String.class;
case "client":
case "Client": return org.hisp.dhis.integration.sdk.api.Dhis2Client.class;
- case "fields":
- 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":
- case "Paging": return java.lang.Boolean.class;
case "password":
case "Password": return java.lang.String.class;
case "path":
case "Path": return java.lang.String.class;
case "queryparams":
case "QueryParams": return java.util.Map.class;
+ case "resource":
+ case "Resource": return java.lang.Object.class;
case "username":
case "Username": return java.lang.String.class;
default: return null;
@@ -105,7 +90,7 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
@Override
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
- org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration target = (org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration) obj;
+ org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration target = (org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "apiname":
case "ApiName": return target.getApiName();
@@ -113,22 +98,16 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su
case "BaseApiUrl": return target.getBaseApiUrl();
case "client":
case "Client": return target.getClient();
- case "fields":
- 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":
- case "Paging": return target.getPaging();
case "password":
case "Password": return target.getPassword();
case "path":
case "Path": return target.getPath();
case "queryparams":
case "QueryParams": return target.getQueryParams();
+ case "resource":
+ case "Resource": return target.getResource();
case "username":
case "Username": return target.getUsername();
default: return null;
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 82f9d8cb13d..bf703853d72 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
@@ -14,6 +14,8 @@ import org.apache.camel.component.dhis2.Dhis2Configuration;
import org.apache.camel.component.dhis2.Dhis2PostEndpointConfiguration;
import org.apache.camel.component.dhis2.Dhis2ResourceTablesEndpointConfiguration;
import org.apache.camel.component.dhis2.Dhis2GetEndpointConfiguration;
+import org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration;
+import org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration;
import org.apache.camel.support.component.ApiCollection;
import org.apache.camel.support.component.ApiMethod;
@@ -44,10 +46,20 @@ public final class Dhis2ApiCollection extends ApiCollection<Dhis2ApiName, Dhis2C
apiMethods.put(Dhis2ResourceTablesApiMethod.class, Dhis2ApiName.RESOURCE_TABLES);
aliases.clear();
- nullableArgs = Arrays.asList("itemType", "paging", "fields", "filter", "queryParams");
+ nullableArgs = Arrays.asList("itemType", "paging", "fields", "filter", "rootJunction", "queryParams");
apiHelpers.put(Dhis2ApiName.GET, new ApiMethodHelper<Dhis2GetApiMethod>(Dhis2GetApiMethod.class, aliases, nullableArgs));
apiMethods.put(Dhis2GetApiMethod.class, Dhis2ApiName.GET);
+ aliases.clear();
+ nullableArgs = Arrays.asList("resource", "queryParams");
+ apiHelpers.put(Dhis2ApiName.DELETE, new ApiMethodHelper<Dhis2DeleteApiMethod>(Dhis2DeleteApiMethod.class, aliases, nullableArgs));
+ apiMethods.put(Dhis2DeleteApiMethod.class, Dhis2ApiName.DELETE);
+
+ aliases.clear();
+ nullableArgs = Arrays.asList("resource", "queryParams");
+ apiHelpers.put(Dhis2ApiName.PUT, new ApiMethodHelper<Dhis2PutApiMethod>(Dhis2PutApiMethod.class, aliases, nullableArgs));
+ apiMethods.put(Dhis2PutApiMethod.class, Dhis2ApiName.PUT);
+
setApiHelpers(apiHelpers);
setApiMethods(apiMethods);
}
@@ -64,6 +76,12 @@ public final class Dhis2ApiCollection extends ApiCollection<Dhis2ApiName, Dhis2C
case GET:
result = new Dhis2GetEndpointConfiguration();
break;
+ case DELETE:
+ result = new Dhis2DeleteEndpointConfiguration();
+ break;
+ case PUT:
+ result = new Dhis2PutEndpointConfiguration();
+ break;
}
return result;
}
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiName.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiName.java
index 3d766c5eba6..8b5d2e3a1db 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiName.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiName.java
@@ -15,7 +15,11 @@ public enum Dhis2ApiName implements ApiName {
RESOURCE_TABLES("resourceTables"),
- GET("get");
+ GET("get"),
+
+ DELETE("delete"),
+
+ PUT("put");
private final String name;
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/Dhis2DeleteApiMethod.java
similarity index 62%
copy from components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
copy to components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2DeleteApiMethod.java
index 67ec2911141..c42a86827af 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/Dhis2DeleteApiMethod.java
@@ -7,7 +7,7 @@ package org.apache.camel.component.dhis2.internal;
import java.lang.reflect.Method;
import java.util.List;
-import org.apache.camel.component.dhis2.api.Dhis2Get;
+import org.apache.camel.component.dhis2.api.Dhis2Delete;
import org.apache.camel.support.component.ApiMethod;
import org.apache.camel.support.component.ApiMethodArg;
@@ -16,32 +16,21 @@ import org.apache.camel.support.component.ApiMethodImpl;
import static org.apache.camel.support.component.ApiMethodArg.arg;
/**
- * Camel {@link ApiMethod} Enumeration for org.apache.camel.component.dhis2.api.Dhis2Get
+ * Camel {@link ApiMethod} Enumeration for org.apache.camel.component.dhis2.api.Dhis2Delete
*/
-public enum Dhis2GetApiMethod implements ApiMethod {
-
- COLLECTION(
- java.util.Iterator.class,
- "collection",
- arg("path", String.class),
- arg("itemType", String.class),
- arg("paging", Boolean.class),
- arg("fields", String.class),
- arg("filter", String.class),
- arg("queryParams", java.util.Map.class)),
+public enum Dhis2DeleteApiMethod implements ApiMethod {
RESOURCE(
java.io.InputStream.class,
"resource",
arg("path", String.class),
- arg("fields", String.class),
- arg("filter", String.class),
+ arg("resource", Object.class),
arg("queryParams", java.util.Map.class));
private final ApiMethod apiMethod;
- private Dhis2GetApiMethod(Class<?> resultType, String name, ApiMethodArg... args) {
- this.apiMethod = new ApiMethodImpl(Dhis2Get.class, resultType, name, args);
+ private Dhis2DeleteApiMethod(Class<?> resultType, String name, ApiMethodArg... args) {
+ this.apiMethod = new ApiMethodImpl(Dhis2Delete.class, resultType, name, args);
}
@Override
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 67ec2911141..66cca60bd5c 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
@@ -28,6 +28,7 @@ public enum Dhis2GetApiMethod implements ApiMethod {
arg("paging", Boolean.class),
arg("fields", String.class),
arg("filter", String.class),
+ arg("rootJunction", org.apache.camel.component.dhis2.api.RootJunctionEnum.class),
arg("queryParams", java.util.Map.class)),
RESOURCE(
@@ -36,6 +37,7 @@ public enum Dhis2GetApiMethod implements ApiMethod {
arg("path", String.class),
arg("fields", String.class),
arg("filter", String.class),
+ arg("rootJunction", org.apache.camel.component.dhis2.api.RootJunctionEnum.class),
arg("queryParams", java.util.Map.class));
private final ApiMethod apiMethod;
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/Dhis2PutApiMethod.java
similarity index 64%
copy from components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java
copy to components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2PutApiMethod.java
index 67ec2911141..de8a070e285 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/Dhis2PutApiMethod.java
@@ -7,7 +7,7 @@ package org.apache.camel.component.dhis2.internal;
import java.lang.reflect.Method;
import java.util.List;
-import org.apache.camel.component.dhis2.api.Dhis2Get;
+import org.apache.camel.component.dhis2.api.Dhis2Put;
import org.apache.camel.support.component.ApiMethod;
import org.apache.camel.support.component.ApiMethodArg;
@@ -16,32 +16,21 @@ import org.apache.camel.support.component.ApiMethodImpl;
import static org.apache.camel.support.component.ApiMethodArg.arg;
/**
- * Camel {@link ApiMethod} Enumeration for org.apache.camel.component.dhis2.api.Dhis2Get
+ * Camel {@link ApiMethod} Enumeration for org.apache.camel.component.dhis2.api.Dhis2Put
*/
-public enum Dhis2GetApiMethod implements ApiMethod {
-
- COLLECTION(
- java.util.Iterator.class,
- "collection",
- arg("path", String.class),
- arg("itemType", String.class),
- arg("paging", Boolean.class),
- arg("fields", String.class),
- arg("filter", String.class),
- arg("queryParams", java.util.Map.class)),
+public enum Dhis2PutApiMethod implements ApiMethod {
RESOURCE(
java.io.InputStream.class,
"resource",
arg("path", String.class),
- arg("fields", String.class),
- arg("filter", String.class),
+ arg("resource", Object.class),
arg("queryParams", java.util.Map.class));
private final ApiMethod apiMethod;
- private Dhis2GetApiMethod(Class<?> resultType, String name, ApiMethodArg... args) {
- this.apiMethod = new ApiMethodImpl(Dhis2Get.class, resultType, name, args);
+ private Dhis2PutApiMethod(Class<?> resultType, String name, ApiMethodArg... args) {
+ this.apiMethod = new ApiMethodImpl(Dhis2Put.class, resultType, name, args);
}
@Override
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration
new file mode 100644
index 00000000000..c20476310a5
--- /dev/null
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfiguration
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.dhis2.Dhis2DeleteEndpointConfigurationConfigurer
diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration
new file mode 100644
index 00000000000..b904c3221d3
--- /dev/null
+++ b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.dhis2.Dhis2PutEndpointConfiguration
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.dhis2.Dhis2PutEndpointConfigurationConfigurer
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 c438e0e0141..ae51b2243f5 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
@@ -33,7 +33,7 @@
"username": { "kind": "property", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account username for accessing the DHIS2 API" }
},
"properties": {
- "apiName": { "kind": "path", "displayName": "Api Name", "group": "common", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.dhis2.internal.Dhis2ApiName", "enum": [ "POST", "RESOURCE_TABLES", "GET" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "API operation (e.g., get)" },
+ "apiName": { "kind": "path", "displayName": "Api Name", "group": "common", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.dhis2.internal.Dhis2ApiName", "enum": [ "POST", "RESOURCE_TABLES", "GET", "DELETE", "PUT" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "API operation (e.g [...]
"methodName": { "kind": "path", "displayName": "Method Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Subject of the API operation (e.g., resource)" },
"baseApiUrl": { "kind": "parameter", "displayName": "Base Api Url", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 server base API URL (e.g., https:\/\/play.dhis2.org\/2.39.1.1\/api)" },
"inBody": { "kind": "parameter", "displayName": "In Body", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of a parameter to be passed in the exchange In Body" },
@@ -62,13 +62,17 @@
"username": { "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account username for accessing the DHIS2 API" }
},
"apis": {
- "get": { "consumerOnly": false, "producerOnly": false, "description": "Sample API used by Dhis2 Component whose method signatures are read from Java source", "methods": { "collection": { "description": "", "signatures": [ "java.util.Iterator collection(String path, String itemType, Boolean paging, String fields, String filter, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, String fields, Str [...]
- "post": { "consumerOnly": false, "producerOnly": false, "description": "Sample API used by Dhis2 Component whose method signatures are read from Java source", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } },
+ "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, 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, org. [...]
+ "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": {
- "get": { "methods": { "collection": { "properties": { "fields": { "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": true }, "filter": { "kind": "parameter", "displayName": "Filter", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false [...]
+ "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": { "fields": { "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": true }, "filter": { "kind": "parameter", "displayName": "Filter", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false [...]
"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 ae488b95a9d..31ef3880bb2 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
@@ -233,6 +233,134 @@ public class MyRouteBuilder extends RouteBuilder {
}
----
+== API: put
+
+*Both producer and consumer are supported*
+
+The post API is defined in the syntax as follows:
+
+....
+dhis2:put/methodName?[parameters]
+....
+
+== METHOD resource
+
+Signatures:
+
+* java.io.InputStream resource(java.lang.String path, java.lang.Object resource, java.util.Map<String, Object queryParams)
+
+The put/resource API method has the parameters listed in the table
+below:
+
+[cols=",,",options="header",]
+|===
+| Parameter | Description | Type
+| path | Resource URL path | String
+| resource | Updated resource | Object
+| queryParams | Custom query parameters | Map
+|===
+
+In addition to the parameters above, the put/resource API can also use any of the link:#query-parameters[Query Parameters].
+
+Any of the parameters can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format CamelDhis2.parameter. The inBody parameter overrides message header, i.e. the endpoint parameter inBody=myParameterNameHere would override a CamelDhis2.myParameterNameHere header.
+
+* Update an organisation unit
++
+[source,java]
+----
+package org.camel.dhis2.example;
+
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.RouteBuilder;
+import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit;
+import org.hisp.dhis.api.model.v2_39_1.DescriptiveWebMessage;
+import org.hisp.dhis.api.model.v2_39_1.ImportReportWebMessageResponse;
+import org.hisp.dhis.integration.sdk.support.period.PeriodBuilder;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.List;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+ public void configure() {
+ from("direct:putResource")
+ .setBody(exchange -> new OrganisationUnit().withName("Acme").withShortName("Acme").withOpeningDate(new Date()))
+ .to("dhis2://put/resource?path=organisationUnits/jUb8gELQApl&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api")
+ .unmarshal().json(ImportReportWebMessageResponse.class)
+ .choice()
+ .when(exchange -> !exchange.getMessage().getBody(ImportReportWebMessageResponse.class).getStatus().get().equals(DescriptiveWebMessage.Status.OK))
+ .log(LoggingLevel.ERROR, "Import error from DHIS2 while updating org unit => ${body}")
+ .end();
+ }
+}
+----
+
+== API: delete
+
+*Both producer and consumer are supported*
+
+The delete API is defined in the syntax as follows:
+
+....
+dhis2:delete/methodName?[parameters]
+....
+
+== METHOD resource
+
+Signatures:
+
+* java.io.InputStream resource(java.lang.String path, java.lang.Object resource, java.util.Map<String, Object queryParams)
+
+The delete/resource API method has the parameters listed in the table
+below:
+
+[cols=",,",options="header",]
+|===
+| Parameter | Description | Type
+| path | Resource URL path | String
+| resource | Deleted resource | Object
+| queryParams | Custom query parameters | Map
+|===
+
+In addition to the parameters above, the delete/resource API can also use any of the link:#query-parameters[Query Parameters].
+
+Any of the parameters can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format CamelDhis2.parameter. The inBody parameter overrides message header, i.e. the endpoint parameter inBody=myParameterNameHere would override a CamelDhis2.myParameterNameHere header.
+
+* Delete an organisation unit
+
+[source,java]
+----
+package org.camel.dhis2.example;
+
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.RouteBuilder;
+import org.hisp.dhis.api.model.v2_39_1.DescriptiveWebMessage;
+import org.hisp.dhis.api.model.v2_39_1.ImportReportWebMessageResponse;
+import org.hisp.dhis.integration.sdk.support.period.PeriodBuilder;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.List;
+
+public class MyRouteBuilder extends RouteBuilder {
+
+ public void configure() {
+ from("direct:deleteResource")
+ .to("dhis2://delete/resource?path=organisationUnits/jUb8gELQApl&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api")
+ .unmarshal().json(ImportReportWebMessageResponse.class)
+ .choice()
+ .when(exchange -> !exchange.getMessage().getBody(ImportReportWebMessageResponse.class).getStatus().get().equals(DescriptiveWebMessage.Status.OK))
+ .log(LoggingLevel.ERROR, "Import error from DHIS2 while deleting org unit => ${body}")
+ .end();
+ }
+}
+----
+
== API: resourceTables
*Both producer and consumer are supported*
diff --git a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Endpoint.java b/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Endpoint.java
index dc26b05e2f0..ff58630d8b1 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Endpoint.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Endpoint.java
@@ -22,8 +22,10 @@ import org.apache.camel.Category;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
+import org.apache.camel.component.dhis2.api.Dhis2Delete;
import org.apache.camel.component.dhis2.api.Dhis2Get;
import org.apache.camel.component.dhis2.api.Dhis2Post;
+import org.apache.camel.component.dhis2.api.Dhis2Put;
import org.apache.camel.component.dhis2.api.Dhis2ResourceTables;
import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection;
import org.apache.camel.component.dhis2.internal.Dhis2ApiName;
@@ -41,8 +43,7 @@ import org.hisp.dhis.integration.sdk.api.Dhis2Client;
* <p>
*/
@UriEndpoint(firstVersion = "3.21.0", scheme = "dhis2", title = "DHIS2", syntax = "dhis2:methodName",
- apiSyntax = "apiName/methodName", category = {
- Category.API })
+ apiSyntax = "apiName/methodName", category = { Category.API })
public class Dhis2Endpoint extends AbstractApiEndpoint<Dhis2ApiName, Dhis2Configuration> {
@UriParam
@@ -57,13 +58,11 @@ public class Dhis2Endpoint extends AbstractApiEndpoint<Dhis2ApiName, Dhis2Config
this.configuration = endpointConfiguration;
}
- public Producer createProducer()
- throws Exception {
+ public Producer createProducer() throws Exception {
return new Dhis2Producer(this);
}
- public Consumer createConsumer(Processor processor)
- throws Exception {
+ public Consumer createConsumer(Processor processor) throws Exception {
// make sure inBody is not set for consumers
if (inBody != null) {
throw new IllegalArgumentException("Option inBody is not supported for consumer endpoint");
@@ -93,6 +92,12 @@ public class Dhis2Endpoint extends AbstractApiEndpoint<Dhis2ApiName, Dhis2Config
case POST:
apiProxy = new Dhis2Post(dhis2Client);
break;
+ case DELETE:
+ apiProxy = new Dhis2Delete(dhis2Client);
+ break;
+ case PUT:
+ apiProxy = new Dhis2Put(dhis2Client);
+ break;
case RESOURCE_TABLES:
apiProxy = new Dhis2ResourceTables(dhis2Client);
break;
diff --git a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Producer.java b/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Producer.java
index 50634f93d85..7b36e0c3a17 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Producer.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Producer.java
@@ -16,13 +16,27 @@
*/
package org.apache.camel.component.dhis2;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
import org.apache.camel.component.dhis2.internal.Dhis2ApiName;
import org.apache.camel.component.dhis2.internal.Dhis2PropertiesHelper;
import org.apache.camel.support.component.AbstractApiProducer;
+import org.apache.camel.support.component.ApiMethod;
public class Dhis2Producer extends AbstractApiProducer<Dhis2ApiName, Dhis2Configuration> {
public Dhis2Producer(Dhis2Endpoint endpoint) {
super(endpoint, Dhis2PropertiesHelper.getHelper(endpoint.getCamelContext()));
}
+
+ @Override
+ protected ApiMethod findMethod(Exchange exchange, Map<String, Object> properties) {
+ ApiMethod apiMethod = super.findMethod(exchange, properties);
+ if (!properties.containsKey("resource")) {
+ properties.put("resource", exchange.getIn().getBody());
+ }
+ return apiMethod;
+ }
+
}
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/Dhis2DeleteIT.java
similarity index 55%
copy from components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java
copy to components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java
index 1166937c6a1..76c79d09097 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/Dhis2DeleteIT.java
@@ -25,46 +25,56 @@ 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.Dhis2PostApiMethod;
-import org.hisp.dhis.api.model.v2_38_1.OrganisationUnit;
+import org.apache.camel.component.dhis2.internal.Dhis2DeleteApiMethod;
+import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit;
+import org.hisp.dhis.api.model.v2_39_1.WebMessage;
+import org.hisp.dhis.integration.sdk.api.RemoteDhis2ClientException;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test class for {@link org.apache.camel.component.dhis2.api.Dhis2Post} APIs.
*/
-public class Dhis2PostIT extends AbstractDhis2TestSupport {
+public class Dhis2DeleteIT extends AbstractDhis2TestSupport {
- private static final Logger LOG = LoggerFactory.getLogger(Dhis2PostIT.class);
- private static final String PATH_PREFIX = Dhis2ApiCollection.getCollection().getApiName(Dhis2PostApiMethod.class).getName();
+ private static final Logger LOG = LoggerFactory.getLogger(Dhis2DeleteIT.class);
+ private static final String PATH_PREFIX
+ = Dhis2ApiCollection.getCollection().getApiName(Dhis2DeleteApiMethod.class).getName();
@Test
- public void testResource() throws Exception {
- final Map<String, Object> headers = new HashMap<String, Object>();
+ public void testResource() {
+ String orgUnitId = (String) ((Map<String, Object>) Environment.DHIS2_CLIENT.post("organisationUnits")
+ .withResource(new OrganisationUnit().withName("Acme").withShortName("Acme").withOpeningDate(new Date()))
+ .transfer()
+ .returnAs(WebMessage.class).getResponse().get()).get("uid");
+
+ final Map<String, Object> headers = new HashMap<>();
// parameter type is String
- headers.put("CamelDhis2.path", "organisationUnits");
+ headers.put("CamelDhis2.path", String.format("organisationUnits/%s", orgUnitId));
// parameter type is java.util.Map
headers.put("CamelDhis2.queryParams", new HashMap<>());
- final java.io.InputStream result = requestBodyAndHeaders("direct://RESOURCE",
- new OrganisationUnit().withName("Foo").withShortName("Foo").withOpeningDate(new Date()),
- headers);
+ final java.io.InputStream result = requestBodyAndHeaders("direct://RESOURCE", null, headers);
+ RemoteDhis2ClientException remoteDhis2ClientException = assertThrows(RemoteDhis2ClientException.class,
+ () -> Environment.DHIS2_CLIENT.get("organisationUnits/{id}", orgUnitId).transfer()
+ .returnAs(OrganisationUnit.class));
+ assertEquals(404, remoteDhis2ClientException.getHttpStatusCode());
assertNotNull(result, "resource result");
LOG.debug("resource: " + result);
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- // test route for resource
from("direct://RESOURCE")
- .to("dhis2://" + PATH_PREFIX + "/resource?inBody=resource");
-
+ .to("dhis2://" + PATH_PREFIX + "/resource");
}
};
}
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 fcc140dcc38..db2e47ac047 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
@@ -45,7 +45,7 @@ public class Dhis2GetIT extends AbstractDhis2TestSupport {
// parameter type is String
headers.put("CamelDhis2.path", "organisationUnits");
// parameter type is String
- headers.put("CamelDhis2.itemType", "org.hisp.dhis.api.model.v2_38_1.OrganisationUnit");
+ headers.put("CamelDhis2.itemType", "org.hisp.dhis.api.model.v2_39_1.OrganisationUnit");
// parameter type is Boolean
headers.put("CamelDhis2.paging", true);
// parameter type is String
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 1166937c6a1..96b610ad862 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
@@ -26,7 +26,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.Dhis2PostApiMethod;
-import org.hisp.dhis.api.model.v2_38_1.OrganisationUnit;
+import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,14 +42,23 @@ public class Dhis2PostIT extends AbstractDhis2TestSupport {
private static final String PATH_PREFIX = Dhis2ApiCollection.getCollection().getApiName(Dhis2PostApiMethod.class).getName();
@Test
- public void testResource() throws Exception {
- final Map<String, Object> headers = new HashMap<String, Object>();
+ public void testResourceGivenInBody() {
+ postResource("direct://RESOURCE_WITH_INBODY");
+ }
+
+ @Test
+ public void testResource() {
+ postResource("direct://RESOURCE");
+ }
+
+ private void postResource(String endpointUri) {
+ final Map<String, Object> headers = new HashMap<>();
// parameter type is String
headers.put("CamelDhis2.path", "organisationUnits");
// parameter type is java.util.Map
headers.put("CamelDhis2.queryParams", new HashMap<>());
- final java.io.InputStream result = requestBodyAndHeaders("direct://RESOURCE",
+ final java.io.InputStream result = requestBodyAndHeaders(endpointUri,
new OrganisationUnit().withName("Foo").withShortName("Foo").withOpeningDate(new Date()),
headers);
@@ -58,13 +67,15 @@ public class Dhis2PostIT extends AbstractDhis2TestSupport {
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
// test route for resource
- from("direct://RESOURCE")
+ from("direct://RESOURCE_WITH_INBODY")
.to("dhis2://" + PATH_PREFIX + "/resource?inBody=resource");
+ from("direct://RESOURCE")
+ .to("dhis2://" + PATH_PREFIX + "/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/Dhis2PutIT.java
similarity index 59%
copy from components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java
copy to components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java
index 1166937c6a1..b0289b20639 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/Dhis2PutIT.java
@@ -25,46 +25,61 @@ 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.Dhis2PostApiMethod;
-import org.hisp.dhis.api.model.v2_38_1.OrganisationUnit;
+import org.apache.camel.component.dhis2.internal.Dhis2PutApiMethod;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test class for {@link org.apache.camel.component.dhis2.api.Dhis2Post} APIs.
*/
-public class Dhis2PostIT extends AbstractDhis2TestSupport {
+public class Dhis2PutIT extends AbstractDhis2TestSupport {
- private static final Logger LOG = LoggerFactory.getLogger(Dhis2PostIT.class);
- private static final String PATH_PREFIX = Dhis2ApiCollection.getCollection().getApiName(Dhis2PostApiMethod.class).getName();
+ private static final Logger LOG = LoggerFactory.getLogger(Dhis2PutIT.class);
+ private static final String PATH_PREFIX = Dhis2ApiCollection.getCollection().getApiName(Dhis2PutApiMethod.class).getName();
@Test
- public void testResource() throws Exception {
- final Map<String, Object> headers = new HashMap<String, Object>();
+ public void testResourceGivenInBody() {
+ putResource("direct://RESOURCE_WITH_INBODY");
+ }
+
+ @Test
+ public void testResource() {
+ putResource("direct://RESOURCE");
+ }
+
+ private void putResource(String endpointUri) {
+ final Map<String, Object> headers = new HashMap<>();
// parameter type is String
- headers.put("CamelDhis2.path", "organisationUnits");
+ headers.put("CamelDhis2.path", String.format("organisationUnits/%s", Environment.ORG_UNIT_ID));
// parameter type is java.util.Map
headers.put("CamelDhis2.queryParams", new HashMap<>());
- final java.io.InputStream result = requestBodyAndHeaders("direct://RESOURCE",
- new OrganisationUnit().withName("Foo").withShortName("Foo").withOpeningDate(new Date()),
- headers);
+ String name = RandomStringUtils.randomAlphabetic(8);
+ final java.io.InputStream result = requestBodyAndHeaders(endpointUri,
+ new OrganisationUnit().withName(name).withShortName(name).withOpeningDate(new Date()), headers);
+ OrganisationUnit organisationUnit = Environment.DHIS2_CLIENT.get("organisationUnits/{id}", Environment.ORG_UNIT_ID)
+ .transfer().returnAs(OrganisationUnit.class);
+ assertEquals(name, organisationUnit.getName().get());
assertNotNull(result, "resource result");
LOG.debug("resource: " + result);
}
@Override
- protected RouteBuilder createRouteBuilder() throws Exception {
+ protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- // test route for resource
- from("direct://RESOURCE")
+ from("direct://RESOURCE_WITH_INBODY")
.to("dhis2://" + PATH_PREFIX + "/resource?inBody=resource");
+ from("direct://RESOURCE")
+ .to("dhis2://" + PATH_PREFIX + "/resource");
}
};
}
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 60edba99db5..8ee0cc686d9 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
@@ -60,7 +60,6 @@ public class Dhis2ResourceTablesIT extends AbstractDhis2TestSupport {
// test route for analytics
from("direct://ANALYTICS")
.to("dhis2://" + PATH_PREFIX + "/analytics");
-
}
};
}
diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java
index e9ae33bc1df..31724fb8a72 100644
--- a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java
+++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java
@@ -20,9 +20,9 @@ import java.time.Duration;
import java.util.Date;
import java.util.Map;
-import org.hisp.dhis.api.model.v2_38_1.OrganisationUnit;
-import org.hisp.dhis.api.model.v2_38_1.OrganisationUnitLevel;
-import org.hisp.dhis.api.model.v2_38_1.WebMessage;
+import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit;
+import org.hisp.dhis.api.model.v2_39_1.OrganisationUnitLevel;
+import org.hisp.dhis.api.model.v2_39_1.WebMessage;
import org.hisp.dhis.integration.sdk.Dhis2ClientBuilder;
import org.hisp.dhis.integration.sdk.api.Dhis2Client;
import org.testcontainers.containers.BindMode;
@@ -34,6 +34,8 @@ import org.testcontainers.utility.DockerImageName;
public final class Environment {
+ public static final Dhis2Client DHIS2_CLIENT;
+
public static final String ORG_UNIT_ID;
private static final Network NETWORK = Network.newNetwork();
@@ -42,8 +44,6 @@ public final class Environment {
private static final GenericContainer<?> DHIS2_CONTAINER;
- private static final Dhis2Client DHIS2_CLIENT;
-
private Environment() {
}
diff --git a/components/camel-dhis2/pom.xml b/components/camel-dhis2/pom.xml
index 1fcdd1f57f1..03838b04144 100644
--- a/components/camel-dhis2/pom.xml
+++ b/components/camel-dhis2/pom.xml
@@ -33,21 +33,37 @@
<name>Camel :: DHIS2 :: Parent</name>
<description>Camel DHIS2 Component</description>
+ <properties>
+ <dhis2-java-sdk.version>2.0.0</dhis2-java-sdk.version>
+ </properties>
+
<modules>
<module>camel-dhis2-api</module>
<module>camel-dhis2-component</module>
</modules>
<dependencies>
+ <dependency>
+ <groupId>org.hisp.dhis.integration.sdk</groupId>
+ <artifactId>dhis2-java-sdk</artifactId>
+ <version>${dhis2-java-sdk.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis.integration.sdk</groupId>
+ <artifactId>jackson-resource-model</artifactId>
+ <version>${dhis2-java-sdk.version}</version>
+ <classifier>v2.39.1</classifier>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.hisp.dhis.integration.sdk</groupId>
- <artifactId>dhis2-java-sdk</artifactId>
- <version>1.0.0</version>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.12.0</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>