@SuppressWarnings("rawtypes") // TreeBasedTable.create() is defined as such @Generates private static <R extends Comparable, C extends Comparable, V> RowSortedTable<R, C, V> generateRowSortedTable(R row, C column, V value) { return generateTreeBasedTable(row, column, value); }
public void testInstantiate_setDistinctValues() throws Exception { NotInstantiable x = new NotInstantiable(); NotInstantiable y = new NotInstantiable(); tester.setDistinctValues(NotInstantiable.class, x, y); assertNotNull(tester.instantiate(ConstructorParameterNotInstantiable.class)); tester.testEquals(ConstructorParameterMapOfNotInstantiable.class); }
public void testEqualsAndSerializableOnReturnValues_equalsIsGoodButNotSerializable() throws Exception { try { tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEqualsAndSerializable(); } catch (AssertionFailedError expected) { return; } fail("should have failed"); }
public void testSymmetryBroken() { EqualsTester tester = new EqualsTester().addEqualityGroup(named("foo").addPeers("bar"), named("bar")); try { tester.testEquals(); } catch (AssertionFailedError e) { assertErrorMessage(e, "bar [group 1, item 2] must be Object#equals to foo [group 1, item 1]"); return; } fail("should failed because symmetry is broken"); }
/** Test proper handling where an object tests equal to null */ public void testInvalidEqualsNull() { Object obj = new InvalidEqualsNullObject(); equalsTester.addEqualityGroup(obj); try { equalsTester.testEquals(); } catch (AssertionFailedError e) { assertErrorMessage(e, obj + " must not be Object#equals to null"); return; } fail("Should get equal to null error"); }
public void testInterfaceDefaultMethod() { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicInstanceMethods(InterfaceDefaultMethodChecksNull.create()); try { tester.testAllPublicInstanceMethods(InterfaceDefaultMethodFailsToCheckNull.create()); } catch (AssertionError expected) { return; } fail(); }
public void testSingleTearDown() throws Exception { final TearDownStack stack = buildTearDownStack(); final SimpleTearDown tearDown = new SimpleTearDown(); stack.addTearDown(tearDown); assertEquals(false, tearDown.ran); stack.runTearDown(); assertEquals("tearDown should have run", true, tearDown.ran); }
public void testInstantiate_setDefault() throws Exception { NotInstantiable x = new NotInstantiable(); tester.setDefault(NotInstantiable.class, x); assertNotNull(tester.instantiate(ConstructorParameterNotInstantiable.class)); }
public void testSerializableOnReturnValues_bad() throws Exception { try { tester.forAllPublicStaticMethods(BadSerializableFactory.class).testSerializable(); } catch (AssertionFailedError expected) { return; } fail(); }
public void testEqualsOnReturnValues_bad() throws Exception { try { tester.forAllPublicStaticMethods(BadEqualsFactory.class).testEquals(); } catch (AssertionFailedError expected) { return; } fail(); }
public void testNullsForReturnValues_factoryReturnsNullButNotAnnotated() throws Exception { try { tester.forAllPublicStaticMethods(FactoryThatReturnsNullButNotAnnotated.class).testNulls(); } catch (AssertionFailedError expected) { return; } fail(); }
public void testGet_class() { assertSame(SomeAbstractClass.INSTANCE, ArbitraryInstances.get(SomeAbstractClass.class)); assertSame( WithPrivateConstructor.INSTANCE, ArbitraryInstances.get(WithPrivateConstructor.class)); assertNull(ArbitraryInstances.get(NoDefaultConstructor.class)); assertSame( WithExceptionalConstructor.INSTANCE, ArbitraryInstances.get(WithExceptionalConstructor.class)); assertNull(ArbitraryInstances.get(NonPublicClass.class)); }
public void testSetDistinctValues_equalInstances() { try { tester.setDistinctValues(String.class, "", ""); fail(); } catch (IllegalArgumentException expected) { } }
public void testInstantiate_constructorThrows() throws Exception { try { tester.instantiate(ConstructorThrows.class); fail(); } catch (InvocationTargetException expected) { } }
public void testFactoryMethodReturnsNullButNotAnnotatedInEqualsTest() throws Exception { try { tester.testEquals(FactoryMethodReturnsNullButNotAnnotated.class); } catch (AssertionFailedError expected) { return; } fail("should have failed"); }
public void testEqualsAndSerializableOnReturnValues_serializableButNotEquals() throws Exception { try { tester.forAllPublicStaticMethods(GoodSerializableFactory.class).testEqualsAndSerializable(); } catch (AssertionFailedError expected) { return; } fail("should have failed"); }
public void testSerializableForReturnValues_factoryReturnsNullButNotAnnotated() throws Exception { try { tester .forAllPublicStaticMethods(FactoryThatReturnsNullButNotAnnotated.class) .testSerializable(); } catch (AssertionFailedError expected) { return; } fail(); }
public void testEqualsForReturnValues_factoryReturnsNullButNotAnnotated() throws Exception { try { tester.forAllPublicStaticMethods(FactoryThatReturnsNullButNotAnnotated.class).testEquals(); } catch (AssertionFailedError expected) { return; } fail(); }
public void testInstantiate_factoryMethodParameterNotInstantiable() throws Exception { try { tester.instantiate(FactoryMethodParameterNotInstantiable.class); fail(); } catch (ParameterNotInstantiableException expected) { } }
public void testEqualsAndSerializableForReturnValues_factoryReturnsNullButNotAnnotated() throws Exception { try { tester .forAllPublicStaticMethods(FactoryThatReturnsNullButNotAnnotated.class) .testEqualsAndSerializable(); } catch (AssertionFailedError expected) { return; } fail(); }