TSK-1442: Used ParameterizedTypeReference properly for list of AccessIds
This commit is contained in:
parent
85573e9ce7
commit
00be5e4b5f
|
@ -4,7 +4,6 @@ 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.test.rest.RestHelper.TEMPLATE;
|
import static pro.taskana.common.test.rest.RestHelper.TEMPLATE;
|
||||||
|
|
||||||
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.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -14,7 +13,6 @@ import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
import pro.taskana.common.rest.models.AccessIdRepresentationModel;
|
import pro.taskana.common.rest.models.AccessIdRepresentationModel;
|
||||||
|
@ -22,9 +20,11 @@ import pro.taskana.common.test.rest.RestHelper;
|
||||||
import pro.taskana.common.test.rest.TaskanaSpringBootTest;
|
import pro.taskana.common.test.rest.TaskanaSpringBootTest;
|
||||||
|
|
||||||
@TaskanaSpringBootTest
|
@TaskanaSpringBootTest
|
||||||
@ActiveProfiles({"test"})
|
|
||||||
class AccessIdControllerIntTest {
|
class AccessIdControllerIntTest {
|
||||||
|
|
||||||
|
private static final ParameterizedTypeReference<List<AccessIdRepresentationModel>>
|
||||||
|
ACCESS_ID_LIST_TYPE = new ParameterizedTypeReference<List<AccessIdRepresentationModel>>() {};
|
||||||
|
|
||||||
private final RestHelper restHelper;
|
private final RestHelper restHelper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -34,13 +34,13 @@ class AccessIdControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testQueryGroupsByDn() {
|
void testQueryGroupsByDn() {
|
||||||
ResponseEntity<AccessIdListResource> response =
|
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||||
TEMPLATE.exchange(
|
TEMPLATE.exchange(
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID)
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID)
|
||||||
+ "?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));
|
ACCESS_ID_LIST_TYPE);
|
||||||
assertThat(response.getBody())
|
assertThat(response.getBody())
|
||||||
.isNotNull()
|
.isNotNull()
|
||||||
.extracting(AccessIdRepresentationModel::getAccessId)
|
.extracting(AccessIdRepresentationModel::getAccessId)
|
||||||
|
@ -50,13 +50,13 @@ class AccessIdControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testQueryUserByDn() {
|
void testQueryUserByDn() {
|
||||||
ResponseEntity<AccessIdListResource> response =
|
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||||
TEMPLATE.exchange(
|
TEMPLATE.exchange(
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID)
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID)
|
||||||
+ "?search-for=uid=teamlead-1,cn=users,OU=Test,O=TASKANA",
|
+ "?search-for=uid=teamlead-1,cn=users,OU=Test,O=TASKANA",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
assertThat(response.getBody())
|
assertThat(response.getBody())
|
||||||
.isNotNull()
|
.isNotNull()
|
||||||
.extracting(AccessIdRepresentationModel::getAccessId)
|
.extracting(AccessIdRepresentationModel::getAccessId)
|
||||||
|
@ -66,12 +66,12 @@ class AccessIdControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testQueryGroupsByCn() {
|
void testQueryGroupsByCn() {
|
||||||
ResponseEntity<AccessIdListResource> response =
|
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||||
TEMPLATE.exchange(
|
TEMPLATE.exchange(
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=ksc-use",
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=ksc-use",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
assertThat(response.getBody())
|
assertThat(response.getBody())
|
||||||
.isNotNull()
|
.isNotNull()
|
||||||
.extracting(AccessIdRepresentationModel::getAccessId)
|
.extracting(AccessIdRepresentationModel::getAccessId)
|
||||||
|
@ -81,12 +81,12 @@ class AccessIdControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_ReturnEmptyResults_ifInvalidCharacterIsUsedInCondition() {
|
void should_ReturnEmptyResults_ifInvalidCharacterIsUsedInCondition() {
|
||||||
ResponseEntity<AccessIdListResource> response =
|
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||||
TEMPLATE.exchange(
|
TEMPLATE.exchange(
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=ksc-teamleads,cn=groups",
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=ksc-teamleads,cn=groups",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
assertThat(response.getBody()).isNotNull().isEmpty();
|
assertThat(response.getBody()).isNotNull().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class AccessIdControllerIntTest {
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=rig",
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=rig",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
|
|
||||||
assertThat(response.getBody())
|
assertThat(response.getBody())
|
||||||
.isNotNull()
|
.isNotNull()
|
||||||
|
@ -112,7 +112,7 @@ class AccessIdControllerIntTest {
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=läf",
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=läf",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
|
|
||||||
assertThat(response.getBody())
|
assertThat(response.getBody())
|
||||||
.isNotNull()
|
.isNotNull()
|
||||||
|
@ -143,7 +143,7 @@ class AccessIdControllerIntTest {
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS) + "?access-id=teamlead-2",
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS) + "?access-id=teamlead-2",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
|
|
||||||
assertThat(response.getBody())
|
assertThat(response.getBody())
|
||||||
.isNotNull()
|
.isNotNull()
|
||||||
|
@ -166,7 +166,7 @@ class AccessIdControllerIntTest {
|
||||||
+ "?access-id=teamlead-2,cn=users",
|
+ "?access-id=teamlead-2,cn=users",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
|
|
||||||
assertThatThrownBy(call)
|
assertThatThrownBy(call)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
|
@ -184,7 +184,7 @@ class AccessIdControllerIntTest {
|
||||||
+ "cn=Organisationseinheit KSC,cn=organisation,OU=Test,O=TASKANA",
|
+ "cn=Organisationseinheit KSC,cn=organisation,OU=Test,O=TASKANA",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
restHelper.defaultRequest(),
|
restHelper.defaultRequest(),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
|
|
||||||
assertThat(response.getBody())
|
assertThat(response.getBody())
|
||||||
.isNotNull()
|
.isNotNull()
|
||||||
|
@ -201,7 +201,7 @@ class AccessIdControllerIntTest {
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS) + "?access-id=teamlead-2",
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS) + "?access-id=teamlead-2",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
new HttpEntity<>(restHelper.getHeadersUser_1_1()),
|
new HttpEntity<>(restHelper.getHeadersUser_1_1()),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
|
|
||||||
assertThatThrownBy(call)
|
assertThatThrownBy(call)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
|
@ -217,14 +217,11 @@ class AccessIdControllerIntTest {
|
||||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=al",
|
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=al",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
new HttpEntity<>(restHelper.getHeadersUser_1_1()),
|
new HttpEntity<>(restHelper.getHeadersUser_1_1()),
|
||||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
ACCESS_ID_LIST_TYPE);
|
||||||
|
|
||||||
assertThatThrownBy(call)
|
assertThatThrownBy(call)
|
||||||
.isInstanceOf(HttpClientErrorException.class)
|
.isInstanceOf(HttpClientErrorException.class)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.FORBIDDEN);
|
.isEqualTo(HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AccessIdListResource extends ArrayList<AccessIdRepresentationModel> {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue