TSK-1743: Deleted some Tests and started grouping tests together
This commit is contained in:
parent
8047e97c15
commit
a73b80c59d
|
@ -4,13 +4,18 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static pro.taskana.common.api.BaseQuery.SortDirection.ASCENDING;
|
||||||
|
import static pro.taskana.common.api.BaseQuery.SortDirection.DESCENDING;
|
||||||
import static pro.taskana.task.api.TaskCustomField.CUSTOM_7;
|
import static pro.taskana.task.api.TaskCustomField.CUSTOM_7;
|
||||||
|
|
||||||
import acceptance.AbstractAccTest;
|
import acceptance.AbstractAccTest;
|
||||||
import acceptance.TaskTestMapper;
|
import acceptance.TaskTestMapper;
|
||||||
import acceptance.TaskanaEngineProxy;
|
import acceptance.TaskanaEngineProxy;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.apache.ibatis.session.Configuration;
|
import org.apache.ibatis.session.Configuration;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
@ -33,9 +38,12 @@ import pro.taskana.common.internal.util.Triplet;
|
||||||
import pro.taskana.common.test.security.JaasExtension;
|
import pro.taskana.common.test.security.JaasExtension;
|
||||||
import pro.taskana.common.test.security.WithAccessId;
|
import pro.taskana.common.test.security.WithAccessId;
|
||||||
import pro.taskana.task.api.TaskCustomField;
|
import pro.taskana.task.api.TaskCustomField;
|
||||||
|
import pro.taskana.task.api.TaskQueryColumnName;
|
||||||
|
import pro.taskana.task.api.TaskState;
|
||||||
import pro.taskana.task.api.models.Task;
|
import pro.taskana.task.api.models.Task;
|
||||||
import pro.taskana.task.api.models.TaskSummary;
|
import pro.taskana.task.api.models.TaskSummary;
|
||||||
import pro.taskana.task.internal.models.TaskImpl;
|
import pro.taskana.task.internal.models.TaskImpl;
|
||||||
|
import pro.taskana.user.api.exceptions.UserNotFoundException;
|
||||||
|
|
||||||
/** Acceptance test for all "query tasks with sorting" scenarios. */
|
/** Acceptance test for all "query tasks with sorting" scenarios. */
|
||||||
@ExtendWith(JaasExtension.class)
|
@ExtendWith(JaasExtension.class)
|
||||||
|
@ -119,7 +127,7 @@ class QueryTasksAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
@WithAccessId(user = "user-1-2")
|
@WithAccessId(user = "user-1-2")
|
||||||
@Test
|
@Test
|
||||||
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameNotLike() throws Exception {
|
void should_SetOwnerLongNameOfTask_When_FilteringWithOwnerLongNameNotLike() {
|
||||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||||
List<TaskSummary> tasks = taskService.createTaskQuery().ownerLongNameNotLike("%1-1%").list();
|
List<TaskSummary> tasks = taskService.createTaskQuery().ownerLongNameNotLike("%1-1%").list();
|
||||||
|
|
||||||
|
@ -175,7 +183,9 @@ class QueryTasksAccTest extends AbstractAccTest {
|
||||||
void should_ListValues_For_OwnerLongName() {
|
void should_ListValues_For_OwnerLongName() {
|
||||||
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
taskanaEngineConfiguration.setAddAdditionalUserInfo(false);
|
||||||
List<String> longNames =
|
List<String> longNames =
|
||||||
taskService.createTaskQuery().listValues(TaskQueryColumnName.OWNER_LONG_NAME, ASCENDING)
|
taskService
|
||||||
|
.createTaskQuery()
|
||||||
|
.listValues(TaskQueryColumnName.OWNER_LONG_NAME, ASCENDING)
|
||||||
.stream()
|
.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -185,11 +195,12 @@ class QueryTasksAccTest extends AbstractAccTest {
|
||||||
.containsExactly("Eifrig, Elena - (user-1-2)", "Mustermann, Max - (user-1-1)");
|
.containsExactly("Eifrig, Elena - (user-1-2)", "Mustermann, Max - (user-1-1)");
|
||||||
|
|
||||||
longNames =
|
longNames =
|
||||||
taskService.createTaskQuery().listValues(TaskQueryColumnName.OWNER_LONG_NAME, DESCENDING)
|
taskService
|
||||||
|
.createTaskQuery()
|
||||||
|
.listValues(TaskQueryColumnName.OWNER_LONG_NAME, DESCENDING)
|
||||||
.stream()
|
.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
;
|
|
||||||
assertThat(longNames)
|
assertThat(longNames)
|
||||||
.hasSize(2)
|
.hasSize(2)
|
||||||
.contains("Mustermann, Max - (user-1-1)", "Eifrig, Elena - (user-1-2)")
|
.contains("Mustermann, Max - (user-1-1)", "Eifrig, Elena - (user-1-2)")
|
||||||
|
@ -231,7 +242,7 @@ class QueryTasksAccTest extends AbstractAccTest {
|
||||||
void should_SplitTaskListIntoChunksOf32000_When_AugmentingTasksAfterTaskQuery() {
|
void should_SplitTaskListIntoChunksOf32000_When_AugmentingTasksAfterTaskQuery() {
|
||||||
try (MockedStatic<CollectionUtil> listUtilMock =
|
try (MockedStatic<CollectionUtil> listUtilMock =
|
||||||
Mockito.mockStatic(CollectionUtil.class, new CallsRealMethods())) {
|
Mockito.mockStatic(CollectionUtil.class, new CallsRealMethods())) {
|
||||||
TASK_SERVICE.createTaskQuery().list();
|
taskService.createTaskQuery().list();
|
||||||
|
|
||||||
listUtilMock.verify(() -> CollectionUtil.partitionBasedOnSize(any(), eq(32000)));
|
listUtilMock.verify(() -> CollectionUtil.partitionBasedOnSize(any(), eq(32000)));
|
||||||
}
|
}
|
||||||
|
@ -275,14 +286,14 @@ class QueryTasksAccTest extends AbstractAccTest {
|
||||||
TaskCustomField customField, String[] searchArguments, int expectedResult)
|
TaskCustomField customField, String[] searchArguments, int expectedResult)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
List<TaskSummary> results =
|
List<TaskSummary> results =
|
||||||
TASK_SERVICE.createTaskQuery().customAttributeLike(customField, searchArguments).list();
|
taskService.createTaskQuery().customAttributeLike(customField, searchArguments).list();
|
||||||
assertThat(results).hasSize(expectedResult);
|
assertThat(results).hasSize(expectedResult);
|
||||||
|
|
||||||
String[] customAttributes =
|
String[] customAttributes =
|
||||||
results.stream().map(t -> t.getCustomAttribute(customField)).toArray(String[]::new);
|
results.stream().map(t -> t.getCustomAttribute(customField)).toArray(String[]::new);
|
||||||
|
|
||||||
List<TaskSummary> result2 =
|
List<TaskSummary> result2 =
|
||||||
TASK_SERVICE.createTaskQuery().customAttributeIn(customField, customAttributes).list();
|
taskService.createTaskQuery().customAttributeIn(customField, customAttributes).list();
|
||||||
assertThat(result2).hasSize(expectedResult);
|
assertThat(result2).hasSize(expectedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,14 +330,14 @@ class QueryTasksAccTest extends AbstractAccTest {
|
||||||
void testQueryForCustomXNotIn(
|
void testQueryForCustomXNotIn(
|
||||||
TaskCustomField customField, String[] searchArguments, int expectedCount) throws Exception {
|
TaskCustomField customField, String[] searchArguments, int expectedCount) throws Exception {
|
||||||
long results =
|
long results =
|
||||||
TASK_SERVICE.createTaskQuery().customAttributeNotIn(customField, searchArguments).count();
|
taskService.createTaskQuery().customAttributeNotIn(customField, searchArguments).count();
|
||||||
assertThat(results).isEqualTo(expectedCount);
|
assertThat(results).isEqualTo(expectedCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(user = "admin")
|
@WithAccessId(user = "admin")
|
||||||
@Test
|
@Test
|
||||||
void testQueryForCustom7WithExceptionInLike() {
|
void testQueryForCustom7WithExceptionInLike() {
|
||||||
assertThatThrownBy(() -> TASK_SERVICE.createTaskQuery().customAttributeLike(CUSTOM_7).list())
|
assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeLike(CUSTOM_7).list())
|
||||||
.isInstanceOf(InvalidArgumentException.class);
|
.isInstanceOf(InvalidArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,10 +345,10 @@ class QueryTasksAccTest extends AbstractAccTest {
|
||||||
@Test
|
@Test
|
||||||
void testQueryForCustom7WithExceptionInIn() throws Exception {
|
void testQueryForCustom7WithExceptionInIn() throws Exception {
|
||||||
List<TaskSummary> results =
|
List<TaskSummary> results =
|
||||||
TASK_SERVICE.createTaskQuery().customAttributeLike(CUSTOM_7, "fsdhfshk%").list();
|
taskService.createTaskQuery().customAttributeLike(CUSTOM_7, "fsdhfshk%").list();
|
||||||
assertThat(results).isEmpty();
|
assertThat(results).isEmpty();
|
||||||
|
|
||||||
assertThatThrownBy(() -> TASK_SERVICE.createTaskQuery().customAttributeIn(CUSTOM_7).list())
|
assertThatThrownBy(() -> taskService.createTaskQuery().customAttributeIn(CUSTOM_7).list())
|
||||||
.isInstanceOf(InvalidArgumentException.class);
|
.isInstanceOf(InvalidArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,28 +356,28 @@ class QueryTasksAccTest extends AbstractAccTest {
|
||||||
@Test
|
@Test
|
||||||
void testQueryForCustom7WithException() throws Exception {
|
void testQueryForCustom7WithException() throws Exception {
|
||||||
List<TaskSummary> results =
|
List<TaskSummary> results =
|
||||||
TASK_SERVICE.createTaskQuery().customAttributeLike(CUSTOM_7, "%").list();
|
taskService.createTaskQuery().customAttributeLike(CUSTOM_7, "%").list();
|
||||||
assertThat(results).hasSize(2);
|
assertThat(results).hasSize(2);
|
||||||
|
|
||||||
String[] ids =
|
String[] ids =
|
||||||
results.stream().map(t -> t.getCustomAttribute(CUSTOM_7)).toArray(String[]::new);
|
results.stream().map(t -> t.getCustomAttribute(CUSTOM_7)).toArray(String[]::new);
|
||||||
|
|
||||||
List<TaskSummary> result2 =
|
List<TaskSummary> result2 =
|
||||||
TASK_SERVICE.createTaskQuery().customAttributeIn(CUSTOM_7, ids).list();
|
taskService.createTaskQuery().customAttributeIn(CUSTOM_7, ids).list();
|
||||||
assertThat(result2).hasSize(2);
|
assertThat(result2).hasSize(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(user = "admin")
|
@WithAccessId(user = "admin")
|
||||||
@Test
|
@Test
|
||||||
void testQueryTaskByCustomAttributes() throws Exception {
|
void testQueryTaskByCustomAttributes() throws Exception {
|
||||||
Task newTask = TASK_SERVICE.newTask("USER-1-1", "DOMAIN_A");
|
Task newTask = taskService.newTask("USER-1-1", "DOMAIN_A");
|
||||||
newTask.setPrimaryObjRef(
|
newTask.setPrimaryObjRef(
|
||||||
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||||
newTask.setClassificationKey("T2100");
|
newTask.setClassificationKey("T2100");
|
||||||
Map<String, String> customAttributesForCreate =
|
Map<String, String> customAttributesForCreate =
|
||||||
createSimpleCustomPropertyMap(20000); // about 1 Meg
|
createSimpleCustomPropertyMap(20000); // about 1 Meg
|
||||||
newTask.setCustomAttributeMap(customAttributesForCreate);
|
newTask.setCustomAttributeMap(customAttributesForCreate);
|
||||||
Task createdTask = TASK_SERVICE.createTask(newTask);
|
Task createdTask = taskService.createTask(newTask);
|
||||||
|
|
||||||
assertThat(createdTask).isNotNull();
|
assertThat(createdTask).isNotNull();
|
||||||
// query the task by custom attributes
|
// query the task by custom attributes
|
||||||
|
|
|
@ -30,7 +30,7 @@ class QueryTasksByWildcardSearchAccTest extends AbstractAccTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
List<TaskSummary> foundTasks =
|
List<TaskSummary> foundTasks =
|
||||||
TASK_SERVICE
|
taskService
|
||||||
.createTaskQuery()
|
.createTaskQuery()
|
||||||
.wildcardSearchFieldsIn(wildcards)
|
.wildcardSearchFieldsIn(wildcards)
|
||||||
.wildcardSearchValueLike("%99%")
|
.wildcardSearchValueLike("%99%")
|
||||||
|
@ -48,7 +48,7 @@ class QueryTasksByWildcardSearchAccTest extends AbstractAccTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
long foundTasks =
|
long foundTasks =
|
||||||
TASK_SERVICE
|
taskService
|
||||||
.createTaskQuery()
|
.createTaskQuery()
|
||||||
.wildcardSearchFieldsIn(wildcards)
|
.wildcardSearchFieldsIn(wildcards)
|
||||||
.wildcardSearchValueLike("%99%")
|
.wildcardSearchValueLike("%99%")
|
||||||
|
@ -66,7 +66,7 @@ class QueryTasksByWildcardSearchAccTest extends AbstractAccTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
List<TaskSummary> foundTasks =
|
List<TaskSummary> foundTasks =
|
||||||
TASK_SERVICE
|
taskService
|
||||||
.createTaskQuery()
|
.createTaskQuery()
|
||||||
.wildcardSearchFieldsIn(wildcards)
|
.wildcardSearchFieldsIn(wildcards)
|
||||||
.wildcardSearchValueLike("%99%")
|
.wildcardSearchValueLike("%99%")
|
||||||
|
@ -84,14 +84,14 @@ class QueryTasksByWildcardSearchAccTest extends AbstractAccTest {
|
||||||
WildcardSearchField[] wildcards = {WildcardSearchField.NAME};
|
WildcardSearchField[] wildcards = {WildcardSearchField.NAME};
|
||||||
|
|
||||||
List<TaskSummary> foundTasksCaseSensitive =
|
List<TaskSummary> foundTasksCaseSensitive =
|
||||||
TASK_SERVICE
|
taskService
|
||||||
.createTaskQuery()
|
.createTaskQuery()
|
||||||
.wildcardSearchFieldsIn(wildcards)
|
.wildcardSearchFieldsIn(wildcards)
|
||||||
.wildcardSearchValueLike("%Wid%")
|
.wildcardSearchValueLike("%Wid%")
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
List<TaskSummary> foundTasksCaseInsensitive =
|
List<TaskSummary> foundTasksCaseInsensitive =
|
||||||
TASK_SERVICE
|
taskService
|
||||||
.createTaskQuery()
|
.createTaskQuery()
|
||||||
.wildcardSearchFieldsIn(wildcards)
|
.wildcardSearchFieldsIn(wildcards)
|
||||||
.wildcardSearchValueLike("%wid%")
|
.wildcardSearchValueLike("%wid%")
|
||||||
|
@ -107,7 +107,7 @@ class QueryTasksByWildcardSearchAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
ThrowingCallable queryAttempt =
|
ThrowingCallable queryAttempt =
|
||||||
() ->
|
() ->
|
||||||
TASK_SERVICE
|
taskService
|
||||||
.createTaskQuery()
|
.createTaskQuery()
|
||||||
.wildcardSearchValueLike("%99%")
|
.wildcardSearchValueLike("%99%")
|
||||||
.orderByName(SortDirection.ASCENDING)
|
.orderByName(SortDirection.ASCENDING)
|
||||||
|
@ -117,7 +117,7 @@ class QueryTasksByWildcardSearchAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
queryAttempt =
|
queryAttempt =
|
||||||
() ->
|
() ->
|
||||||
TASK_SERVICE
|
taskService
|
||||||
.createTaskQuery()
|
.createTaskQuery()
|
||||||
.wildcardSearchFieldsIn(
|
.wildcardSearchFieldsIn(
|
||||||
WildcardSearchField.CUSTOM_1, WildcardSearchField.DESCRIPTION)
|
WildcardSearchField.CUSTOM_1, WildcardSearchField.DESCRIPTION)
|
||||||
|
|
Loading…
Reference in New Issue