From bfe9320da51075e1e64499dbdbb9dc855758f081 Mon Sep 17 00:00:00 2001 From: Andreas Riepl Date: Wed, 29 May 2024 15:03:05 +0200 Subject: [PATCH] fix(miranum): complex object mapping (#362) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #360 --------- Co-authored-by: Lukas Mösle <37705369+lmoesle@users.noreply.github.com> --- .../remote/utils/Camunda7PojoMapper.java | 5 +- .../remote/utils/Camunda7PojoMapperTest.java | 19 +- .../remote/worker/Camunda7WorkerAdapter.java | 31 +-- .../in/c8/message/Camunda8MessageAdapter.java | 2 - .../elementtemplate/api/PropertyType.java | 4 +- .../WorkerAnnotationBeanPostProcessor.java | 2 - .../worker/impl/WorkerExecuteApiImpl.java | 1 + .../impl/impl/WorkerExecuteApiImplTest.java | 210 +++++++++++++++++- .../c7/Camunda7ElementTemplateGenerator.java | 4 +- .../c8/Camunda8ElementTemplateGenerator.java | 7 +- .../src/main/resources/application.yml | 10 +- 11 files changed, 241 insertions(+), 54 deletions(-) diff --git a/connect/camunda7-remote/utils/src/main/java/io/miragon/miranum/connect/camnda7/remote/utils/Camunda7PojoMapper.java b/connect/camunda7-remote/utils/src/main/java/io/miragon/miranum/connect/camnda7/remote/utils/Camunda7PojoMapper.java index ea2e57a6e..41282ecf8 100644 --- a/connect/camunda7-remote/utils/src/main/java/io/miragon/miranum/connect/camnda7/remote/utils/Camunda7PojoMapper.java +++ b/connect/camunda7-remote/utils/src/main/java/io/miragon/miranum/connect/camnda7/remote/utils/Camunda7PojoMapper.java @@ -4,10 +4,10 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.ClassUtils; +import org.camunda.bpm.client.variable.ClientValues; import org.camunda.bpm.client.variable.impl.value.JsonValueImpl; import org.camunda.bpm.engine.variable.VariableMap; import org.camunda.bpm.engine.variable.Variables; -import org.camunda.bpm.engine.variable.type.PrimitiveValueType; import org.camunda.bpm.engine.variable.value.TypedValue; import java.util.HashMap; @@ -36,7 +36,7 @@ public Map mapFromEngineData(final VariableMap variables) { final Map data = new HashMap<>(); variables.keySet().forEach(key -> { final TypedValue value = variables.getValueTyped(key); - if (value.getType().getName().equals(PrimitiveValueType.OBJECT.getName())) { + if (value.getType().equals(ClientValues.JSON)) { try { data.put(key, this.mapFromEngineData(value.getValue())); } catch (final JsonProcessingException e) { @@ -50,7 +50,6 @@ public Map mapFromEngineData(final VariableMap variables) { } public Object mapFromEngineData(final Object value) throws JsonProcessingException { - // TODO: Check if Variables.SerializationDataFormats.JSON. May we support XML and JAVA as well? final ObjectMapper mapper = new ObjectMapper(); if (value.toString().startsWith("[")) { return mapper.readValue(value.toString(), new TypeReference>() { diff --git a/connect/camunda7-remote/utils/src/test/java/io/miragon/miranum/connect/camnda7/remote/utils/Camunda7PojoMapperTest.java b/connect/camunda7-remote/utils/src/test/java/io/miragon/miranum/connect/camnda7/remote/utils/Camunda7PojoMapperTest.java index d9829b11c..5a13320c3 100644 --- a/connect/camunda7-remote/utils/src/test/java/io/miragon/miranum/connect/camnda7/remote/utils/Camunda7PojoMapperTest.java +++ b/connect/camunda7-remote/utils/src/test/java/io/miragon/miranum/connect/camnda7/remote/utils/Camunda7PojoMapperTest.java @@ -1,6 +1,8 @@ package io.miragon.miranum.connect.camnda7.remote.utils; import com.fasterxml.jackson.core.JsonProcessingException; +import org.camunda.bpm.client.variable.ClientValues; +import org.camunda.bpm.client.variable.impl.value.JsonValueImpl; import org.camunda.bpm.engine.variable.VariableMap; import org.camunda.bpm.engine.variable.Variables; import org.junit.jupiter.api.Test; @@ -54,11 +56,9 @@ public void testMap_EmptyInput_ShouldReturnEmptyMap() throws JsonProcessingExcep @Test public void testMapFromEngineData_JsonObjectValue_ShouldReturnMap() { // Given a VariableMap with a JSON object value - VariableMap variableMap = Variables.createVariables() - .putValueTyped("var1", Variables - .objectValue("{\"key\":\"value\"}") - .serializationDataFormat(Variables.SerializationDataFormats.JSON) - .create()); + VariableMap variableMap = Variables + .createVariables() + .putValueTyped("var1", new JsonValueImpl("{\"key\":\"value\"}")); // When Map result = mapper.mapFromEngineData(variableMap); @@ -71,12 +71,9 @@ public void testMapFromEngineData_JsonObjectValue_ShouldReturnMap() { @Test public void testMapFromEngineData_JsonArrayToList() { // Given a VariableMap with a JSON list - String jsonArray = "[{\"key\":\"value1\"}, {\"key2\":\"value2\"}]"; - VariableMap variableMap = Variables.createVariables() - .putValueTyped("var1", Variables - .objectValue(jsonArray) - .serializationDataFormat(Variables.SerializationDataFormats.JSON) - .create()); + VariableMap variableMap = Variables + .createVariables() + .putValueTyped("var1", new JsonValueImpl("[{\"key\":\"value1\"}, {\"key2\":\"value2\"}]")); // When Map result = mapper.mapFromEngineData(variableMap); diff --git a/connect/camunda7-remote/worker/src/main/java/io/miragon/miranum/connect/camunda7/remote/worker/Camunda7WorkerAdapter.java b/connect/camunda7-remote/worker/src/main/java/io/miragon/miranum/connect/camunda7/remote/worker/Camunda7WorkerAdapter.java index 67cd89bea..51ee8c02b 100644 --- a/connect/camunda7-remote/worker/src/main/java/io/miragon/miranum/connect/camunda7/remote/worker/Camunda7WorkerAdapter.java +++ b/connect/camunda7-remote/worker/src/main/java/io/miragon/miranum/connect/camunda7/remote/worker/Camunda7WorkerAdapter.java @@ -7,17 +7,18 @@ import io.miragon.miranum.connect.worker.api.WorkerSubscription; import io.miragon.miranum.connect.worker.impl.WorkerExecutor; import lombok.RequiredArgsConstructor; -import lombok.extern.java.Log; +import lombok.extern.slf4j.Slf4j; import org.camunda.bpm.client.ExternalTaskClient; import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; import java.util.Arrays; import java.util.Map; -import java.util.Objects; + +import static java.util.Objects.nonNull; @RequiredArgsConstructor -@Log +@Slf4j public class Camunda7WorkerAdapter implements WorkerSubscription { private final ExternalTaskClient externalTaskClient; @@ -37,18 +38,19 @@ public void execute(final WorkerExecutor executor, final ExternalTask externalTa Integer workerRetries = null; try { final Map data = camunda7PojoMapper.mapFromEngineData(externalTask.getAllVariablesTyped()); + log.debug("Worker {} called with parameters {}", executor.getType(), data); workerRetries = (Integer) data.get("retries"); final Map result = this.workerExecuteApi.execute(executor, data); service.complete(externalTask, null, camunda7PojoMapper.mapToEngineData(result)); } catch (final BusinessException exception) { - log.severe("use case could not be executed " + exception.getMessage()); + log.warn("Use case could not be executed {}", exception.getMessage()); service.handleBpmnError(externalTask, exception.getCode(), exception.getMessage()); } catch (final TechnicalException error) { - log.severe("Technical error while executing task " + error.getMessage()); + log.warn("Technical error while executing task {}", error.getMessage()); service.handleFailure(externalTask, error.getMessage(), Arrays.toString(error.getStackTrace()), 0, 0L); } catch (final Exception error) { int retries = getRemainingRetries(externalTask.getRetries(), workerRetries); - log.severe("Error while executing external task " + error.getMessage()); + log.error("Error while executing external task {}", error.getMessage()); service.handleFailure(externalTask, error.getMessage(), Arrays.toString(error.getStackTrace()), retries, 5000L); } } @@ -66,15 +68,16 @@ public void execute(final WorkerExecutor executor, final ExternalTask externalTa * @return The remaining number of retries for the task. */ private int getRemainingRetries(Integer externalTaskRetries, Integer workerRetries) { - int retries = 0; - if (Objects.isNull(externalTaskRetries)) { - retries = Objects.isNull(workerRetries) ? - camunda7WorkerProperties.getDefaultRetries() : - workerRetries; - } else { + int retries; + + if (nonNull(externalTaskRetries)) { retries = externalTaskRetries; + } else if (nonNull(workerRetries)) { + retries = workerRetries; + } else { + retries = camunda7WorkerProperties.getDefaultRetries(); } - retries -= 1; - return Math.max(retries, 0); + + return Math.max(retries - 1, 0); } } diff --git a/connect/camunda8/message/src/main/java/io/miragon/miranum/connect/adapter/in/c8/message/Camunda8MessageAdapter.java b/connect/camunda8/message/src/main/java/io/miragon/miranum/connect/adapter/in/c8/message/Camunda8MessageAdapter.java index f7da03dcd..5c789cc68 100644 --- a/connect/camunda8/message/src/main/java/io/miragon/miranum/connect/adapter/in/c8/message/Camunda8MessageAdapter.java +++ b/connect/camunda8/message/src/main/java/io/miragon/miranum/connect/adapter/in/c8/message/Camunda8MessageAdapter.java @@ -5,9 +5,7 @@ import io.miragon.miranum.connect.message.impl.DeliverMessagePort; import io.miragon.miranum.connect.message.impl.MessageCorrelationException; import lombok.RequiredArgsConstructor; -import lombok.extern.java.Log; -@Log @RequiredArgsConstructor public class Camunda8MessageAdapter implements DeliverMessagePort { diff --git a/connect/core/element-template-api/src/main/java/io/miragon/miranum/connect/elementtemplate/api/PropertyType.java b/connect/core/element-template-api/src/main/java/io/miragon/miranum/connect/elementtemplate/api/PropertyType.java index d37a70cf9..e667f3262 100644 --- a/connect/core/element-template-api/src/main/java/io/miragon/miranum/connect/elementtemplate/api/PropertyType.java +++ b/connect/core/element-template-api/src/main/java/io/miragon/miranum/connect/elementtemplate/api/PropertyType.java @@ -1,9 +1,7 @@ package io.miragon.miranum.connect.elementtemplate.api; import com.fasterxml.jackson.annotation.JsonValue; -import lombok.extern.java.Log; -@Log public enum PropertyType { STRING("String"), TEXT("Text"), @@ -26,7 +24,7 @@ public String getType() { public static PropertyType getType(Class type) { if (type != String.class) { - log.warning(String.format("Unsupported type \"%s\". PropertyType String is assumed.", type.getName())); + throw new RuntimeException(String.format("Unsupported type '%s'. PropertyType String is assumed.", type.getName())); } return PropertyType.STRING; } diff --git a/connect/core/worker-api/src/main/java/io/miragon/miranum/connect/worker/impl/WorkerAnnotationBeanPostProcessor.java b/connect/core/worker-api/src/main/java/io/miragon/miranum/connect/worker/impl/WorkerAnnotationBeanPostProcessor.java index c92650467..748990044 100644 --- a/connect/core/worker-api/src/main/java/io/miragon/miranum/connect/worker/impl/WorkerAnnotationBeanPostProcessor.java +++ b/connect/core/worker-api/src/main/java/io/miragon/miranum/connect/worker/impl/WorkerAnnotationBeanPostProcessor.java @@ -4,14 +4,12 @@ import io.miragon.miranum.connect.worker.api.WorkerRegistry; import lombok.NonNull; import lombok.RequiredArgsConstructor; -import lombok.extern.java.Log; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.util.ReflectionUtils; import java.lang.reflect.Method; -@Log @RequiredArgsConstructor public class WorkerAnnotationBeanPostProcessor implements BeanPostProcessor { diff --git a/connect/core/worker-api/src/main/java/io/miragon/miranum/connect/worker/impl/WorkerExecuteApiImpl.java b/connect/core/worker-api/src/main/java/io/miragon/miranum/connect/worker/impl/WorkerExecuteApiImpl.java index 2cf34e86c..1316efcaa 100644 --- a/connect/core/worker-api/src/main/java/io/miragon/miranum/connect/worker/impl/WorkerExecuteApiImpl.java +++ b/connect/core/worker-api/src/main/java/io/miragon/miranum/connect/worker/impl/WorkerExecuteApiImpl.java @@ -39,6 +39,7 @@ public Map execute(final WorkerExecutor executor, final Object d private Object mapInput(final Class inputType, final Object object) { final ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true); return Objects.nonNull(inputType) ? mapper.convertValue(object, inputType) : null; } diff --git a/connect/core/worker-api/src/test/java/io/miragon/miranum/connect/worker/impl/impl/WorkerExecuteApiImplTest.java b/connect/core/worker-api/src/test/java/io/miragon/miranum/connect/worker/impl/impl/WorkerExecuteApiImplTest.java index 5990e7ded..27318f5ea 100644 --- a/connect/core/worker-api/src/test/java/io/miragon/miranum/connect/worker/impl/impl/WorkerExecuteApiImplTest.java +++ b/connect/core/worker-api/src/test/java/io/miragon/miranum/connect/worker/impl/impl/WorkerExecuteApiImplTest.java @@ -1,11 +1,16 @@ package io.miragon.miranum.connect.worker.impl.impl; +import com.fasterxml.jackson.core.JsonProcessingException; import io.miragon.miranum.connect.worker.api.BusinessException; import io.miragon.miranum.connect.worker.api.TechnicalException; import io.miragon.miranum.connect.worker.api.WorkerExecuteApi; import io.miragon.miranum.connect.worker.api.WorkerInterceptor; import io.miragon.miranum.connect.worker.impl.WorkerExecuteApiImpl; import io.miragon.miranum.connect.worker.impl.WorkerExecutor; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -15,6 +20,9 @@ import java.util.List; import java.util.Map; +import static java.util.Map.entry; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; @@ -27,8 +35,8 @@ public class WorkerExecuteApiImplTest { // test data private final Map event = Map.ofEntries( - Map.entry("test", "test"), - Map.entry("test2", "test2") + entry("test", "test"), + entry("test2", "test2") ); WorkerExecuteApiImplTest() { @@ -43,12 +51,12 @@ void testExecuteWorker() throws InvocationTargetException, IllegalAccessExceptio when(this.workerExecutor.execute(this.event)).thenReturn(this.event); final Object result = this.workerExecuteApi.execute(this.workerExecutor, this.event); - Assertions.assertEquals(this.event, result); + assertEquals(this.event, result); // make sure that the worker was called final ArgumentCaptor> inputArgumentCaptor = ArgumentCaptor.forClass(Map.class); Mockito.verify(this.workerExecutor).execute(inputArgumentCaptor.capture()); - Assertions.assertEquals(this.event, inputArgumentCaptor.getValue()); + assertEquals(this.event, inputArgumentCaptor.getValue()); } @Test @@ -61,13 +69,13 @@ void testExecuteWorker_withInterceptor() throws InvocationTargetException, Illeg when(this.workerExecutor.execute(this.event)).thenReturn(this.event); final Object result = workerExecuteApi.execute(this.workerExecutor, this.event); - Assertions.assertEquals(this.event, result); + assertEquals(this.event, result); // make sure that the interceptor was called final ArgumentCaptor workerExecutorArgumentCaptor = ArgumentCaptor.forClass(WorkerExecutor.class); final ArgumentCaptor> interceptorArgumentCaptor = ArgumentCaptor.forClass(Map.class); Mockito.verify(this.interceptor).intercept(workerExecutorArgumentCaptor.capture(), interceptorArgumentCaptor.capture()); - Assertions.assertEquals(this.event, interceptorArgumentCaptor.getValue()); + assertEquals(this.event, interceptorArgumentCaptor.getValue()); } @Test @@ -100,6 +108,194 @@ void testExecuteWorker_withNullInputType_shouldNotThrowException() throws Invoca when(this.workerExecutor.execute(null)).thenReturn(this.event); final Object result = this.workerExecuteApi.execute(this.workerExecutor, null); - Assertions.assertEquals(this.event, result); + assertEquals(this.event, result); + } + + @Test + void testExecute_withValidComplexInputObjectC8() throws IllegalAccessException, InvocationTargetException { + // Arrange + ComplexInputObject inputObject = new ComplexInputObject( + "John", "Doe", + List.of("Role1", "Role2"), + Map.ofEntries( + entry("key1", "value1"), + entry("key2", "value2") + ) + ); + Map expectedOutput = Map.of("result", "success"); + + when(this.workerExecutor.getInputType()).thenReturn((Class) ComplexInputObject.class); + when(this.workerExecutor.execute(any())).thenReturn(expectedOutput); + + WorkerInterceptor interceptor = Mockito.mock(WorkerInterceptor.class); + List interceptors = List.of(interceptor); + WorkerExecuteApiImpl workerExecuteApiImpl = new WorkerExecuteApiImpl(interceptors); + + // Act + Map result = workerExecuteApiImpl.execute(this.workerExecutor, inputObject); + + // Assert + assertNotNull(result); + assertEquals(expectedOutput, result); + Mockito.verify(interceptor, Mockito.times(1)).intercept(any(), any()); + Mockito.verify(this.workerExecutor, Mockito.times(1)).execute(any()); + } + + @Test + void testExecute_throwsRuntimeExceptionOnIllegalAccessException() throws IllegalAccessException, InvocationTargetException { + // Arrange + when(this.workerExecutor.getInputType()).thenReturn((Class) ComplexInputObject.class); + when(this.workerExecutor.execute(any())).thenThrow(IllegalAccessException.class); + + // Act & Assert + RuntimeException exception = Assertions.assertThrows(RuntimeException.class, () -> { + workerExecuteApi.execute(this.workerExecutor, new ComplexInputObject( + "John", "Doe", + List.of("Role1", "Role2"), + Map.ofEntries( + entry("key1", "value1"), + entry("key2", "value2") + ) + )); + }); + + assertEquals(IllegalAccessException.class, exception.getCause().getClass()); + } + + @Test + void testExecute_withNestedComplexInputObjectC8() throws IllegalAccessException, InvocationTargetException, JsonProcessingException { + // Arrange + ComplexInputObject nestedObject = new ComplexInputObject( + "Jane", "Doe", + List.of("NestedRole1", "NestedRole2"), + Map.ofEntries( + entry("nestedKey1", "nestedValue1"), + entry("nestedKey2", "nestedValue2") + ) + ); + + ComplexInputObject inputObject = new ComplexInputObject( + "John", "Doe", + List.of("Role1", "Role2"), + Map.ofEntries( + entry("key1", "value1"), + entry("key2", "value2"), + entry("nestedObject", nestedObject.toString()) + ) + ); + + Map expectedOutput = Map.of("result", "success"); + + when(this.workerExecutor.getInputType()).thenReturn((Class) ComplexInputObject.class); + when(this.workerExecutor.execute(any())).thenReturn(expectedOutput); + + WorkerInterceptor interceptor = Mockito.mock(WorkerInterceptor.class); + List interceptors = List.of(interceptor); + WorkerExecuteApiImpl workerExecuteApiImpl = new WorkerExecuteApiImpl(interceptors); + + // Act + Map result = workerExecuteApiImpl.execute(this.workerExecutor, inputObject); + + // Assert + assertNotNull(result); + assertEquals(expectedOutput, result); + Mockito.verify(interceptor, Mockito.times(1)).intercept(any(), any()); + Mockito.verify(this.workerExecutor, Mockito.times(1)).execute(any()); + } + + @Test + void testMapInput_withNestedComplexInputInnerListObjectC8() throws InvocationTargetException, IllegalAccessException { + // Define the complex input object with the nested object included directly + ObjectWithInnerObjectList inputObject = new ObjectWithInnerObjectList( + "John", + List.of(new NestedObject("hi", "dude"), + new NestedObject("whats", "up"), + new NestedObject("2", "night"))); + + Map expectedOutput = Map.of("result", "success"); + + when(this.workerExecutor.getInputType()).thenReturn((Class) ObjectWithInnerObjectList.class); + when(this.workerExecutor.execute(any())).thenReturn(expectedOutput); + + WorkerInterceptor interceptor = Mockito.mock(WorkerInterceptor.class); + List interceptors = List.of(interceptor); + WorkerExecuteApiImpl workerExecuteApiImpl = new WorkerExecuteApiImpl(interceptors); + + // Act + Map result = workerExecuteApiImpl.execute(this.workerExecutor, inputObject); + + // Assert + assertNotNull(result); + assertEquals(expectedOutput, result); + Mockito.verify(interceptor, Mockito.times(1)).intercept(any(), any()); + Mockito.verify(this.workerExecutor, Mockito.times(1)).execute(any()); + } + + @Test + void testMapInput_withNestedComplexInputInnerMapObjectC8() throws InvocationTargetException, IllegalAccessException { + // Define the complex input object with the nested object included directly + ObjectWithInnerObjectMap inputObject = new ObjectWithInnerObjectMap( + "John", + Map.ofEntries( + entry("1", new NestedObject("Hi", "It's me")), + entry("2", new NestedObject("How", "Are You")) + )); + + Map expectedOutput = Map.of("result", "success"); + + when(this.workerExecutor.getInputType()).thenReturn((Class) ObjectWithInnerObjectMap.class); + when(this.workerExecutor.execute(any())).thenReturn(expectedOutput); + + WorkerInterceptor interceptor = Mockito.mock(WorkerInterceptor.class); + List interceptors = List.of(interceptor); + WorkerExecuteApiImpl workerExecuteApiImpl = new WorkerExecuteApiImpl(interceptors); + + // Act + Map result = workerExecuteApiImpl.execute(this.workerExecutor, inputObject); + + // Assert + assertNotNull(result); + assertEquals(expectedOutput, result); + Mockito.verify(interceptor, Mockito.times(1)).intercept(any(), any()); + Mockito.verify(this.workerExecutor, Mockito.times(1)).execute(any()); + } + + + @Setter + @Getter + @NoArgsConstructor + @AllArgsConstructor + static class ComplexInputObject { + private String firstName; + private String lastName; + private List roles; + private Map attributes; + } + + @Setter + @Getter + @NoArgsConstructor + @AllArgsConstructor + static class ObjectWithInnerObjectList { + private String name; + private List attributes; + } + + @Setter + @Getter + @NoArgsConstructor + @AllArgsConstructor + static class ObjectWithInnerObjectMap { + private String name; + private Map attributes; + } + + @Setter + @Getter + @NoArgsConstructor + @AllArgsConstructor + static class NestedObject { + private String nestedField1; + private String nestedField2; } } diff --git a/connect/templates/camunda7/src/main/java/io/miragon/miranum/connect/elementtemplate/c7/Camunda7ElementTemplateGenerator.java b/connect/templates/camunda7/src/main/java/io/miragon/miranum/connect/elementtemplate/c7/Camunda7ElementTemplateGenerator.java index 23679c2fe..d9181a9c5 100644 --- a/connect/templates/camunda7/src/main/java/io/miragon/miranum/connect/elementtemplate/c7/Camunda7ElementTemplateGenerator.java +++ b/connect/templates/camunda7/src/main/java/io/miragon/miranum/connect/elementtemplate/c7/Camunda7ElementTemplateGenerator.java @@ -7,11 +7,11 @@ import io.miragon.miranum.platform.connect.c7.elementtemplates.gen.CamundaC7ElementTemplate; import io.miragon.miranum.platform.connect.c7.elementtemplates.gen.Constraints; import io.miragon.miranum.platform.connect.c7.elementtemplates.gen.Property; -import lombok.extern.java.Log; +import lombok.extern.slf4j.Slf4j; import java.util.Collections; -@Log +@Slf4j public class Camunda7ElementTemplateGenerator implements ElementTemplateGenerator { @Override diff --git a/connect/templates/camunda8/src/main/java/io/miragon/miranum/connect/elementtemplate/c8/Camunda8ElementTemplateGenerator.java b/connect/templates/camunda8/src/main/java/io/miragon/miranum/connect/elementtemplate/c8/Camunda8ElementTemplateGenerator.java index 79376d104..d60e1c808 100644 --- a/connect/templates/camunda8/src/main/java/io/miragon/miranum/connect/elementtemplate/c8/Camunda8ElementTemplateGenerator.java +++ b/connect/templates/camunda8/src/main/java/io/miragon/miranum/connect/elementtemplate/c8/Camunda8ElementTemplateGenerator.java @@ -7,11 +7,9 @@ import io.miragon.miranum.connect.elementtemplate.c8.schema.Constraints; import io.miragon.miranum.connect.elementtemplate.c8.schema.Property; import io.miragon.miranum.connect.elementtemplate.core.*; -import lombok.extern.java.Log; import java.util.List; -@Log public class Camunda8ElementTemplateGenerator implements ElementTemplateGenerator { @Override @@ -73,12 +71,11 @@ private Property createPropertyWithValue(ElementTemplatePropertyInfo info, boole // Only set if false, else jackson will display default value in generated json if (!info.isNotEmpty()) { - property.setConstraints(new Constraints() - .setNotEmpty(info.isNotEmpty())); + property.setConstraints(new Constraints().setNotEmpty(false)); } if (!info.isEditable()) { - property.setEditable(info.isEditable()); + property.setEditable(false); } return property; diff --git a/platform/examples/single-deployment-unit-example/src/main/resources/application.yml b/platform/examples/single-deployment-unit-example/src/main/resources/application.yml index 294f4d826..9f4157e72 100644 --- a/platform/examples/single-deployment-unit-example/src/main/resources/application.yml +++ b/platform/examples/single-deployment-unit-example/src/main/resources/application.yml @@ -74,12 +74,12 @@ spring: application: name: '@project.artifactId@' datasource: - url: '${ENGINE_DATASOURCE_URL:jdbc:h2:file:~/backenddb;DB_CLOSE_ON_EXIT=FALSE}' - username: '${ENGINE_DATASOURCE_USER:sa}' - password: '${ENGINE_DATASOURCE_PASSWORD:}' - driver-class-name: '${ENGINE_DATASOURCE_DRIVERCLASSNAME:org.h2.Driver}' + url: '${ENGINE_DATASOURCE_URL:localhost:5432}' + username: '${ENGINE_DATASOURCE_USER:user}' + password: '${ENGINE_DATASOURCE_PASSWORD:secret}' + driver-class-name: '${ENGINE_DATASOURCE_DRIVERCLASSNAME:org.postgresql.Driver}' jpa: - database-platform: '${ENGINE_DATABASE_PLATFORM:org.hibernate.dialect.H2Dialect}' + database-platform: '${ENGINE_DATABASE_PLATFORM:org.hibernate.dialect.PostgreSQLDialect}' hibernate: ddl-auto: validate open-in-view: true