TSK-1147 Replaced getRestTemplate() by constant TEMPLATE
TSK-1147 Usage of AssertJ ListAsserts TSK-1147 Usage of AssertJ ListAssert TSK-1147 Removed doesNotContain
This commit is contained in:
parent
bb31dc84dd
commit
ebd2098434
|
@ -52,7 +52,7 @@ class AsyncUpdateJobIntTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -69,7 +69,7 @@ public class RestHelper {
|
|||
*
|
||||
* @return RestTemplate
|
||||
*/
|
||||
public static RestTemplate getRestTemplate() {
|
||||
private static RestTemplate getRestTemplate() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
|
|
|
@ -28,7 +28,7 @@ class AccessIdControllerIntTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -30,7 +30,7 @@ import pro.taskana.rest.resource.ClassificationSummaryResource;
|
|||
@TaskanaSpringBootTest
|
||||
class ClassificationControllerIntTest {
|
||||
|
||||
static RestTemplate template = RestHelper.getRestTemplate();
|
||||
static RestTemplate template = RestHelper.TEMPLATE;
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.File;
|
||||
|
@ -46,7 +46,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -378,12 +378,10 @@ class ClassificationDefinitionControllerIntTest {
|
|||
clList.add(classificationString);
|
||||
clList.add(classificationString);
|
||||
|
||||
try {
|
||||
importRequest(clList);
|
||||
fail("Expected http-Status 409");
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.CONFLICT);
|
||||
}
|
||||
assertThatThrownBy(() -> importRequest(clList))
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
private ClassificationResource createClassification(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -22,21 +23,19 @@ class GeneralExceptionHandlingTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteNonExisitingClassificationExceptionIsLogged() {
|
||||
|
||||
HttpClientErrorException ex =
|
||||
Assertions.assertThrows(
|
||||
HttpClientErrorException.class,
|
||||
() ->
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"),
|
||||
HttpMethod.DELETE,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)));
|
||||
Assertions.assertTrue(ex.getResponseBodyAsString().contains("non-existing-id"));
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"),
|
||||
HttpMethod.DELETE,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)))
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("non-existing-id");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
@ -17,7 +17,7 @@ class MappingTest {
|
|||
String mapUrl = Mapping.URL_TASKS;
|
||||
String buildUrl =
|
||||
linkTo(methodOn(TaskController.class).getTasks(new LinkedMultiValueMap<>())).toString();
|
||||
Assertions.assertEquals(mapUrl, buildUrl);
|
||||
assertThat(buildUrl).isEqualTo(mapUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -28,6 +28,6 @@ class MappingTest {
|
|||
String mapUrl =
|
||||
UriComponentsBuilder.fromPath(Mapping.URL_TASKS_ID).buildAndExpand(id).toUriString();
|
||||
String buildUrl = linkTo(methodOn(TaskController.class).getTask(id)).toString();
|
||||
Assertions.assertEquals(mapUrl, buildUrl);
|
||||
assertThat(buildUrl).isEqualTo(mapUrl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.net.URL;
|
|||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.sql.DataSource;
|
||||
import org.assertj.core.api.Fail;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -59,7 +58,7 @@ class TaskControllerIntTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
void resetDb() {
|
||||
|
@ -339,17 +338,17 @@ class TaskControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||
try {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?invalid=VNR",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
Fail.fail("");
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
assertThat(e.getResponseBodyAsString().contains("[invalid]")).isTrue();
|
||||
}
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?invalid=VNR",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class)))
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
@ -27,7 +25,7 @@ class TaskanaEngineControllerIntTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -38,7 +36,7 @@ class TaskanaEngineControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
assertTrue(response.getBody().contains("DOMAIN_A"));
|
||||
assertThat(response.getBody()).contains("DOMAIN_A");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -49,9 +47,7 @@ class TaskanaEngineControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
assertTrue(response.getBody().contains("TASK"));
|
||||
assertTrue(response.getBody().contains("DOCUMENT"));
|
||||
assertFalse(response.getBody().contains("UNKNOWN"));
|
||||
assertThat(response.getBody()).containsOnly("TASK", "DOCUMENT");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -62,11 +58,7 @@ class TaskanaEngineControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
assertTrue(response.getBody().contains("MANUAL"));
|
||||
assertTrue(response.getBody().contains("EXTERNAL"));
|
||||
assertTrue(response.getBody().contains("AUTOMATIC"));
|
||||
assertTrue(response.getBody().contains("PROCESS"));
|
||||
assertFalse(response.getBody().contains("UNKNOWN"));
|
||||
assertThat(response.getBody()).containsOnly("MANUAL", "EXTERNAL", "AUTOMATIC", "PROCESS");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -77,9 +69,9 @@ class TaskanaEngineControllerIntTest {
|
|||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskanaUserInfoResource.class));
|
||||
assertEquals("teamlead_1", response.getBody().getUserId());
|
||||
assertTrue(response.getBody().getGroupIds().contains("businessadmin"));
|
||||
assertTrue(response.getBody().getRoles().contains(TaskanaRole.BUSINESS_ADMIN));
|
||||
assertFalse(response.getBody().getRoles().contains(TaskanaRole.ADMIN));
|
||||
assertThat(response.getBody().getUserId()).isEqualTo("teamlead_1");
|
||||
assertThat(response.getBody().getGroupIds()).contains("businessadmin");
|
||||
assertThat(response.getBody().getRoles()).contains(TaskanaRole.BUSINESS_ADMIN);
|
||||
assertThat(response.getBody().getRoles()).doesNotContain(TaskanaRole.ADMIN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -7,7 +9,6 @@ import java.sql.SQLException;
|
|||
import java.util.Locale;
|
||||
import javax.sql.DataSource;
|
||||
import org.junit.Assume;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
@ -57,7 +58,7 @@ class TestSchemaNameCustomizable {
|
|||
String tableName = rs.getString("tablename");
|
||||
tablefound = tableName.equals("workbasket");
|
||||
}
|
||||
Assertions.assertTrue(tablefound, "Table workbasket should be there ...");
|
||||
assertThat(tablefound).as("Table workbasket should be there ...").isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +79,7 @@ class TestSchemaNameCustomizable {
|
|||
String tableName = rs.getString("TABLE_NAME");
|
||||
tablefound = tableName.equals("WORKBASKET");
|
||||
}
|
||||
Assertions.assertTrue(tablefound, "Table WORKBASKET should be there ...");
|
||||
assertThat(tablefound).as("Table WORKBASKET should be there ...").isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package pro.taskana.rest;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
|
@ -31,7 +30,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,18 +59,18 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||
try {
|
||||
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));
|
||||
fail("Invalid filter is used");
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
assertThat(e.getResponseBodyAsString().contains("[invalid]")).isTrue();
|
||||
}
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
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)))
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -2,11 +2,9 @@ package pro.taskana.rest;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.time.Instant;
|
||||
import java.util.Iterator;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -38,7 +36,7 @@ class WorkbasketControllerIntTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -92,17 +90,17 @@ class WorkbasketControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||
try {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?invalid=PERSONAL",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
fail();
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
assertThat(e.getResponseBodyAsString().contains("[invalid]")).isTrue();
|
||||
}
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?invalid=PERSONAL",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class)))
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -214,11 +212,11 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(DistributionTargetListResource.class));
|
||||
assertThat(response2.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Iterator<DistributionTargetResource> iterator = response2.getBody().getContent().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
assertThat(iterator.next().getWorkbasketId())
|
||||
.isNotEqualTo("WBI:100000000000000000000000000000000007");
|
||||
}
|
||||
assertThat(
|
||||
response2.getBody().getContent().stream()
|
||||
.map(DistributionTargetResource::getWorkbasketId)
|
||||
.noneMatch(id -> (id.equals("WBI:100000000000000000000000000000000007"))))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -235,7 +233,7 @@ class WorkbasketControllerIntTest {
|
|||
.isEqualTo(MediaTypes.HAL_JSON_UTF8_VALUE);
|
||||
assertThat(response.getBody().getContent()).hasSize(3);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testGetWorkbasketDistributionTargets() {
|
||||
ResponseEntity<DistributionTargetListResource> response =
|
||||
|
|
|
@ -57,7 +57,7 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
template = RestHelper.getRestTemplate();
|
||||
template = RestHelper.TEMPLATE;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
|
Loading…
Reference in New Issue