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