TSK-1164: refactor code which is using assertJ's assertThatThrownBy and lambda expression with line breaks
This commit is contained in:
parent
f14c09c88e
commit
fc3f9e1868
|
@ -9,6 +9,7 @@ import java.sql.SQLException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
@ -120,13 +121,15 @@ public class TaskHistoryEventControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowsExceptionIfInvalidFilterIsUsed() {
|
public void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
server + port + "/api/v1/task-history-event?invalid=BPI:01",
|
server + port + "/api/v1/task-history-event?invalid=BPI:01",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
request,
|
request,
|
||||||
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)))
|
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("[invalid]")
|
.hasMessageContaining("[invalid]")
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
|
@ -137,13 +140,15 @@ public class TaskHistoryEventControllerIntTest {
|
||||||
public void testGetHistoryEventOfDate() {
|
public void testGetHistoryEventOfDate() {
|
||||||
String currentTime = LocalDateTime.now().toString();
|
String currentTime = LocalDateTime.now().toString();
|
||||||
final String finalCurrentTime = currentTime;
|
final String finalCurrentTime = currentTime;
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
server + port + "/api/v1/task-history-event?created=" + finalCurrentTime,
|
server + port + "/api/v1/task-history-event?created=" + finalCurrentTime,
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
request,
|
request,
|
||||||
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class)))
|
ParameterizedTypeReference.forType(TaskHistoryEventListResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining(currentTime)
|
.hasMessageContaining(currentTime)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
|
||||||
import acceptance.AbstractAccTest;
|
import acceptance.AbstractAccTest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
|
@ -59,9 +60,11 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
||||||
assertThat(taskComments).hasSize(2);
|
assertThat(taskComments).hasSize(2);
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() -> taskService.deleteTaskComment("TCI:000000000000000000000000000000000005"))
|
() -> {
|
||||||
.isInstanceOf(NotAuthorizedException.class);
|
taskService.deleteTaskComment("TCI:000000000000000000000000000000000005");
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall).isInstanceOf(NotAuthorizedException.class);
|
||||||
|
|
||||||
// make sure the task comment was not deleted
|
// make sure the task comment was not deleted
|
||||||
List<TaskComment> taskCommentsAfterDeletion =
|
List<TaskComment> taskCommentsAfterDeletion =
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
|
||||||
import acceptance.AbstractAccTest;
|
import acceptance.AbstractAccTest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
|
@ -58,9 +59,11 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() -> taskService.getTaskComments("TKI:000000000000000000000000000000000004"))
|
() -> {
|
||||||
.isInstanceOf(NotAuthorizedException.class);
|
taskService.getTaskComments("TKI:000000000000000000000000000000000004");
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall).isInstanceOf(NotAuthorizedException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
ServiceLevelPriorityAccTest() {
|
ServiceLevelPriorityAccTest() {
|
||||||
super();
|
super();
|
||||||
|
DaysToWorkingDaysConverter.setGermanPublicHolidaysEnabled(true);
|
||||||
taskService = taskanaEngine.getTaskService();
|
taskService = taskanaEngine.getTaskService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,9 +232,9 @@ public class ServiceLevelPriorityAccTest extends AbstractAccTest {
|
||||||
Instant dueBulk3 = taskService.getTask(tkId3).getDue();
|
Instant dueBulk3 = taskService.getTask(tkId3).getDue();
|
||||||
Instant dueBulk4 = taskService.getTask(tkId4).getDue();
|
Instant dueBulk4 = taskService.getTask(tkId4).getDue();
|
||||||
assertThat(dueBulk1).isEqualTo(getInstant("2020-05-14T07:00:00"));
|
assertThat(dueBulk1).isEqualTo(getInstant("2020-05-14T07:00:00"));
|
||||||
assertThat(dueBulk2).isEqualTo(getInstant("2020-05-21T07:00:00"));
|
assertThat(dueBulk2).isEqualTo(getInstant("2020-05-22T07:00:00"));
|
||||||
assertThat(dueBulk3).isEqualTo(getInstant("2020-05-14T07:00:00"));
|
assertThat(dueBulk3).isEqualTo(getInstant("2020-05-14T07:00:00"));
|
||||||
assertThat(dueBulk4).isEqualTo(getInstant("2020-05-21T07:00:00"));
|
assertThat(dueBulk4).isEqualTo(getInstant("2020-05-22T07:00:00"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
@ -211,10 +212,12 @@ class TaskanaTransactionIntTest {
|
||||||
new TaskCleanupJob(taskanaEngine, springTransactionProvider, null);
|
new TaskCleanupJob(taskanaEngine, springTransactionProvider, null);
|
||||||
taskCleanupJob.run();
|
taskCleanupJob.run();
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
workbasketService.deleteWorkbasket(
|
workbasketService.deleteWorkbasket(
|
||||||
workbasketService.getWorkbasket("key3", "DOMAIN_A").getId()))
|
workbasketService.getWorkbasket("key3", "DOMAIN_A").getId());
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(WorkbasketInUseException.class)
|
.isInstanceOf(WorkbasketInUseException.class)
|
||||||
.hasMessageContaining("contains 1 non-completed tasks");
|
.hasMessageContaining("contains 1 non-completed tasks");
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -79,12 +80,15 @@ class AccessIdControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testBadRequestWhenSearchForIsTooShort() {
|
void testBadRequestWhenSearchForIsTooShort() {
|
||||||
assertThatThrownBy(() ->
|
ThrowingCallable httpCall =
|
||||||
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=al",
|
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=al",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(List.class)))
|
ParameterizedTypeReference.forType(List.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("Minimum searchFor length =")
|
.hasMessageContaining("Minimum searchFor length =")
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
|
|
|
@ -3,6 +3,7 @@ package pro.taskana.rest;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
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 org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
|
@ -238,13 +239,15 @@ class ClassificationControllerIntTest {
|
||||||
+ "\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\","
|
+ "\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\","
|
||||||
+ "\"parentKey\":\"T2000\"}";
|
+ "\"parentKey\":\"T2000\"}";
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||||
ParameterizedTypeReference.forType(ClassificationResource.class)))
|
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||||
|
@ -258,13 +261,15 @@ class ClassificationControllerIntTest {
|
||||||
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\","
|
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\","
|
||||||
+ "\"name\":\"new classification\",\"type\":\"TASK\"}";
|
+ "\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||||
ParameterizedTypeReference.forType(ClassificationResource.class)))
|
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||||
|
@ -299,14 +304,15 @@ class ClassificationControllerIntTest {
|
||||||
assertThat(HttpStatus.NO_CONTENT).isEqualTo(response.getStatusCode());
|
assertThat(HttpStatus.NO_CONTENT).isEqualTo(response.getStatusCode());
|
||||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(
|
||||||
Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
|
Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
request,
|
request,
|
||||||
ParameterizedTypeReference.forType(ClassificationSummaryResource.class)))
|
ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
|
||||||
.isInstanceOf(HttpClientErrorException.class);
|
};
|
||||||
|
assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package pro.taskana.rest;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -28,13 +29,15 @@ class GeneralExceptionHandlingTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDeleteNonExisitingClassificationExceptionIsLogged() {
|
void testDeleteNonExisitingClassificationExceptionIsLogged() {
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"),
|
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"),
|
||||||
HttpMethod.DELETE,
|
HttpMethod.DELETE,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)))
|
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("non-existing-id");
|
.hasMessageContaining("non-existing-id");
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.net.URL;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -163,8 +164,8 @@ class TaskControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetAllTasksByWorkbasketIdWithInvalidPlannedParamsCombination() {
|
void testGetAllTasksByWorkbasketIdWithInvalidPlannedParamsCombination() {
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_TASKS)
|
restHelper.toUrl(Mapping.URL_TASKS)
|
||||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||||
|
@ -175,7 +176,9 @@ class TaskControllerIntTest {
|
||||||
+ "&sort-by=planned",
|
+ "&sort-by=planned",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class)))
|
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("400");
|
.hasMessageContaining("400");
|
||||||
}
|
}
|
||||||
|
@ -252,8 +255,8 @@ class TaskControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetAllTasksByWorkbasketIdWithInvalidDueParamsCombination() {
|
void testGetAllTasksByWorkbasketIdWithInvalidDueParamsCombination() {
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_TASKS)
|
restHelper.toUrl(Mapping.URL_TASKS)
|
||||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||||
|
@ -264,7 +267,9 @@ class TaskControllerIntTest {
|
||||||
+ "&sort-by=planned",
|
+ "&sort-by=planned",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class)))
|
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("400");
|
.hasMessageContaining("400");
|
||||||
}
|
}
|
||||||
|
@ -291,15 +296,15 @@ class TaskControllerIntTest {
|
||||||
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
|
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
|
||||||
HttpEntity<String> request = new HttpEntity<>(headers);
|
HttpEntity<String> request = new HttpEntity<>(headers);
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
ResponseEntity<TaskSummaryListResource> response =
|
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2",
|
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
request,
|
request,
|
||||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||||
})
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("400");
|
.hasMessageContaining("400");
|
||||||
}
|
}
|
||||||
|
@ -338,13 +343,15 @@ class TaskControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_TASKS) + "?invalid=VNR",
|
restHelper.toUrl(Mapping.URL_TASKS) + "?invalid=VNR",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class)))
|
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("[invalid]")
|
.hasMessageContaining("[invalid]")
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
|
@ -584,14 +591,15 @@ class TaskControllerIntTest {
|
||||||
taskResource.setPlanned(now.toString());
|
taskResource.setPlanned(now.toString());
|
||||||
taskResource.setDue(now.toString());
|
taskResource.setDue(now.toString());
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_TASKS),
|
restHelper.toUrl(Mapping.URL_TASKS),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
new HttpEntity<>(taskResource, restHelper.getHeaders()),
|
new HttpEntity<>(taskResource, restHelper.getHeaders()),
|
||||||
ParameterizedTypeReference.forType(TaskResource.class)))
|
ParameterizedTypeReference.forType(TaskResource.class));
|
||||||
.isInstanceOf(HttpClientErrorException.class);
|
};
|
||||||
|
assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -695,19 +703,19 @@ class TaskControllerIntTest {
|
||||||
assertThat(theTaskResource.getOwner()).isEqualTo(user_id_of_claimed_task);
|
assertThat(theTaskResource.getOwner()).isEqualTo(user_id_of_claimed_task);
|
||||||
|
|
||||||
// try to cancel claim
|
// try to cancel claim
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id),
|
restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id),
|
||||||
HttpMethod.DELETE,
|
HttpMethod.DELETE,
|
||||||
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
||||||
ParameterizedTypeReference.forType(TaskResource.class)))
|
ParameterizedTypeReference.forType(TaskResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.CONFLICT);
|
.isEqualTo(HttpStatus.CONFLICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdateTaskOwnerOfReadyTaskSucceeds() {
|
void testUpdateTaskOwnerOfReadyTaskSucceeds() {
|
||||||
// setup
|
// setup
|
||||||
|
@ -768,13 +776,15 @@ class TaskControllerIntTest {
|
||||||
final String anyUserName = "dummyuser";
|
final String anyUserName = "dummyuser";
|
||||||
theTaskResource.setOwner(anyUserName);
|
theTaskResource.setOwner(anyUserName);
|
||||||
|
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
taskUrlString,
|
taskUrlString,
|
||||||
HttpMethod.PUT,
|
HttpMethod.PUT,
|
||||||
new HttpEntity<>(theTaskResource, restHelper.getHeadersUser_1_2()),
|
new HttpEntity<>(theTaskResource, restHelper.getHeadersUser_1_2()),
|
||||||
ParameterizedTypeReference.forType(TaskResource.class)))
|
ParameterizedTypeReference.forType(TaskResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("409");
|
.hasMessageContaining("409");
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package pro.taskana.rest;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
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 org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
import org.junit.jupiter.api.MethodOrderer;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -59,14 +60,16 @@ class WorkbasketAccessItemControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS)
|
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS)
|
||||||
+ "?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1",
|
+ "?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class)))
|
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("[invalid]")
|
.hasMessageContaining("[invalid]")
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
|
@ -112,13 +115,15 @@ class WorkbasketAccessItemControllerIntTest {
|
||||||
@Test
|
@Test
|
||||||
void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() {
|
void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() {
|
||||||
String parameters = "?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
|
String parameters = "?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
|
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
|
||||||
HttpMethod.DELETE,
|
HttpMethod.DELETE,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(Void.class)))
|
ParameterizedTypeReference.forType(Void.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -90,12 +91,15 @@ class WorkbasketControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||||
assertThatThrownBy(() ->
|
ThrowingCallable httpCall =
|
||||||
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?invalid=PERSONAL",
|
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?invalid=PERSONAL",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class)))
|
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.hasMessageContaining("[invalid]")
|
.hasMessageContaining("[invalid]")
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
|
@ -125,13 +129,16 @@ class WorkbasketControllerIntTest {
|
||||||
workbasketResource.setOwner("Joerg");
|
workbasketResource.setOwner("Joerg");
|
||||||
workbasketResource.setModified(String.valueOf(Instant.now()));
|
workbasketResource.setModified(String.valueOf(Instant.now()));
|
||||||
|
|
||||||
assertThatThrownBy(() ->
|
ThrowingCallable httpCall =
|
||||||
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
|
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
|
||||||
HttpMethod.PUT,
|
HttpMethod.PUT,
|
||||||
new HttpEntity<>(
|
new HttpEntity<>(
|
||||||
mapper.writeValueAsString(workbasketResource), restHelper.getHeaders()),
|
mapper.writeValueAsString(workbasketResource), restHelper.getHeaders()),
|
||||||
ParameterizedTypeReference.forType(WorkbasketResource.class)))
|
ParameterizedTypeReference.forType(WorkbasketResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.CONFLICT);
|
.isEqualTo(HttpStatus.CONFLICT);
|
||||||
}
|
}
|
||||||
|
@ -141,12 +148,15 @@ class WorkbasketControllerIntTest {
|
||||||
|
|
||||||
String workbasketId = "WBI:100004857400039500000999999999999999";
|
String workbasketId = "WBI:100004857400039500000999999999999999";
|
||||||
|
|
||||||
assertThatThrownBy(() ->
|
ThrowingCallable httpCall =
|
||||||
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
|
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
new HttpEntity<String>(restHelper.getHeaders()),
|
new HttpEntity<String>(restHelper.getHeaders()),
|
||||||
ParameterizedTypeReference.forType(WorkbasketResource.class)))
|
ParameterizedTypeReference.forType(WorkbasketResource.class));
|
||||||
|
};
|
||||||
|
assertThatThrownBy(httpCall)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -211,11 +212,12 @@ class WorkbasketDefinitionControllerIntTest {
|
||||||
String w1String = workbasketToString(w);
|
String w1String = workbasketToString(w);
|
||||||
w.getWorkbasket().setKey("new Key for this WB");
|
w.getWorkbasket().setKey("new Key for this WB");
|
||||||
String w2String = workbasketToString(w);
|
String w2String = workbasketToString(w);
|
||||||
assertThatThrownBy(
|
ThrowingCallable httpCall =
|
||||||
() ->
|
() -> {
|
||||||
expectStatusWhenExecutingImportRequestOfWorkbaskets(
|
expectStatusWhenExecutingImportRequestOfWorkbaskets(
|
||||||
HttpStatus.CONFLICT, Arrays.asList(w1String, w2String)))
|
HttpStatus.CONFLICT, Arrays.asList(w1String, w2String));
|
||||||
.isInstanceOf(HttpClientErrorException.class);
|
};
|
||||||
|
assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeWorkbasketIdOrKey(
|
private void changeWorkbasketIdOrKey(
|
||||||
|
|
Loading…
Reference in New Issue