From 2cbd5d66bcda32d9c9c604feea661f57a6ff95c2 Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Wed, 2 Jul 2025 21:39:58 +0200 Subject: [PATCH] added a eventlog test client --- office-alexander-logistics-testclient/pom.xml | 143 ++++++++++++++++++ .../alexanderlogistics/rest/TestEventLog.java | 101 +++++++++++++ pom.xml | 1 + 3 files changed, 245 insertions(+) create mode 100644 office-alexander-logistics-testclient/pom.xml create mode 100644 office-alexander-logistics-testclient/src/test/java/com/alexanderlogistics/rest/TestEventLog.java diff --git a/office-alexander-logistics-testclient/pom.xml b/office-alexander-logistics-testclient/pom.xml new file mode 100644 index 0000000..4a31bec --- /dev/null +++ b/office-alexander-logistics-testclient/pom.xml @@ -0,0 +1,143 @@ + + + 4.0.0 + + office-alexander-logistics + com.alexander-logistics + 1.3.4 + + office-alexander-logistics-testclient + jar + Imixs Office Workflow Remote Test Client + + + + + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 11 + 11 + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + ${project.build.sourceEncoding} + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + + imixs-process-manager + + + + + + jakarta.platform + jakarta.jakartaee-api + 10.0.0 + provided + + + + + + org.imixs.workflow + imixs-workflow-core + ${org.imixs.workflow.version} + + + + + + org.imixs.workflow + imixs-melman + ${org.imixs.melman.version} + test + + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + + + + jakarta.xml.bind + jakarta.xml.bind-api + 3.0.0 + test + + + org.eclipse.parsson + jakarta.json + 1.1.1 + test + + + org.glassfish.jaxb + jaxb-runtime + 3.0.0 + test + + + org.glassfish.jersey.media + jersey-media-jaxb + 3.1.5 + test + + + + org.glassfish.jersey.core + jersey-client + 3.1.5 + + + + + \ No newline at end of file diff --git a/office-alexander-logistics-testclient/src/test/java/com/alexanderlogistics/rest/TestEventLog.java b/office-alexander-logistics-testclient/src/test/java/com/alexanderlogistics/rest/TestEventLog.java new file mode 100644 index 0000000..32a9bc7 --- /dev/null +++ b/office-alexander-logistics-testclient/src/test/java/com/alexanderlogistics/rest/TestEventLog.java @@ -0,0 +1,101 @@ +package com.alexanderlogistics.rest; + +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import org.imixs.melman.EventLogClient; +import org.imixs.melman.FormAuthenticator; +import org.imixs.melman.RestAPIException; +import org.imixs.workflow.ItemCollection; +import org.imixs.workflow.WorkflowKernel; +import org.imixs.workflow.exceptions.PluginException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * A simple example how to create a new event log entry remote. + * + */ +@Disabled +public class TestEventLog { + + private static Logger logger = Logger.getLogger(TestEventLog.class.getName()); + + EventLogClient client = null; + + // String restAPI = "https://test.alexander-logistics.office-workflow.de/api"; + String restAPI = "http://localhost:8080/api"; + String userID = "kutzner-service"; + String password = "imixs"; + + /** + * Setup a new Rest Client + * + * @throws PluginException + */ + @BeforeEach + public void setup() throws PluginException { + + client = new EventLogClient(restAPI); + FormAuthenticator aut; + try { + aut = new FormAuthenticator(restAPI, userID, password); + client.registerClientRequestFilter(aut); + } catch (RestAPIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * Create an event log entry.... + * + */ + @Test + public void sendXMLData() { + + logger.info("start..."); + ItemCollection payLoad = new ItemCollection(); + String uid = WorkflowKernel.generateUniqueID(); + try { + // set data.... + payLoad.setItemValue("some-data", "abc"); + String xmlString = "" + + "" + + " " + + " 224225" + + " " + + " "; + payLoad.setItemValue("xml-data", xmlString); + + client.createEventLogEntry("TOPIC_CARGOSOFT_INVOICE", uid, payLoad); + logger.info("completed"); + } catch (RestAPIException e) { + logger.severe("Failed to send event log entry: " + e.getMessage()); + e.printStackTrace(); + } + } + + @Test + public void getXMLData() { + logger.info("start..."); + try { + List list = client.searchEventLog("TOPIC_CARGOSOFT_INVOICE"); + logger.info("found " + list.size() + " log entries"); + for (ItemCollection entry : list) { + List dataList = entry.getItemValue("data"); + if (dataList != null && dataList.size() > 0) { + ItemCollection data = new ItemCollection((Map>) dataList.get(0)); + logger.info("Data=" + data.getItemValueString("some-data")); + logger.info("XML Data=" + data.getItemValueString("xml-data")); + } + } + } catch (RestAPIException e) { + logger.severe("Failed to read event log entry: " + e.getMessage()); + e.printStackTrace(); + } + } + +} diff --git a/pom.xml b/pom.xml index 659b70f..1d83e6c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ office-alexander-logistics-app + office-alexander-logistics-testclient