com.blazebit.storage.testsuite.common.Assert Maven / Gradle / Ivy
package com.blazebit.storage.testsuite.common;
import static org.junit.Assert.*;
import java.util.Collection;
import java.util.List;
import com.googlecode.catchexception.internal.SubclassProxyFactory;
public class Assert {
// # Collection assertions
public static void assertUnorderedEquals(Collection> a, Collection> b) {
assertEquals(a.size(), b.size());
assertTrue(a.containsAll(b));
}
public static void assertOrderedEquals(List> a, List> b) {
assertEquals(a.size(), b.size());
for (int i = 0; i < a.size(); i++) {
if (a.get(i) == null) {
assertTrue(b.get(i) == null);
} else {
assertTrue(a.get(i).equals(b.get(i)));
}
}
}
// # Exception assertions
public static T verifyException(T obj, Class clazz) {
if (obj == null) {
throw new IllegalArgumentException("obj must not be null");
}
return new SubclassProxyFactory(). createProxy(obj.getClass(), new EjbAwareThrowableProcessingInterceptor(obj, clazz));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy