fixed new sonarqube code smells and bugs
This commit is contained in:
parent
969d3eeff6
commit
b3add569ff
|
@ -77,7 +77,8 @@ public class TaskHistoryEventResourceAssemblerTest {
|
||||||
.isEqualTo(taskHistoryEventResource.getWorkbasketKey());
|
.isEqualTo(taskHistoryEventResource.getWorkbasketKey());
|
||||||
assertThat(historyEvent.getAttachmentClassificationKey())
|
assertThat(historyEvent.getAttachmentClassificationKey())
|
||||||
.isEqualTo(taskHistoryEventResource.getAttachmentClassificationKey());
|
.isEqualTo(taskHistoryEventResource.getAttachmentClassificationKey());
|
||||||
assertThat(historyEvent.getCreated()).isEqualTo(taskHistoryEventResource.getCreated());
|
assertThat(historyEvent.getCreated())
|
||||||
|
.isEqualTo(Instant.parse(taskHistoryEventResource.getCreated()));
|
||||||
assertThat(historyEvent.getOldValue()).isEqualTo(taskHistoryEventResource.getOldValue());
|
assertThat(historyEvent.getOldValue()).isEqualTo(taskHistoryEventResource.getOldValue());
|
||||||
assertThat(historyEvent.getNewValue()).isEqualTo(taskHistoryEventResource.getNewValue());
|
assertThat(historyEvent.getNewValue()).isEqualTo(taskHistoryEventResource.getNewValue());
|
||||||
assertThat(historyEvent.getPorCompany()).isEqualTo(taskHistoryEventResource.getPorCompany());
|
assertThat(historyEvent.getPorCompany()).isEqualTo(taskHistoryEventResource.getPorCompany());
|
||||||
|
|
|
@ -152,10 +152,7 @@ class UpdateClassificationAccTest extends AbstractAccTest {
|
||||||
classification.setName("NOW IT´S MY TURN");
|
classification.setName("NOW IT´S MY TURN");
|
||||||
classification.setDescription("IT SHOULD BE TO LATE...");
|
classification.setDescription("IT SHOULD BE TO LATE...");
|
||||||
ThrowingCallable call = () -> classificationService.updateClassification(classification);
|
ThrowingCallable call = () -> classificationService.updateClassification(classification);
|
||||||
assertThatThrownBy(call)
|
assertThatThrownBy(call).isInstanceOf(ConcurrencyException.class);
|
||||||
.isInstanceOf(ConcurrencyException.class)
|
|
||||||
.describedAs(
|
|
||||||
"The Classification should not be updated, because it was modified while editing.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(user = "businessadmin")
|
@WithAccessId(user = "businessadmin")
|
||||||
|
|
|
@ -5,7 +5,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import acceptance.AbstractAccTest;
|
import acceptance.AbstractAccTest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -24,14 +23,8 @@ import pro.taskana.workbasket.internal.jobs.WorkbasketCleanupJob;
|
||||||
@ExtendWith(JaasExtension.class)
|
@ExtendWith(JaasExtension.class)
|
||||||
class WorkbasketCleanupJobAccTest extends AbstractAccTest {
|
class WorkbasketCleanupJobAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
WorkbasketService workbasketService;
|
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||||
TaskService taskService;
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void before() {
|
|
||||||
workbasketService = taskanaEngine.getWorkbasketService();
|
|
||||||
taskService = taskanaEngine.getTaskService();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void after() throws Exception {
|
void after() throws Exception {
|
||||||
|
@ -50,8 +43,8 @@ class WorkbasketCleanupJobAccTest extends AbstractAccTest {
|
||||||
.orderByKey(BaseQuery.SortDirection.ASCENDING)
|
.orderByKey(BaseQuery.SortDirection.ASCENDING)
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
assertThat(0).isEqualTo(getNumberTaskNotCompleted(workbaskets.get(0).getId()));
|
assertThat(getNumberTaskNotCompleted(workbaskets.get(0).getId())).isZero();
|
||||||
assertThat(1).isEqualTo(getNumberTaskCompleted(workbaskets.get(0).getId()));
|
assertThat(getNumberTaskCompleted(workbaskets.get(0).getId())).isOne();
|
||||||
|
|
||||||
// Workbasket with completed task will be marked for deletion.
|
// Workbasket with completed task will be marked for deletion.
|
||||||
workbasketService.deleteWorkbasket(workbaskets.get(0).getId());
|
workbasketService.deleteWorkbasket(workbaskets.get(0).getId());
|
||||||
|
@ -60,7 +53,7 @@ class WorkbasketCleanupJobAccTest extends AbstractAccTest {
|
||||||
TaskCleanupJob taskCleanupJob = new TaskCleanupJob(taskanaEngine, null, null);
|
TaskCleanupJob taskCleanupJob = new TaskCleanupJob(taskanaEngine, null, null);
|
||||||
taskCleanupJob.run();
|
taskCleanupJob.run();
|
||||||
|
|
||||||
assertThat(0).isEqualTo(getNumberTaskCompleted(workbaskets.get(0).getId()));
|
assertThat(getNumberTaskCompleted(workbaskets.get(0).getId())).isZero();
|
||||||
|
|
||||||
WorkbasketCleanupJob workbasketCleanupJob = new WorkbasketCleanupJob(taskanaEngine, null, null);
|
WorkbasketCleanupJob workbasketCleanupJob = new WorkbasketCleanupJob(taskanaEngine, null, null);
|
||||||
workbasketCleanupJob.run();
|
workbasketCleanupJob.run();
|
||||||
|
@ -81,7 +74,7 @@ class WorkbasketCleanupJobAccTest extends AbstractAccTest {
|
||||||
.orderByKey(BaseQuery.SortDirection.ASCENDING)
|
.orderByKey(BaseQuery.SortDirection.ASCENDING)
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
assertThat(0).isNotEqualTo(getNumberTaskCompleted(workbaskets.get(0).getId()));
|
assertThat(getNumberTaskCompleted(workbaskets.get(0).getId())).isPositive();
|
||||||
|
|
||||||
// Workbasket with completed task will be marked for deletion.
|
// Workbasket with completed task will be marked for deletion.
|
||||||
workbasketService.deleteWorkbasket(workbaskets.get(0).getId());
|
workbasketService.deleteWorkbasket(workbaskets.get(0).getId());
|
||||||
|
|
|
@ -217,8 +217,9 @@ class CompleteTaskAccTest extends AbstractAccTest {
|
||||||
Task taskAfterClaim = TASK_SERVICE.forceClaim(createdTask.getId());
|
Task taskAfterClaim = TASK_SERVICE.forceClaim(createdTask.getId());
|
||||||
|
|
||||||
assertThat(taskAfterClaim.getOwner()).isEqualTo(CurrentUserContext.getUserid());
|
assertThat(taskAfterClaim.getOwner()).isEqualTo(CurrentUserContext.getUserid());
|
||||||
assertThat(beforeForceClaim).isBeforeOrEqualTo(taskAfterClaim.getModified());
|
assertThat(beforeForceClaim)
|
||||||
assertThat(beforeForceClaim).isBeforeOrEqualTo(taskAfterClaim.getClaimed());
|
.isBeforeOrEqualTo(taskAfterClaim.getModified())
|
||||||
|
.isBeforeOrEqualTo(taskAfterClaim.getClaimed());
|
||||||
assertThat(taskAfterClaim.getCreated()).isBeforeOrEqualTo(taskAfterClaim.getModified());
|
assertThat(taskAfterClaim.getCreated()).isBeforeOrEqualTo(taskAfterClaim.getModified());
|
||||||
|
|
||||||
assertThat(taskAfterClaim.getState()).isEqualTo(TaskState.CLAIMED);
|
assertThat(taskAfterClaim.getState()).isEqualTo(TaskState.CLAIMED);
|
||||||
|
|
|
@ -40,12 +40,10 @@ class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
columnValueList =
|
columnValueList =
|
||||||
workbasketService.createWorkbasketAccessItemQuery().listValues(ACCESS_ID, null);
|
workbasketService.createWorkbasketAccessItemQuery().listValues(ACCESS_ID, null);
|
||||||
assertThat(columnValueList).isNotNull();
|
|
||||||
assertThat(columnValueList).hasSize(10);
|
assertThat(columnValueList).hasSize(10);
|
||||||
|
|
||||||
columnValueList =
|
columnValueList =
|
||||||
workbasketService.createWorkbasketAccessItemQuery().listValues(WORKBASKET_KEY, null);
|
workbasketService.createWorkbasketAccessItemQuery().listValues(WORKBASKET_KEY, null);
|
||||||
assertThat(columnValueList).isNotNull();
|
|
||||||
assertThat(columnValueList).hasSize(24);
|
assertThat(columnValueList).hasSize(24);
|
||||||
|
|
||||||
long countEntries = workbasketService.createWorkbasketAccessItemQuery().count();
|
long countEntries = workbasketService.createWorkbasketAccessItemQuery().count();
|
||||||
|
|
|
@ -49,9 +49,9 @@ class ClassificationControllerIntTest {
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||||
|
assertThat(response.getBody()).isNotNull();
|
||||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||||
assertThat(response.getHeaders().getContentType().toString())
|
assertThat(response.getHeaders().getContentType()).isEqualTo(MediaTypes.HAL_JSON);
|
||||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -62,6 +62,7 @@ class ClassificationControllerIntTest {
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||||
|
assertThat(response.getBody()).isNotNull();
|
||||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +74,8 @@ class ClassificationControllerIntTest {
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||||
|
|
||||||
|
assertThat(response.getBody()).isNotNull();
|
||||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||||
assertThat(response.getBody().getContent()).hasSize(13);
|
assertThat(response.getBody().getContent()).hasSize(13);
|
||||||
}
|
}
|
||||||
|
@ -86,14 +89,10 @@ class ClassificationControllerIntTest {
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||||
|
assertThat(response.getBody()).isNotNull();
|
||||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||||
assertThat(
|
assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF).getHref())
|
||||||
response
|
.endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc");
|
||||||
.getBody()
|
|
||||||
.getRequiredLink(IanaLinkRelations.SELF)
|
|
||||||
.getHref()
|
|
||||||
.endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc"))
|
|
||||||
.isTrue();
|
|
||||||
assertThat(response.getBody().getContent()).hasSize(17);
|
assertThat(response.getBody().getContent()).hasSize(17);
|
||||||
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("A12");
|
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("A12");
|
||||||
}
|
}
|
||||||
|
@ -107,6 +106,7 @@ class ClassificationControllerIntTest {
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||||
|
assertThat(response.getBody()).isNotNull();
|
||||||
assertThat(response.getBody().getContent()).hasSize(5);
|
assertThat(response.getBody().getContent()).hasSize(5);
|
||||||
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050");
|
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050");
|
||||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||||
|
@ -219,6 +219,8 @@ class ClassificationControllerIntTest {
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||||
|
|
||||||
|
assertThat(response.getBody()).isNotNull();
|
||||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||||
boolean foundClassificationCreated = false;
|
boolean foundClassificationCreated = false;
|
||||||
for (ClassificationSummaryRepresentationModel classification :
|
for (ClassificationSummaryRepresentationModel classification :
|
||||||
|
@ -290,6 +292,7 @@ class ClassificationControllerIntTest {
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
request,
|
request,
|
||||||
ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
|
ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
|
||||||
|
assertThat(response.getBody()).isNotNull();
|
||||||
assertThat(response.getBody().getName()).isEqualTo("Zustimmungserklärung");
|
assertThat(response.getBody().getName()).isEqualTo("Zustimmungserklärung");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@ package pro.taskana.common.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 static pro.taskana.common.rest.RestHelper.TEMPLATE;
|
||||||
|
|
||||||
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.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
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;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
|
@ -15,7 +15,6 @@ import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import pro.taskana.common.rest.models.AccessIdRepresentationModel;
|
import pro.taskana.common.rest.models.AccessIdRepresentationModel;
|
||||||
|
|
||||||
|
@ -23,55 +22,55 @@ import pro.taskana.common.rest.models.AccessIdRepresentationModel;
|
||||||
@ActiveProfiles({"test"})
|
@ActiveProfiles({"test"})
|
||||||
class AccessIdControllerIntTest {
|
class AccessIdControllerIntTest {
|
||||||
|
|
||||||
private static RestTemplate template;
|
private final RestHelper restHelper;
|
||||||
|
|
||||||
@Autowired RestHelper restHelper;
|
@Autowired
|
||||||
|
AccessIdControllerIntTest(RestHelper restHelper) {
|
||||||
@BeforeAll
|
this.restHelper = restHelper;
|
||||||
static void init() {
|
|
||||||
template = RestHelper.TEMPLATE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testQueryGroupsByDn() {
|
void testQueryGroupsByDn() {
|
||||||
ResponseEntity<AccessIdListResource> response =
|
ResponseEntity<AccessIdListResource> response =
|
||||||
template.exchange(
|
TEMPLATE.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_ACCESSID)
|
restHelper.toUrl(Mapping.URL_ACCESSID)
|
||||||
+ "?search-for=cn=ksc-users,cn=groups,OU=Test,O=TASKANA",
|
+ "?search-for=cn=ksc-users,cn=groups,OU=Test,O=TASKANA",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
||||||
assertThat(response.getBody()).hasSize(1);
|
assertThat(response.getBody())
|
||||||
assertThat(response.getBody().get(0).getAccessId())
|
.isNotNull()
|
||||||
.isEqualToIgnoringCase("cn=ksc-users,cn=groups,OU=Test,O=TASKANA");
|
.extracting(AccessIdRepresentationModel::getAccessId)
|
||||||
|
.usingElementComparator(String.CASE_INSENSITIVE_ORDER)
|
||||||
|
.containsExactly("cn=ksc-users,cn=groups,OU=Test,O=TASKANA");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testQueryGroupsByCn() {
|
void testQueryGroupsByCn() {
|
||||||
ResponseEntity<AccessIdListResource> response =
|
ResponseEntity<AccessIdListResource> response =
|
||||||
template.exchange(
|
TEMPLATE.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=ksc-use",
|
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=ksc-use",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
||||||
assertThat(response.getBody()).hasSize(1);
|
assertThat(response.getBody())
|
||||||
assertThat(response.getBody().get(0).getAccessId())
|
.isNotNull()
|
||||||
.isEqualToIgnoringCase("cn=ksc-users,cn=groups,OU=Test,O=TASKANA");
|
.extracting(AccessIdRepresentationModel::getAccessId)
|
||||||
|
.usingElementComparator(String.CASE_INSENSITIVE_ORDER)
|
||||||
|
.containsExactly("cn=ksc-users,cn=groups,OU=Test,O=TASKANA");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetMatches() {
|
void testGetMatches() {
|
||||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||||
template.exchange(
|
TEMPLATE.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=rig",
|
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=rig",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
||||||
|
|
||||||
List<AccessIdRepresentationModel> body = response.getBody();
|
assertThat(response.getBody())
|
||||||
assertThat(body).isNotNull();
|
.isNotNull()
|
||||||
assertThat(body).hasSize(2);
|
|
||||||
assertThat(body)
|
|
||||||
.extracting(AccessIdRepresentationModel::getName)
|
.extracting(AccessIdRepresentationModel::getName)
|
||||||
.containsExactlyInAnyOrder("Schläfrig, Tim", "Eifrig, Elena");
|
.containsExactlyInAnyOrder("Schläfrig, Tim", "Eifrig, Elena");
|
||||||
}
|
}
|
||||||
|
@ -79,16 +78,14 @@ class AccessIdControllerIntTest {
|
||||||
@Test
|
@Test
|
||||||
void should_returnAccessIdWithUmlauten_ifBased64EncodedUserIsLookedUp() {
|
void should_returnAccessIdWithUmlauten_ifBased64EncodedUserIsLookedUp() {
|
||||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||||
template.exchange(
|
TEMPLATE.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=läf",
|
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=läf",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
||||||
|
|
||||||
List<AccessIdRepresentationModel> body = response.getBody();
|
assertThat(response.getBody())
|
||||||
assertThat(body).isNotNull();
|
.isNotNull()
|
||||||
assertThat(body).hasSize(1);
|
|
||||||
assertThat(body)
|
|
||||||
.extracting(AccessIdRepresentationModel::getName)
|
.extracting(AccessIdRepresentationModel::getName)
|
||||||
.containsExactlyInAnyOrder("Schläfrig, Tim");
|
.containsExactlyInAnyOrder("Schläfrig, Tim");
|
||||||
}
|
}
|
||||||
|
@ -97,7 +94,7 @@ class AccessIdControllerIntTest {
|
||||||
void testBadRequestWhenSearchForIsTooShort() {
|
void testBadRequestWhenSearchForIsTooShort() {
|
||||||
ThrowingCallable httpCall =
|
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(),
|
||||||
|
|
|
@ -31,7 +31,12 @@ public class RestHelper {
|
||||||
|
|
||||||
public static final RestTemplate TEMPLATE = getRestTemplate();
|
public static final RestTemplate TEMPLATE = getRestTemplate();
|
||||||
|
|
||||||
@Autowired Environment environment;
|
private final Environment environment;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public RestHelper(Environment environment) {
|
||||||
|
this.environment = environment;
|
||||||
|
}
|
||||||
|
|
||||||
public String toUrl(String relativeUrl, Object... uriVariables) {
|
public String toUrl(String relativeUrl, Object... uriVariables) {
|
||||||
return UriComponentsBuilder.fromPath(relativeUrl)
|
return UriComponentsBuilder.fromPath(relativeUrl)
|
||||||
|
|
Loading…
Reference in New Issue