ilgrosso commented on code in PR #1296:
URL: https://github.com/apache/syncope/pull/1296#discussion_r2792203709
##########
client/am/console/src/main/java/org/apache/syncope/client/console/rest/AuthProfileRestClient.java:
##########
@@ -20,18 +20,23 @@
import java.util.List;
import org.apache.syncope.common.lib.to.AuthProfileTO;
+import org.apache.syncope.common.rest.api.beans.AuthProfileQuery;
import org.apache.syncope.common.rest.api.service.AuthProfileService;
public class AuthProfileRestClient extends BaseRestClient {
private static final long serialVersionUID = -7379778542101161274L;
- public long count() {
- return getService(AuthProfileService.class).list(1, 1).getTotalCount();
+ public long count(final String keyword) {
+ return getService(AuthProfileService.class).
+ search(new
AuthProfileQuery.Builder().page(1).size(0).keyword(keyword).build()).
+ getTotalCount();
}
- public List<AuthProfileTO> list(final int page, final int size) {
- return getService(AuthProfileService.class).list(page,
size).getResult();
+ public List<AuthProfileTO> search(final int page, final int size, final
String keyword) {
Review Comment:
Please change this method's parameters order: `keyword`, `page, `size`
##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/wa/GoogleMfaAuthTokenITCase.java:
##########
@@ -65,17 +65,49 @@ public void count() {
}
@Test
- public void verifyProfile() {
- String owner = UUID.randomUUID().toString();
- GoogleMfaAuthToken token = createGoogleMfaAuthToken();
- GOOGLE_MFA_AUTH_TOKEN_SERVICE.store(owner, token);
- PagedResult<AuthProfileTO> results = AUTH_PROFILE_SERVICE.list(1, 100);
- assertFalse(results.getResult().isEmpty());
- AuthProfileTO profileTO = results.getResult().stream().
- filter(p -> owner.equals(p.getOwner())).findFirst().get();
- assertEquals(profileTO, AUTH_PROFILE_SERVICE.read(profileTO.getKey()));
- AUTH_PROFILE_SERVICE.delete(profileTO.getKey());
- assertThrows(SyncopeClientException.class, () ->
AUTH_PROFILE_SERVICE.read(profileTO.getKey()));
+ public void listProfiles() {
+ String owner = "owner" + UUID.randomUUID();
+ String owner1 = "owner" + UUID.randomUUID();
+ String test = "test" + UUID.randomUUID();
+ PagedResult<AuthProfileTO> results = null;
+ PagedResult<AuthProfileTO> resultsTest = null;
+ try {
+ GoogleMfaAuthToken token = createGoogleMfaAuthToken();
+ GOOGLE_MFA_AUTH_TOKEN_SERVICE.store(owner, token);
+
+ GoogleMfaAuthToken token1 = createGoogleMfaAuthToken();
+ GOOGLE_MFA_AUTH_TOKEN_SERVICE.store(owner1, token1);
+
+ GoogleMfaAuthToken token2 = createGoogleMfaAuthToken();
+ GOOGLE_MFA_AUTH_TOKEN_SERVICE.store(test, token2);
+
+ results = AUTH_PROFILE_SERVICE.search(
+ new
AuthProfileQuery.Builder().page(1).size(100).keyword("owner*").build());
+
+ resultsTest = AUTH_PROFILE_SERVICE.search(
+ new
AuthProfileQuery.Builder().page(1).size(100).keyword("test*").build());
+
+ assertEquals(2, results.getTotalCount());
+ assertEquals(2, results.getResult().size());
+ } finally {
+ AuthProfileTO profileTO = results.getResult().stream().
+ filter(p -> owner.equals(p.getOwner())).findFirst().get();
Review Comment:
replace `.get()` with `orElseThrow()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]