Skip to content

Commit

Permalink
updated pom.xml , fixes test simulation service
Browse files Browse the repository at this point in the history
Issue #859
  • Loading branch information
rsoika committed May 7, 2024
1 parent f5644f3 commit 0a8cf67
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.xml.sax.SAXException;
import java.util.logging.Level;

/**
* The WorkflowSimulationEnvironment provides a test environment for jUnit
Expand Down Expand Up @@ -54,23 +55,23 @@ public class WorkflowSimulationEnvironment {
protected SessionContext ctx;

protected WorkflowContext workflowContext;

@Spy
protected SimulationService simulationService;
protected List<String> plugins=null;
protected List<String> plugins = null;

@SuppressWarnings("unchecked")
@Before
public void setUp() throws PluginException, ModelException, AccessDeniedException, ProcessingErrorException {
MockitoAnnotations.initMocks(this);
// MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);

// mock session context
ctx = Mockito.mock(SessionContext.class);
// simulate SessionContext ctx.getCallerPrincipal().getName()
// simulate Principal
Principal principal = Mockito.mock(Principal.class);
when(principal.getName()).thenReturn("manfred");
when(ctx.getCallerPrincipal()).thenReturn(principal);

// mock Entity service

// Mock modelService (using the @spy) annotation
Mockito.doNothing().when(modelService).init();

Expand All @@ -90,20 +91,13 @@ public void setUp() throws PluginException, ModelException, AccessDeniedExceptio
workflowContext = Mockito.mock(WorkflowContext.class);
when(workflowContext.getModelManager()).thenReturn(modelManager);

// Mock WorkflowService
simulationService = Mockito.mock(SimulationService.class);
// workflowService.documentService = documentService;
// setup SimulationService
simulationService.setCtx(ctx);

simulationService.setModelService(modelService);
when(simulationService.getModelManager()).thenReturn(modelService);

when(simulationService.processWorkItem(Mockito.any(ItemCollection.class), Mockito.any(List.class)))
.thenCallRealMethod();

}


public String getModelPath() {
return modelPath;
}
Expand Down Expand Up @@ -133,40 +127,36 @@ public void loadModel() {
if (this.modelPath != null) {
InputStream inputStream = getClass().getResourceAsStream(this.modelPath);
try {
logger.info("loading model: " + this.modelPath + "....");
logger.log(Level.INFO, "loading model: {0}....", this.modelPath);
model = BPMNParser.parseModel(inputStream, "UTF-8");

this.modelService.addModel(model);
} catch (ModelException | ParseException | ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace();
}

}

}

public List<String> getPlugins() {
return plugins;
}


public void setPlugins(List<String> plugins) {
this.plugins = plugins;
}


/**
* Simulates a processing life cycle
* Simulates a processing life cycle
*
* @param workitem
* @return
* @throws ModelException
* @throws PluginException
* @throws ProcessingErrorException
* @throws AccessDeniedException
* @throws ModelException
* @throws PluginException
* @throws ProcessingErrorException
* @throws AccessDeniedException
*/
public ItemCollection processWorkItem(ItemCollection workitem) throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
public ItemCollection processWorkItem(ItemCollection workitem)
throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
workitem = simulationService.processWorkItem(workitem, plugins);
return workitem;
}

}
19 changes: 15 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<jakarta.version>8.0</jakarta.version>
<microprofile.version>3.3</microprofile.version>
<lucene.version>7.7.3</lucene.version>
<!-- 20.2.0 22.3.1 -->
<graalvm.version>22.3.2</graalvm.version>
</properties>


Expand Down Expand Up @@ -110,7 +112,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 @@ -122,7 +124,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 Down Expand Up @@ -288,8 +290,8 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<artifactId>mockito-core</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -305,6 +307,15 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.4</version>
<scope>test</scope>
</dependency>



</dependencies>


Expand Down

0 comments on commit 0a8cf67

Please sign in to comment.