Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Issue #18
  • Loading branch information
rsoika committed Sep 4, 2024
1 parent 55b8316 commit 74a7ab2
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 43 deletions.
39 changes: 27 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<org.imixs.workflow.version>6.1.0-SNAPSHOT</org.imixs.workflow.version>
<mockito.version>5.8.0</mockito.version>
<jakarta.version>10.0.0</jakarta.version>
<junit.jupiter.version>5.9.2</junit.jupiter.version>
</properties>

<description>
Expand Down Expand Up @@ -97,7 +98,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<version>3.0.1</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
Expand All @@ -109,7 +110,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand All @@ -123,7 +124,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.9.0</version>
<version>3.12.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -158,6 +159,13 @@
</plugin>


<!-- Testing JUnit 5 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>

</plugins>
</build>

Expand Down Expand Up @@ -254,42 +262,49 @@
</dependency>

<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>

<!-- JUnit 5 Dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<!-- Mockito Dependencies -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>

</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>

</dependency>


<dependency>
<groupId>org.eclipse.parsson</groupId>
<artifactId>jakarta.json</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.0</version>

<scope>test</scope>
</dependency>


</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.imixs.workflow.engine;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.when;

import java.lang.reflect.Field;
Expand All @@ -16,7 +18,6 @@
import org.imixs.workflow.engine.adapters.AccessAdapter;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.exceptions.PluginException;
import org.junit.Assert;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
Expand Down Expand Up @@ -114,7 +115,7 @@ public void setUp() throws PluginException {
// Link modelService to workflowServiceMock
workflowService.modelService = modelService;
modelService.modelManager = new ModelManager();
Assert.assertNotNull(modelService.getModelManager());
assertNotNull(modelService.getModelManager());

workflowContext = new WorkflowContextMock();
workflowService.ctx = workflowContext.getSessionContext();
Expand Down Expand Up @@ -193,7 +194,7 @@ public void loadBPMNModel(String modelPath) {
BPMNModel model = BPMNModelFactory.read(modelPath);
modelService.getModelManager().addModel(model);
} catch (BPMNModelException | ModelException e) {
Assert.fail(e.getMessage());
fail(e.getMessage());
}
}

Expand Down
32 changes: 18 additions & 14 deletions src/test/java/org/imixs/example/TestBPMN.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package org.imixs.example;

// Import the JUnit 5 Assertions class
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -10,7 +16,6 @@
import org.imixs.workflow.engine.plugins.OwnerPlugin;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.exceptions.PluginException;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -45,16 +50,15 @@ public void testBasic() {

try {
workitem = workflowEnvironment.getWorkflowService().processWorkItem(workitem);

Assert.assertNotNull(workitem);
Assert.assertEquals(11001, workitem.getTaskID());
assertNotNull(workitem);
assertEquals(1100, workitem.getTaskID());

// test $readaccess
Assert.assertTrue(workitem.getItemValueString(WorkflowService.READACCESS).isEmpty());
assertTrue(workitem.getItemValueString(WorkflowService.READACCESS).isEmpty());

} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
fail(e.getMessage());
}

}
Expand All @@ -74,25 +78,25 @@ public void testBasicOwner() {
try {
workitem = workflowEnvironment.getWorkflowService().processWorkItem(workitem);

Assert.assertNotNull(workitem);
Assert.assertEquals(1100, workitem.getTaskID());
Assert.assertEquals("manfred", workitem.getItemValue(OwnerPlugin.OWNER, String.class));
assertNotNull(workitem);
assertEquals(1100, workitem.getTaskID());
assertEquals("manfred", workitem.getItemValue(OwnerPlugin.OWNER, String.class));

// test $owner
List<String> owners = workitem.getItemValue("$owner");
Assert.assertTrue(owners.contains("manfred"));
assertTrue(owners.contains("manfred"));

// test $readaccess
Assert.assertTrue(workitem.getItemValueString(WorkflowService.READACCESS).isEmpty());
assertTrue(workitem.getItemValueString(WorkflowService.READACCESS).isEmpty());

// test $writeaccess
List<String> writeAccess = workitem.getItemValue(WorkflowService.WRITEACCESS);
Assert.assertTrue(writeAccess.contains("manfred"));
Assert.assertTrue(writeAccess.contains("{process:Finance:assist}"));
assertTrue(writeAccess.contains("manfred"));
assertTrue(writeAccess.contains("{process:Finance:assist}"));

} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
fail(e.getMessage());
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.imixs.example.modeling;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.WorkflowMockEnvironment;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.exceptions.PluginException;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -43,12 +46,12 @@ public void testSimpleConditionalEvent() {
try {
workitem = workflowEnvironment.getWorkflowService().processWorkItem(workitem);

Assert.assertNotNull(workitem);
Assert.assertEquals(1100, workitem.getTaskID());
assertNotNull(workitem);
assertEquals(1100, workitem.getTaskID());

} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
fail(e.getMessage());
}

// test _budget < 100
Expand All @@ -59,12 +62,11 @@ public void testSimpleConditionalEvent() {
try {
workitem = workflowEnvironment.getWorkflowService().processWorkItem(workitem);

Assert.assertNotNull(workitem);
Assert.assertEquals(1200, workitem.getTaskID());
assertNotNull(workitem);
assertEquals(1200, workitem.getTaskID());

} catch (Exception e) {
e.printStackTrace();
Assert.fail();
fail(e.getMessage());
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.imixs.example.modeling;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.WorkflowMockEnvironment;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.exceptions.PluginException;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -46,15 +49,14 @@ public void testSimpleConditionalEvent() {
// in this case the budget will be computed by a business rule (RulePlugin)
workitem = workflowEnvironment.getWorkflowService().processWorkItem(workitem);

Assert.assertNotNull(workitem);
assertNotNull(workitem);
// test budget
Assert.assertEquals(500, workitem.getItemValueInteger("_budget"));
assertEquals(500, workitem.getItemValueInteger("_budget"));
// test conditional event
Assert.assertEquals(1100, workitem.getTaskID());
assertEquals(1100, workitem.getTaskID());

} catch (Exception e) {
e.printStackTrace();
Assert.fail();
fail(e.getMessage());
}

}
Expand Down

0 comments on commit 74a7ab2

Please sign in to comment.