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