Skip to content

Commit ca22649

Browse files
committed
Added UserAttributeProfilePage and Deserializer
1 parent 66ff9ff commit ca22649

File tree

6 files changed

+63
-264
lines changed

6 files changed

+63
-264
lines changed

src/main/java/com/auth0/client/mgmt/UserAttributeProfilesEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Request<UserAttributeProfile> get(String id) {
4343
* @return a Request to execute
4444
*
4545
*/
46-
public Request<ListUserAttributeProfile> getAll(UserAttributeProfilesFilter filter) {
46+
public Request<UserAttributeProfilePage> getAll(UserAttributeProfilesFilter filter) {
4747
HttpUrl.Builder builder = baseUrl.newBuilder()
4848
.addPathSegments(ORGS_PATH);
4949

@@ -53,7 +53,7 @@ public Request<ListUserAttributeProfile> getAll(UserAttributeProfilesFilter filt
5353

5454
String url = builder.build().toString();
5555

56-
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<ListUserAttributeProfile>() {
56+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<UserAttributeProfilePage>() {
5757
});
5858
}
5959

src/main/java/com/auth0/json/mgmt/userAttributeProfiles/ListUserAttributeProfile.java

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.auth0.json.mgmt.userAttributeProfiles;
2+
3+
import com.auth0.json.mgmt.Page;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
6+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
7+
8+
import java.util.List;
9+
10+
@SuppressWarnings({"unused", "WeakerAccess"})
11+
@JsonIgnoreProperties(ignoreUnknown = true)
12+
@JsonInclude(JsonInclude.Include.NON_NULL)
13+
@JsonDeserialize(using = UserAttributeProfilePageDeserializer.class)
14+
public class UserAttributeProfilePage extends Page<UserAttributeProfile> {
15+
public UserAttributeProfilePage(List<UserAttributeProfile> items) {
16+
super(items);
17+
}
18+
19+
protected UserAttributeProfilePage(Integer start, Integer length, Integer total, Integer limit, List<UserAttributeProfile> items) {
20+
super(start, length, total, limit, items);
21+
}
22+
23+
protected UserAttributeProfilePage(Integer start, Integer length, Integer total, Integer limit, String next, List<UserAttributeProfile> items){
24+
super(start, length, total, limit, next, items);
25+
}
26+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.auth0.json.mgmt.userAttributeProfiles;
2+
3+
import com.auth0.json.mgmt.PageDeserializer;
4+
5+
import java.util.List;
6+
7+
8+
@SuppressWarnings({"unused", "WeakerAccess"})
9+
class UserAttributeProfilePageDeserializer extends PageDeserializer<UserAttributeProfilePage, UserAttributeProfile> {
10+
UserAttributeProfilePageDeserializer() {
11+
super(UserAttributeProfile.class, "user_attribute_profiles");
12+
}
13+
14+
@Override
15+
protected UserAttributeProfilePage createPage(List<UserAttributeProfile> items) {
16+
return new UserAttributeProfilePage(items);
17+
}
18+
19+
@Override
20+
protected UserAttributeProfilePage createPage(Integer start, Integer length, Integer total, Integer limit, List<UserAttributeProfile> items) {
21+
return new UserAttributeProfilePage(start, length, total, limit, items);
22+
}
23+
24+
@Override
25+
protected UserAttributeProfilePage createPage(Integer start, Integer length, Integer total, Integer limit, String next, List<UserAttributeProfile> items) {
26+
return new UserAttributeProfilePage(start, length, total, limit, next, items);
27+
}
28+
}

src/test/java/com/auth0/client/mgmt/UserAttributeProfilesEntityTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,31 @@ public void shouldGetUserAttributeProfile() throws Exception {
4949

5050
@Test
5151
public void shouldGetAllUserAttributeProfilesWithoutFilter() throws Exception {
52-
Request<ListUserAttributeProfile> request = api.userAttributeProfiles().getAll(null);
52+
Request<UserAttributeProfilePage> request = api.userAttributeProfiles().getAll(null);
5353
assertThat(request, is(notNullValue()));
5454

5555
server.jsonResponse(MockServer.MGMT_USER_ATTRIBUTE_PROFILES_LIST, 200);
56-
ListUserAttributeProfile response = request.execute().getBody();
56+
UserAttributeProfilePage response = request.execute().getBody();
5757
RecordedRequest recordedRequest = server.takeRequest();
5858

5959
assertThat(recordedRequest, hasMethodAndPath(HttpMethod.GET, "/api/v2/user-attribute-profiles"));
6060
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
6161
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
6262

6363
assertThat(response, is(notNullValue()));
64-
assertThat(response.getUserAttributeProfiles(), hasSize(3));
64+
assertThat(response.getItems(), hasSize(3));
6565
}
6666

6767
@Test
6868
public void shouldGetAllUserAttributeProfilesWithFilter() throws Exception {
6969
UserAttributeProfilesFilter filter = new UserAttributeProfilesFilter()
70-
.withCheckpointPagination("uap_1234567890", 10);
70+
.withCheckpointPagination("uap_1234567890", 2);
7171

72-
Request<ListUserAttributeProfile> request = api.userAttributeProfiles().getAll(filter);
72+
Request<UserAttributeProfilePage> request = api.userAttributeProfiles().getAll(filter);
7373
assertThat(request, is(notNullValue()));
7474

7575
server.jsonResponse(MockServer.MGMT_USER_ATTRIBUTE_PROFILES_LIST, 200);
76-
ListUserAttributeProfile response = request.execute().getBody();
76+
UserAttributeProfilePage response = request.execute().getBody();
7777
RecordedRequest recordedRequest = server.takeRequest();
7878

7979
assertThat(recordedRequest, hasMethodAndPath(HttpMethod.GET, "/api/v2/user-attribute-profiles"));
@@ -83,7 +83,7 @@ public void shouldGetAllUserAttributeProfilesWithFilter() throws Exception {
8383
assertThat(recordedRequest, hasQueryParameter("take", "10"));
8484

8585
assertThat(response, is(notNullValue()));
86-
assertThat(response.getUserAttributeProfiles(), hasSize(3));
86+
assertThat(response.getItems(), hasSize(2));
8787
}
8888

8989
@Test

src/test/java/com/auth0/json/mgmt/userAttributeProfiles/ListUserAttributeProfileTest.java

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)