diff --git a/history/taskana-simplehistory-provider/pom.xml b/history/taskana-simplehistory-provider/pom.xml
index 9ce5efd850..c90e7e6eca 100644
--- a/history/taskana-simplehistory-provider/pom.xml
+++ b/history/taskana-simplehistory-provider/pom.xml
@@ -64,21 +64,9 @@
test
- org.junit.vintage
- junit-vintage-engine
- ${version.junit.jupiter}
- test
-
-
- org.powermock
- powermock-api-mockito2
- ${version.powermock}
- test
-
-
- org.powermock
- powermock-module-junit4
- ${version.powermock}
+ org.mockito
+ mockito-junit-jupiter
+ ${version.junit.mockito}
test
@@ -93,5 +81,5 @@
${version.h2}
test
-
+
diff --git a/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImpl.java b/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImpl.java
index 85bb87f16b..1a07f5f625 100644
--- a/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImpl.java
+++ b/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImpl.java
@@ -23,8 +23,7 @@ public class SimpleHistoryServiceImpl implements TaskanaHistory {
@Override
public void initialize(TaskanaEngineConfiguration taskanaEngineConfiguration) {
try {
- this.taskanaHistoryEngine =
- TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration);
+ this.taskanaHistoryEngine = getTaskanaEngine(taskanaEngineConfiguration);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Simple history service implementation initialized with schemaName: {} ",
@@ -59,4 +58,12 @@ public void create(TaskanaHistoryEvent event) {
public HistoryQuery createHistoryQuery() {
return new HistoryQueryImpl(taskanaHistoryEngine, historyQueryMapper);
}
+
+ /*
+ * ATTENTION: This method exists for testing purposes.
+ */
+ TaskanaHistoryEngineImpl getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
+ throws SQLException {
+ return TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration);
+ }
}
diff --git a/history/taskana-simplehistory-provider/src/test/java/acceptance/AbstractAccTest.java b/history/taskana-simplehistory-provider/src/test/java/acceptance/AbstractAccTest.java
index 9cea78141e..5452ad99bc 100644
--- a/history/taskana-simplehistory-provider/src/test/java/acceptance/AbstractAccTest.java
+++ b/history/taskana-simplehistory-provider/src/test/java/acceptance/AbstractAccTest.java
@@ -11,7 +11,7 @@
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,7 +45,7 @@ protected AbstractAccTest() {
// not called
}
- @BeforeClass
+ @BeforeAll
public static void setupTest() throws Exception {
resetDb(null);
}
diff --git a/history/taskana-simplehistory-provider/src/test/java/acceptance/query/QueryHistoryAccTest.java b/history/taskana-simplehistory-provider/src/test/java/acceptance/query/QueryHistoryAccTest.java
index a6a3974ee5..43196951b3 100644
--- a/history/taskana-simplehistory-provider/src/test/java/acceptance/query/QueryHistoryAccTest.java
+++ b/history/taskana-simplehistory-provider/src/test/java/acceptance/query/QueryHistoryAccTest.java
@@ -1,20 +1,19 @@
package acceptance.query;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
import acceptance.AbstractAccTest;
import java.time.Instant;
+import java.util.Collections;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import pro.taskana.common.api.BaseQuery.SortDirection;
import pro.taskana.common.api.TimeInterval;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.query.HistoryQuery;
import pro.taskana.simplehistory.query.HistoryQueryColumnName;
+import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
/** Test for History queries. */
public class QueryHistoryAccTest extends AbstractAccTest {
@@ -31,14 +30,17 @@ public void testListValuesAscendingAndDescending() {
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.COMMENT, SortDirection.ASCENDING);
+
+ assertThat(ascendingList).hasSize(3);
+ assertThat(ascendingList).isEqualTo(defaultList);
+
List descendingList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.COMMENT, SortDirection.DESCENDING);
+ Collections.reverse(ascendingList);
- assertEquals(3, ascendingList.size());
- assertArrayEquals(defaultList.toArray(), ascendingList.toArray());
- assertEquals(ascendingList.get(2), descendingList.get(0));
+ assertThat(ascendingList).isEqualTo(descendingList);
}
@Test
@@ -51,15 +53,14 @@ public void testComplexQuery() {
.orderByCreated(SortDirection.DESCENDING);
List results = query.list();
- assertEquals(2, results.size());
- assertEquals("admin", results.get(0).getUserId());
- assertEquals("peter", results.get(1).getUserId());
-
+ assertThat(results)
+ .extracting(TaskanaHistoryEvent::getUserId)
+ .containsExactly("admin", "peter");
results = query.orderByUserId(SortDirection.DESCENDING).list();
- assertEquals(2, results.size());
- assertEquals("admin", results.get(0).getUserId());
- assertEquals("peter", results.get(1).getUserId());
- assertEquals(3, query.domainLike().count());
+ assertThat(results)
+ .extracting(TaskanaHistoryEvent::getUserId)
+ .containsExactly("admin", "peter");
+ assertThat(query.domainLike().count()).isEqualTo(3);
}
@Test
@@ -67,300 +68,299 @@ public void testQueryListOffset() {
List result = getHistoryService().createHistoryQuery().list(1, 2);
List wrongList = getHistoryService().createHistoryQuery().list();
- assertEquals(2, result.size());
-
- assertNotEquals(wrongList.get(0).getUserId(), result.get(0).getUserId());
- assertEquals(wrongList.get(1).getUserId(), result.get(0).getUserId());
+ assertThat(result).hasSize(2);
+ assertThat(result.get(0).getUserId()).isNotEqualTo(wrongList.get(0).getUserId());
+ assertThat(result.get(0).getUserId()).isEqualTo(wrongList.get(1).getUserId());
}
@Test
public void testCorrectResultWithWrongConstraints() {
List result = getHistoryService().createHistoryQuery().list(1, 1000);
- assertEquals(2, result.size());
- assertEquals("created by Peter", result.get(0).getComment());
+ assertThat(result).hasSize(2);
+ assertThat(result.get(0).getComment()).isEqualTo("created by Peter");
result = getHistoryService().createHistoryQuery().list(100, 1000);
- assertTrue(result.isEmpty());
+ assertThat(result).isEmpty();
}
@Test
public void testSingle() {
HistoryEventImpl single = getHistoryService().createHistoryQuery().userIdIn("peter").single();
- assertEquals("CREATE", single.getEventType());
+ assertThat(single.getEventType()).isEqualTo("CREATE");
single = getHistoryService().createHistoryQuery().eventTypeIn("CREATE", "xy").single();
- assertEquals("admin", single.getUserId());
+ assertThat(single.getUserId()).isEqualTo("admin");
}
@Test
public void testCount() {
long count = getHistoryService().createHistoryQuery().userIdIn("peter").count();
- assertEquals(1, count);
+ assertThat(count).isOne();
count = getHistoryService().createHistoryQuery().count();
- assertEquals(3, count);
+ assertThat(count).isEqualTo(3);
count = getHistoryService().createHistoryQuery().userIdIn("klaus", "arnold", "benni").count();
- assertEquals(0, count);
+ assertThat(count).isZero();
}
@Test
public void testQueryAttributesIn() {
List returnValues =
getHistoryService().createHistoryQuery().businessProcessIdIn("BPI:01", "BPI:02").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues =
getHistoryService().createHistoryQuery().parentBusinessProcessIdIn("BPI:01").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues =
getHistoryService()
.createHistoryQuery()
.taskIdIn("TKI:000000000000000000000000000000000000")
.list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().eventTypeIn("CREATE").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
TimeInterval timeInterval = new TimeInterval(Instant.now().minusSeconds(10), Instant.now());
returnValues = getHistoryService().createHistoryQuery().createdWithin(timeInterval).list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().userIdIn("admin").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().domainIn("DOMAIN_A").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues =
getHistoryService()
.createHistoryQuery()
.workbasketKeyIn("WBI:100000000000000000000000000000000001")
.list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().porCompanyIn("00").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().porSystemIn("PASystem").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().porInstanceIn("22").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().porTypeIn("VN").list();
- assertEquals(0, returnValues.size());
+ assertThat(returnValues).isEmpty();
returnValues = getHistoryService().createHistoryQuery().porValueIn("11223344").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues =
getHistoryService().createHistoryQuery().taskClassificationKeyIn("L140101").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues =
getHistoryService().createHistoryQuery().taskClassificationCategoryIn("TASK").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues =
getHistoryService()
.createHistoryQuery()
.attachmentClassificationKeyIn("DOCTYPE_DEFAULT")
.list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().custom1In("custom1").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
returnValues = getHistoryService().createHistoryQuery().custom2In("custom2").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().custom3In("custom3").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().custom4In("custom4").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().commentIn("created a bug").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().oldValueIn("old_val").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().newValueIn("new_val").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().oldDataIn("123").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().newDataIn("456").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
returnValues = getHistoryService().createHistoryQuery().oldValueLike("old%").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().newValueLike("new_%").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().oldDataLike("%23%").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
returnValues = getHistoryService().createHistoryQuery().newDataLike("456%").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
}
@Test
public void testSomeLikeMethods() {
List returnValues =
getHistoryService().createHistoryQuery().businessProcessIdLike("BPI:0%").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
returnValues =
getHistoryService().createHistoryQuery().parentBusinessProcessIdLike("BPI:01", " %").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues =
getHistoryService().createHistoryQuery().taskIdLike("TKI:000000000000000%").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
returnValues = getHistoryService().createHistoryQuery().oldValueLike("old%").list();
- assertEquals(1, returnValues.size());
+ assertThat(returnValues).hasSize(1);
returnValues = getHistoryService().createHistoryQuery().newValueLike("new_%").list();
- assertEquals(2, returnValues.size());
+ assertThat(returnValues).hasSize(2);
returnValues = getHistoryService().createHistoryQuery().oldDataLike("%23%").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
returnValues = getHistoryService().createHistoryQuery().newDataLike("456%").list();
- assertEquals(3, returnValues.size());
+ assertThat(returnValues).hasSize(3);
}
@Test
public void testListValues() {
List returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.ID, null);
- assertEquals(3, returnedList.size());
+ assertThat(returnedList).hasSize(3);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.BUSINESS_PROCESS_ID, null);
- assertEquals(3, returnedList.size());
+ assertThat(returnedList).hasSize(3);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.PARENT_BUSINESS_PROCESS_ID, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.TASK_ID, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.EVENT_TYPE, null);
- assertEquals(1, returnedList.size());
+ assertThat(returnedList).hasSize(1);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.CREATED, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.USER_ID, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.DOMAIN, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.WORKBASKET_KEY, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.POR_COMPANY, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.POR_SYSTEM, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.POR_INSTANCE, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.POR_TYPE, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.POR_VALUE, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.TASK_CLASSIFICATION_KEY, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.TASK_CLASSIFICATION_CATEGORY, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService()
.createHistoryQuery()
.listValues(HistoryQueryColumnName.ATTACHMENT_CLASSIFICATION_KEY, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.COMMENT, null);
- assertEquals(3, returnedList.size());
+ assertThat(returnedList).hasSize(3);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.OLD_VALUE, null);
- assertEquals(3, returnedList.size());
+ assertThat(returnedList).hasSize(3);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.NEW_VALUE, null);
- assertEquals(3, returnedList.size());
+ assertThat(returnedList).hasSize(3);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_1, null);
- assertEquals(1, returnedList.size());
+ assertThat(returnedList).hasSize(1);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_2, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_3, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_4, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.OLD_DATA, null);
- assertEquals(2, returnedList.size());
+ assertThat(returnedList).hasSize(2);
returnedList =
getHistoryService().createHistoryQuery().listValues(HistoryQueryColumnName.NEW_DATA, null);
- assertEquals(1, returnedList.size());
+ assertThat(returnedList).hasSize(1);
}
}
diff --git a/history/taskana-simplehistory-provider/src/test/java/configuration/TaskanaEngineConfigurationTest.java b/history/taskana-simplehistory-provider/src/test/java/configuration/TaskanaEngineConfigurationTest.java
index 24dc7374a0..ed43ecce8f 100644
--- a/history/taskana-simplehistory-provider/src/test/java/configuration/TaskanaEngineConfigurationTest.java
+++ b/history/taskana-simplehistory-provider/src/test/java/configuration/TaskanaEngineConfigurationTest.java
@@ -1,12 +1,11 @@
package configuration;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import javax.sql.DataSource;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import pro.taskana.TaskanaEngineConfiguration;
import pro.taskana.common.api.TaskanaEngine;
@@ -26,19 +25,19 @@ public void testCreateTaskanaEngine() throws SQLException {
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
- Assert.assertNotNull(te);
+ assertThat(te).isNotNull();
}
@Test
public void testCreateTaskanaHistoryEventWithNonDefaultSchemaName() throws SQLException {
resetDb("SOMECUSTOMSCHEMANAME");
long count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
- assertEquals(0, count);
+ assertThat(count).isZero();
getHistoryService()
.create(
AbstractAccTest.createHistoryEvent(
"wbKey1", "taskId1", "type1", "Some comment", "wbKey2","someUserId"));
count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
- assertEquals(1, count);
+ assertThat(count).isOne();
}
}
diff --git a/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/HistoryQueryImplTest.java b/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/HistoryQueryImplTest.java
index c02f7f5923..6d26dd8eb5 100644
--- a/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/HistoryQueryImplTest.java
+++ b/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/HistoryQueryImplTest.java
@@ -1,6 +1,6 @@
package pro.taskana.simplehistory.impl;
-import static org.junit.Assert.assertArrayEquals;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.validateMockitoUsage;
@@ -9,11 +9,11 @@
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import pro.taskana.common.api.TimeInterval;
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
@@ -23,7 +23,7 @@
*
* @author BV
*/
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class HistoryQueryImplTest {
private HistoryQueryImpl historyQueryImpl;
@@ -32,7 +32,7 @@ public class HistoryQueryImplTest {
@Mock private HistoryQueryMapper historyQueryMock;
- @Before
+ @BeforeEach
public void setup() {
historyQueryImpl = new HistoryQueryImpl(taskanaHistoryEngineMock, historyQueryMock);
}
@@ -58,7 +58,7 @@ public void testShouldReturnList() throws SQLException {
.list();
validateMockitoUsage();
- assertArrayEquals(returnList.toArray(), result.toArray());
+ assertThat(result).isEqualTo(returnList);
}
private HistoryEventImpl createHistoryEvent(
diff --git a/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImplTest.java b/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImplTest.java
index 86812221c2..667aed2bc7 100644
--- a/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImplTest.java
+++ b/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImplTest.java
@@ -1,45 +1,33 @@
package pro.taskana.simplehistory.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.session.SqlSessionManager;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.Spy;
+import org.mockito.junit.jupiter.MockitoExtension;
import pro.taskana.TaskanaEngineConfiguration;
import pro.taskana.simplehistory.impl.mappings.HistoryEventMapper;
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
-/**
- * Unit Test for SimpleHistoryServiceImplTest.
- *
- * @author MMR
- */
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(TaskanaHistoryEngineImpl.class)
-@PowerMockIgnore("javax.management.*")
+/** Unit Test for SimpleHistoryServiceImplTest. */
+@ExtendWith(MockitoExtension.class)
public class SimpleHistoryServiceImplTest {
- @InjectMocks private SimpleHistoryServiceImpl cutSpy;
+ @InjectMocks @Spy private SimpleHistoryServiceImpl cutSpy;
@Mock private HistoryEventMapper historyEventMapperMock;
@@ -51,42 +39,14 @@ public class SimpleHistoryServiceImplTest {
@Mock private SqlSessionManager sqlSessionManagerMock;
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- }
-
@Test
public void testInitializeSimpleHistoryService() throws SQLException {
- doReturn(historyEventMapperMock)
- .when(sqlSessionManagerMock)
- .getMapper(HistoryEventMapper.class);
- doReturn(historyQueryMapperMock)
- .when(sqlSessionManagerMock)
- .getMapper(HistoryQueryMapper.class);
- doReturn(sqlSessionManagerMock).when(taskanaHistoryEngineMock).getSqlSession();
- PowerMockito.mockStatic(TaskanaHistoryEngineImpl.class);
- Mockito.when(TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration))
- .thenReturn(taskanaHistoryEngineMock);
- cutSpy.initialize(taskanaEngineConfiguration);
-
- verify(sqlSessionManagerMock, times(2)).getMapper(any());
- verify(taskanaHistoryEngineMock, times(2)).getSqlSession();
- }
-
- @Test
- public void testInitializeSimpleHistoryServiceWithNonDefaultSchemaName() throws SQLException {
-
- doReturn(historyEventMapperMock)
- .when(sqlSessionManagerMock)
- .getMapper(HistoryEventMapper.class);
- doReturn(historyQueryMapperMock)
- .when(sqlSessionManagerMock)
- .getMapper(HistoryQueryMapper.class);
- doReturn(sqlSessionManagerMock).when(taskanaHistoryEngineMock).getSqlSession();
- PowerMockito.mockStatic(TaskanaHistoryEngineImpl.class);
- Mockito.when(TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration))
- .thenReturn(taskanaHistoryEngineMock);
+ when(sqlSessionManagerMock.getMapper(HistoryEventMapper.class))
+ .thenReturn(historyEventMapperMock);
+ when(sqlSessionManagerMock.getMapper(HistoryQueryMapper.class))
+ .thenReturn(historyQueryMapperMock);
+ when(taskanaHistoryEngineMock.getSqlSession()).thenReturn(sqlSessionManagerMock);
+ doReturn(taskanaHistoryEngineMock).when(cutSpy).getTaskanaEngine(taskanaEngineConfiguration);
cutSpy.initialize(taskanaEngineConfiguration);
verify(sqlSessionManagerMock, times(2)).getMapper(any());
@@ -98,13 +58,12 @@ public void testCreateEvent() throws SQLException {
HistoryEventImpl expectedWb =
AbstractAccTest.createHistoryEvent(
"wbKey1", "taskId1", "type1", "Some comment", "wbKey2", "someUserId");
- doNothing().when(historyEventMapperMock).insert(expectedWb);
cutSpy.create(expectedWb);
verify(taskanaHistoryEngineMock, times(1)).openConnection();
verify(historyEventMapperMock, times(1)).insert(expectedWb);
verify(taskanaHistoryEngineMock, times(1)).returnConnection();
- assertNotNull(expectedWb.getCreated());
+ assertThat(expectedWb.getCreated()).isNotNull();
}
@Test
@@ -113,14 +72,14 @@ public void testQueryEvent() throws SQLException {
returnList.add(
AbstractAccTest.createHistoryEvent(
"wbKey1", "taskId1", "type1", "Some comment", "wbKey2", "someUserId"));
- doReturn(returnList).when(historyQueryMapperMock).queryHistoryEvent(any());
+ when(historyQueryMapperMock.queryHistoryEvent(any())).thenReturn(returnList);
final List result = cutSpy.createHistoryQuery().taskIdIn("taskId1").list();
verify(taskanaHistoryEngineMock, times(1)).openConnection();
verify(historyQueryMapperMock, times(1)).queryHistoryEvent(any());
verify(taskanaHistoryEngineMock, times(1)).returnConnection();
- assertEquals(returnList.size(), result.size());
- assertEquals(returnList.get(0).getWorkbasketKey(), result.get(0).getWorkbasketKey());
+ assertThat(result).hasSize(returnList.size());
+ assertThat(result.get(0).getWorkbasketKey()).isEqualTo(returnList.get(0).getWorkbasketKey());
}
}
diff --git a/pom.xml b/pom.xml
index 3f0bc3c676..b4efaee631 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,7 +82,6 @@
spring mock tests see LdapClientTest -->
1.10.8
1.10.8
- 2.0.5
2.2
3.1.12
0.8.13