Skip to content

Commit 3cf0f19

Browse files
committed
Closes #2404 - Changes jakarta migration in wildfly
1 parent 8cb1db3 commit 3cf0f19

File tree

50 files changed

+1534
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1534
-281
lines changed

common/taskana-common-logging/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
</dependency>
4646
<dependency>
4747
<groupId>org.mockito</groupId>
48-
<version>${version.mockito-inline}</version>
49-
<artifactId>mockito-inline</artifactId>
48+
<artifactId>mockito-core</artifactId>
5049
<scope>test</scope>
5150
</dependency>
5251
</dependencies>

history/taskana-loghistory-provider/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
</dependency>
6060
<dependency>
6161
<groupId>org.mockito</groupId>
62-
<version>${version.mockito-inline}</version>
63-
<artifactId>mockito-inline</artifactId>
62+
<artifactId>mockito-core</artifactId>
6463
<scope>test</scope>
6564
</dependency>
6665
</dependencies>

history/taskana-simplehistory-provider/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666
</dependency>
6767
<dependency>
6868
<groupId>org.mockito</groupId>
69-
<version>${version.mockito-inline}</version>
70-
<artifactId>mockito-inline</artifactId>
69+
<artifactId>mockito-core</artifactId>
7170
<scope>test</scope>
7271
</dependency>
7372
<dependency>

history/taskana-simplehistory-rest-spring/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<dependency>
105105
<groupId>org.springframework.plugin</groupId>
106106
<artifactId>spring-plugin-core</artifactId>
107-
<version>${version.spring.core}</version>
107+
<version>${version.spring.plugin.core}</version>
108108
<scope>test</scope>
109109
</dependency>
110110
<dependency>

lib/taskana-cdi-example/pom.xml

Lines changed: 184 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,25 @@
1919
<sonar.tests/>
2020
</properties>
2121

22+
<dependencyManagement>
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.wildfly.bom</groupId>
26+
<artifactId>wildfly-ee</artifactId>
27+
<version>${version.wildfly}</version>
28+
<scope>import</scope>
29+
<type>pom</type>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.jboss.arquillian</groupId>
33+
<artifactId>arquillian-bom</artifactId>
34+
<version>${version.arquillian}</version>
35+
<scope>import</scope>
36+
<type>pom</type>
37+
</dependency>
38+
</dependencies>
39+
</dependencyManagement>
2240
<dependencies>
23-
<dependency>
24-
<groupId>pro.taskana</groupId>
25-
<artifactId>taskana-common-logging</artifactId>
26-
<version>${project.version}</version>
27-
</dependency>
2841
<dependency>
2942
<groupId>jakarta.platform</groupId>
3043
<artifactId>jakarta.jakartaee-api</artifactId>
@@ -36,5 +49,171 @@
3649
<artifactId>taskana-cdi</artifactId>
3750
<version>${project.version}</version>
3851
</dependency>
52+
<!-- TEST dependencies -->
53+
<dependency>
54+
<groupId>org.slf4j</groupId>
55+
<artifactId>jcl-over-slf4j</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.slf4j</groupId>
60+
<artifactId>slf4j-simple</artifactId>
61+
<scope>test</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.assertj</groupId>
65+
<artifactId>assertj-core</artifactId>
66+
<version>${version.assertj}</version>
67+
<scope>test</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.awaitility</groupId>
71+
<artifactId>awaitility</artifactId>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.junit.jupiter</groupId>
76+
<artifactId>junit-jupiter</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.junit.vintage</groupId>
81+
<artifactId>junit-vintage-engine</artifactId>
82+
<scope>test</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>jakarta.servlet</groupId>
86+
<artifactId>jakarta.servlet-api</artifactId>
87+
<scope>test</scope>
88+
</dependency>
89+
<dependency>
90+
<groupId>com.h2database</groupId>
91+
<artifactId>h2</artifactId>
92+
<scope>test</scope>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.jboss.arquillian.junit</groupId>
96+
<artifactId>arquillian-junit-container</artifactId>
97+
<scope>test</scope>
98+
</dependency>
99+
<dependency>
100+
<groupId>org.jboss.shrinkwrap.resolver</groupId>
101+
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
102+
<scope>test</scope>
103+
</dependency>
104+
<dependency>
105+
<groupId>org.jboss.shrinkwrap.resolver</groupId>
106+
<artifactId>shrinkwrap-resolver-api-maven</artifactId>
107+
<scope>test</scope>
108+
</dependency>
109+
<dependency>
110+
<groupId>org.wildfly.arquillian</groupId>
111+
<artifactId>wildfly-arquillian-container-managed</artifactId>
112+
<version>${version.arquillian.managed.wildfly}</version>
113+
<scope>test</scope>
114+
</dependency>
39115
</dependencies>
116+
117+
<build>
118+
<plugins>
119+
<plugin>
120+
<groupId>org.apache.maven.plugins</groupId>
121+
<artifactId>maven-dependency-plugin</artifactId>
122+
<version>${version.maven.dependency}</version>
123+
<executions>
124+
<execution>
125+
<id>unpack-wildfly</id>
126+
<phase>process-test-classes</phase>
127+
<goals>
128+
<goal>unpack</goal>
129+
</goals>
130+
<configuration>
131+
<artifactItems>
132+
<artifactItem>
133+
<groupId>org.wildfly</groupId>
134+
<artifactId>wildfly-dist</artifactId>
135+
<version>${version.wildfly}</version>
136+
<type>zip</type>
137+
<overWrite>false</overWrite>
138+
<outputDirectory>${project.build.directory}</outputDirectory>
139+
</artifactItem>
140+
</artifactItems>
141+
</configuration>
142+
</execution>
143+
<execution>
144+
<id>copy-latest-h2-db-driver</id>
145+
<phase>process-test-classes</phase>
146+
<goals>
147+
<goal>copy</goal>
148+
</goals>
149+
<configuration>
150+
<artifactItems>
151+
<artifactItem>
152+
<groupId>com.h2database</groupId>
153+
<artifactId>h2</artifactId>
154+
<outputDirectory>
155+
${project.build.directory}/wildfly-${version.wildfly}/modules/system/layers/base/com/h2database/h2/main
156+
</outputDirectory>
157+
</artifactItem>
158+
</artifactItems>
159+
</configuration>
160+
</execution>
161+
</executions>
162+
</plugin>
163+
<plugin>
164+
<groupId>org.apache.maven.plugins</groupId>
165+
<artifactId>maven-resources-plugin</artifactId>
166+
<version>${version.maven.resources}</version>
167+
<executions>
168+
<execution>
169+
<id>copy-h2-module-xml</id>
170+
<phase>process-test-classes</phase>
171+
<goals>
172+
<goal>copy-resources</goal>
173+
</goals>
174+
<configuration>
175+
<outputDirectory>
176+
${project.build.directory}/wildfly-${version.wildfly}/modules/system/layers/base/com/h2database/h2/main
177+
</outputDirectory>
178+
<resources>
179+
<resource>
180+
<directory>src/test/resources</directory>
181+
<includes>
182+
<include>module.xml</include>
183+
</includes>
184+
</resource>
185+
</resources>
186+
</configuration>
187+
</execution>
188+
<execution>
189+
<id>copy-wildfly-config-xml</id>
190+
<phase>process-test-classes</phase>
191+
<goals>
192+
<goal>copy-resources</goal>
193+
</goals>
194+
<configuration>
195+
<outputDirectory>
196+
${project.build.directory}/wildfly-${version.wildfly}/standalone/configuration
197+
</outputDirectory>
198+
<resources>
199+
<resource>
200+
<directory>src/test/resources</directory>
201+
<includes>
202+
<include>int-test-standalone.xml</include>
203+
</includes>
204+
</resource>
205+
</resources>
206+
</configuration>
207+
</execution>
208+
</executions>
209+
</plugin>
210+
</plugins>
211+
</build>
212+
213+
<repositories>
214+
<repository>
215+
<id>jboss</id>
216+
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
217+
</repository>
218+
</repositories>
40219
</project>
Lines changed: 64 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,77 @@
11
package pro.taskana.example;
22

3-
import jakarta.annotation.PostConstruct;
4-
import jakarta.ejb.EJB;
53
import jakarta.enterprise.context.ApplicationScoped;
6-
import jakarta.enterprise.context.Initialized;
74
import jakarta.enterprise.event.Observes;
8-
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
9-
import pro.taskana.common.api.exceptions.InvalidArgumentException;
10-
import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
11-
import pro.taskana.task.api.exceptions.InvalidOwnerException;
12-
import pro.taskana.task.api.exceptions.InvalidTaskStateException;
13-
import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException;
14-
import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
15-
import pro.taskana.task.api.exceptions.TaskNotFoundException;
5+
import jakarta.enterprise.event.Startup;
6+
import jakarta.inject.Inject;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import pro.taskana.classification.api.models.Classification;
10+
import pro.taskana.common.api.exceptions.TaskanaException;
1611
import pro.taskana.task.api.models.Task;
1712
import pro.taskana.task.internal.models.ObjectReferenceImpl;
18-
import pro.taskana.workbasket.api.exceptions.NotAuthorizedOnWorkbasketException;
19-
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
13+
import pro.taskana.workbasket.api.WorkbasketType;
14+
import pro.taskana.workbasket.api.models.Workbasket;
2015

2116
/** Example Bootstrap Application. */
2217
@ApplicationScoped
2318
public class ExampleBootstrap {
2419

25-
@EJB private TaskanaEjb taskanaEjb;
26-
27-
@PostConstruct
28-
public void init(@Observes @Initialized(ApplicationScoped.class) Object init)
29-
throws TaskNotFoundException,
30-
WorkbasketNotFoundException,
31-
ClassificationNotFoundException,
32-
InvalidOwnerException,
33-
TaskAlreadyExistException,
34-
InvalidArgumentException,
35-
AttachmentPersistenceException,
36-
ObjectReferencePersistenceException,
37-
NotAuthorizedOnWorkbasketException,
38-
InvalidTaskStateException {
39-
System.out.println("---------------------------> Start App");
40-
ObjectReferenceImpl objRef = new ObjectReferenceImpl();
41-
objRef.setCompany("aCompany");
42-
objRef.setSystem("aSystem");
43-
objRef.setSystemInstance("anInstance");
44-
objRef.setType("aType");
45-
objRef.setValue("aValue");
46-
Task task = taskanaEjb.getTaskService().newTask(null);
47-
task.setPrimaryObjRef(objRef);
48-
task = taskanaEjb.getTaskService().createTask(task);
49-
System.out.println("---------------------------> Task started: " + task.getId());
50-
taskanaEjb.getTaskService().claim(task.getId());
51-
System.out.println(
52-
"---------------------------> Task claimed: "
53-
+ taskanaEjb.getTaskService().getTask(task.getId()).getOwner());
54-
taskanaEjb.getTaskService().completeTask(task.getId());
55-
System.out.println("---------------------------> Task completed");
20+
private static final Logger LOGGER = LoggerFactory.getLogger(ExampleBootstrap.class);
21+
22+
private static final String CDIDOMAIN = "CDIDOMAIN";
23+
private static final String CLASSIFICATION_TYPE = "T1";
24+
25+
private final TaskanaEjb taskanaEjb;
26+
27+
public ExampleBootstrap() {
28+
this.taskanaEjb = null;
29+
}
30+
31+
@Inject
32+
public ExampleBootstrap(TaskanaEjb taskanaEjb) {
33+
this.taskanaEjb = taskanaEjb;
34+
}
35+
36+
/**
37+
* The parameter `@Observes Startup` makes sure that the dependency injection framework calls this
38+
* method on system startup. And to do that, it needs to call `@PostConstruct start()` first.
39+
*
40+
* @param startup just the startup event
41+
* @throws ExampleStartupException in case of task creation fails
42+
*/
43+
public void init(@Observes Startup startup) throws ExampleStartupException {
44+
try {
45+
LOGGER.info("---------------------------> Start App -- {}", startup);
46+
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("KEY", CDIDOMAIN);
47+
workbasket.setName("wb");
48+
workbasket.setType(WorkbasketType.PERSONAL);
49+
workbasket = taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
50+
Classification classification =
51+
taskanaEjb
52+
.getClassificationService()
53+
.newClassification("TEST", CDIDOMAIN, CLASSIFICATION_TYPE);
54+
taskanaEjb.getClassificationService().createClassification(classification);
55+
ObjectReferenceImpl objRef = new ObjectReferenceImpl();
56+
objRef.setCompany("aCompany");
57+
objRef.setSystem("aSystem");
58+
objRef.setSystemInstance("anInstance");
59+
objRef.setType("aType");
60+
objRef.setValue("aValue");
61+
Task task = taskanaEjb.getTaskService().newTask(workbasket.getId());
62+
task.setClassificationKey(classification.getKey());
63+
task.setName("BootstrapTask");
64+
task.setPrimaryObjRef(objRef);
65+
task = taskanaEjb.getTaskService().createTask(task);
66+
LOGGER.info("---------------------------> Task started: {}", task.getId());
67+
taskanaEjb.getTaskService().claim(task.getId());
68+
LOGGER.info(
69+
"---------------------------> Task claimed: {}",
70+
taskanaEjb.getTaskService().getTask(task.getId()).getOwner());
71+
taskanaEjb.getTaskService().completeTask(task.getId());
72+
LOGGER.info("---------------------------> Task completed");
73+
} catch (TaskanaException e) {
74+
throw new ExampleStartupException(e);
75+
}
5676
}
5777
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package pro.taskana.example;
2+
3+
public class ExampleStartupException extends RuntimeException {
4+
5+
public ExampleStartupException(Throwable cause) {
6+
super("Can't bootstrap CDI example application", cause);
7+
}
8+
}

0 commit comments

Comments
 (0)