TSK-948: Fix or delete disabled tests

This commit is contained in:
Benjamin Eckstein 2020-01-08 12:10:28 +01:00 committed by BerndBreier
parent 6a6dcb9c1e
commit 57670b854e
7 changed files with 55 additions and 69 deletions

View File

@ -1,5 +1,6 @@
package acceptance;
import java.sql.Connection;
import java.sql.SQLException;
import java.time.Instant;
import java.time.LocalDate;
@ -99,6 +100,12 @@ public abstract class AbstractAccTest {
return attachment;
}
protected String getDatabaseProductId() throws SQLException {
try (Connection connection = taskanaEngineConfiguration.getDatasource().getConnection()) {
return connection.getMetaData().getDatabaseProductName();
}
}
protected TimeInterval todaysInterval() {
Instant begin =
LocalDateTime.of(LocalDate.now(), LocalTime.MIN).atZone(ZoneId.systemDefault()).toInstant();

View File

@ -4,14 +4,17 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.ClassificationService;
import pro.taskana.ClassificationSummary;
import pro.taskana.configuration.DB;
import pro.taskana.exceptions.TaskanaRuntimeException;
import pro.taskana.security.JaasExtension;
@ -144,9 +147,11 @@ class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
*/
@Disabled
@Test
void testPaginationThrowingExceptionWhenPageOutOfBounds() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
void testPaginationThrowingExceptionWhenPageOutOfBounds() throws SQLException {
Assumptions.assumeTrue(DB.isDb2(getDatabaseProductId()), "Only test with DB2");
ClassificationService classificationService = taskanaEngine.getClassificationService();
// entrypoint set outside result amount
int pageNumber = 5;
int pageSize = 10;
@ -157,7 +162,8 @@ class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
classificationService
.createClassificationQuery()
.domainIn("DOMAIN_A")
.listPage(pageNumber, pageSize));
.listPage(pageNumber, pageSize),
"Using DB2 should throw a unchecked RuntimeException for a offset which is out of bounds.");
}
@Test

View File

@ -4,10 +4,11 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -15,6 +16,7 @@ import pro.taskana.ObjectReference;
import pro.taskana.ObjectReferenceQuery;
import pro.taskana.TaskQuery;
import pro.taskana.TaskService;
import pro.taskana.configuration.DB;
import pro.taskana.exceptions.TaskanaRuntimeException;
import pro.taskana.security.JaasExtension;
@ -113,19 +115,18 @@ class QueryObjectreferencesWithPaginationAccTest extends AbstractAccTest {
assertThat(results.size(), equalTo(3));
}
/**
* Testcase only for DB2 users, because H2 doesn´t throw a Exception when the offset is set to
* high.<br>
* Using DB2 should throw a unchecked RuntimeException for a offset which is out of bounds.
*/
@Disabled
@Test
void testPaginationThrowingExceptionWhenPageOutOfBounds() {
void testPaginationThrowingExceptionWhenPageOutOfBounds() throws SQLException {
Assumptions.assumeTrue(DB.isDb2(getDatabaseProductId()), "Only test with DB2");
// entrypoint set outside result amount
int pageNumber = 6;
int pageSize = 10;
Assertions.assertThrows(
TaskanaRuntimeException.class, () -> objRefQuery.listPage(pageNumber, pageSize));
TaskanaRuntimeException.class,
() -> objRefQuery.listPage(pageNumber, pageSize),
"Using DB2 should throw a unchecked RuntimeException for a offset which is out of bounds.");
}
@Test

View File

@ -4,15 +4,17 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.KeyDomain;
import pro.taskana.TaskService;
import pro.taskana.TaskSummary;
import pro.taskana.configuration.DB;
import pro.taskana.exceptions.TaskanaRuntimeException;
import pro.taskana.security.JaasExtension;
import pro.taskana.security.WithAccessId;
@ -171,17 +173,13 @@ class QueryTasksWithPaginationAccTest extends AbstractAccTest {
assertThat(results.size(), equalTo(10));
}
/**
* Testcase only for DB2 users, because H2 doesn´t throw a Exception when the offset is set to
* high.<br>
* Using DB2 should throw a unchecked RuntimeException for a offset which is out of bounds.
*/
@Disabled
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
void testPaginationThrowingExceptionWhenPageOutOfBounds() {
void testPaginationThrowingExceptionWhenPageOutOfBounds() throws SQLException {
Assumptions.assumeTrue(DB.isDb2(getDatabaseProductId()), "Only test with DB2");
TaskService taskService = taskanaEngine.getTaskService();
// entrypoint set outside result amount
@ -194,7 +192,8 @@ class QueryTasksWithPaginationAccTest extends AbstractAccTest {
taskService
.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A"))
.listPage(pageNumber, pageSize));
.listPage(pageNumber, pageSize),
"Using DB2 should throw a unchecked RuntimeException for a offset which is out of bounds.");
}
@WithAccessId(

View File

@ -4,14 +4,16 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.configuration.DB;
import pro.taskana.exceptions.TaskanaRuntimeException;
import pro.taskana.security.JaasExtension;
import pro.taskana.security.WithAccessId;
@ -153,14 +155,10 @@ class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
assertThat(results.size(), equalTo(9));
}
/**
* Testcase only for DB2 users, because H2 doesn´t throw a Exception when the offset is set to
* high.<br>
* Using DB2 should throw a unchecked RuntimeException for a offset which is out of bounds.
*/
@Disabled
@Test
void testPaginationThrowingExceptionWhenPageOutOfBounds() {
void testPaginationThrowingExceptionWhenPageOutOfBounds() throws SQLException {
Assumptions.assumeTrue(DB.isDb2(getDatabaseProductId()), "Only test with DB2");
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
// entrypoint set outside result amount
@ -173,7 +171,8 @@ class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
workbasketService
.createWorkbasketQuery()
.domainIn("DOMAIN_A")
.listPage(pageNumber, pageSize));
.listPage(pageNumber, pageSize),
"Using DB2 should throw a unchecked RuntimeException for a offset which is out of bounds");
}
@WithAccessId(

View File

@ -5,7 +5,6 @@ import static org.hamcrest.core.IsEqual.equalTo;
import acceptance.AbstractAccTest;
import java.util.List;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -13,6 +12,7 @@ import pro.taskana.BaseQuery.SortDirection;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.security.JaasExtension;
import pro.taskana.security.WithAccessId;
/** Acceptance test for all "query classifications with pagination" scenarios. */
@ExtendWith(JaasExtension.class)
@ -21,41 +21,41 @@ class WorkbasketQueryWithOrderedPaginationAccTest extends AbstractAccTest {
private static SortDirection asc = SortDirection.ASCENDING;
private static SortDirection desc = SortDirection.DESCENDING;
WorkbasketQueryWithOrderedPaginationAccTest() {
super();
}
@Disabled
@Test
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
void testGetFirstPageOfTaskQueryWithOffset() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").orderByKey(asc).list(0, 5);
assertThat(results.size(), equalTo(5));
assertThat(results.get(0).getKey(), equalTo("GPK_KSC"));
assertThat(results.get(4).getKey(), equalTo("key2"));
assertThat(results.get(4).getKey(), equalTo("TEAMLEAD_2"));
results =
workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").orderByKey(desc).list(0, 5);
assertThat(results.size(), equalTo(5));
assertThat(results.get(0).getKey(), equalTo("USER_2_2"));
assertThat(results.get(4).getKey(), equalTo("TEAMLEAD_2"));
assertThat(results.get(4).getKey(), equalTo("TPK_VIP"));
}
@Disabled
@Test
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
void testGetSecondPageOfTaskQueryWithOffset() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results =
workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").orderByKey(asc).list(5, 5);
assertThat(results.size(), equalTo(5));
assertThat(results.get(0).getKey(), equalTo("key3"));
assertThat(results.get(4).getKey(), equalTo("USER_1_1"));
assertThat(results.get(0).getKey(), equalTo("TPK_VIP"));
assertThat(results.get(4).getKey(), equalTo("USER_2_2"));
results =
workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").orderByKey(desc).list(5, 5);
assertThat(results.size(), equalTo(5));
assertThat(results.get(0).getKey(), equalTo("TEAMLEAD_1"));
assertThat(results.get(4).getKey(), equalTo("key3"));
assertThat(results.get(0).getKey(), equalTo("TEAMLEAD_2"));
assertThat(results.get(4).getKey(), equalTo("GPK_KSC"));
}
}

View File

@ -18,7 +18,6 @@ import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
@ -153,31 +152,6 @@ class WorkbasketServiceImplTest {
taskanaEngineConfigurationMock);
}
// TODO Add stored-check. Not getWorkbasket() because permissions are not set with this action
// here.
@Disabled
@Test
void testCreateWorkbasket_NotCreated() {
WorkbasketImpl expectedWb = createTestWorkbasket(null, "Key-1");
when(workbasketMapperMock.findById(any())).thenThrow(WorkbasketNotFoundException.class);
Assertions.assertThrows(
WorkbasketNotFoundException.class, () -> workbasketServiceSpy.createWorkbasket(expectedWb));
verify(internalTaskanaEngineMock, times(1)).openConnection();
verify(workbasketMapperMock, times(1)).insert(expectedWb);
verify(workbasketMapperMock, times(1)).findById(expectedWb.getId());
verify(internalTaskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(
taskQueryMock,
taskServiceMock,
workbasketMapperMock,
workbasketAccessMapperMock,
distributionTargetMapperMock,
internalTaskanaEngineMock,
taskanaEngineConfigurationMock);
}
@Test
void testDeleteWorkbasketIsUsed() throws NotAuthorizedException, WorkbasketNotFoundException {
Workbasket wb = createTestWorkbasket("WBI:0", "wb-key");