Remove AbstractAdminTest.assertNames and related methods (as they are available in Assert class)

This commit is contained in:
mposolda 2016-04-20 08:04:18 +02:00
parent 060527ac67
commit d415bdb3d2
2 changed files with 4 additions and 39 deletions

View file

@ -93,40 +93,4 @@ public abstract class AbstractAdminTest extends TestRealmKeycloakTest {
}
}
public static <T> void assertNames(List<T> actual, String... expected) {
Arrays.sort(expected);
String[] actualNames = names(actual);
assertArrayEquals("Expected: " + Arrays.toString(expected) + ", was: " + Arrays.toString(actualNames), expected, actualNames);
}
public static <T> List<T> sort(List<T> list) {
Collections.sort(list, new Comparator<Object>() {
@Override
public int compare(Object o1, Object o2) {
return name(o1).compareTo(name(o2));
}
});
return list;
}
public static <T> String[] names(List<T> list) {
String[] names = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
names[i] = name(list.get(i));
}
Arrays.sort(names);
return names;
}
public static String name(Object o1) {
if (o1 instanceof RealmRepresentation) {
return ((RealmRepresentation) o1).getRealm();
} else if (o1 instanceof ClientRepresentation) {
return ((ClientRepresentation) o1).getClientId();
} else if (o1 instanceof IdentityProviderRepresentation) {
return ((IdentityProviderRepresentation) o1).getAlias();
}
throw new IllegalArgumentException();
}
}

View file

@ -17,7 +17,6 @@
package org.keycloak.testsuite.admin;
import org.junit.Assert;
import org.junit.Test;
import org.keycloak.admin.client.resource.ClientResource;
import org.keycloak.admin.client.resource.ProtocolMappersResource;
@ -31,6 +30,8 @@ import javax.ws.rs.core.Response;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.util.OAuthClient;
import static org.junit.Assert.assertArrayEquals;
@ -47,7 +48,7 @@ public class ClientTest extends AbstractAdminTest {
@Test
public void getClients() {
assertNames(realm.clients().findAll(), "account", "realm-management", "security-admin-console", "broker", Constants.ADMIN_CLI_CLIENT_ID);
Assert.assertNames(realm.clients().findAll(), "account", "realm-management", "security-admin-console", "broker", Constants.ADMIN_CLI_CLIENT_ID);
}
private ClientRepresentation createClient() {
@ -67,7 +68,7 @@ public class ClientTest extends AbstractAdminTest {
String id = createClient().getId();
assertNotNull(realm.clients().get(id));
assertNames(realm.clients().findAll(), "account", "realm-management", "security-admin-console", "broker", "my-app", Constants.ADMIN_CLI_CLIENT_ID);
Assert.assertNames(realm.clients().findAll(), "account", "realm-management", "security-admin-console", "broker", "my-app", Constants.ADMIN_CLI_CLIENT_ID);
}
@Test