use of samples.suppressfield.SuppressField in project powermock by powermock.
the class SuppressFieldTest method assertThatSpecificInstanceFieldSuppressionWorks.
@Test
public void assertThatSpecificInstanceFieldSuppressionWorks() throws Exception {
suppress(field(SuppressField.class, "mySecondValue"));
SuppressField suppressField = new SuppressField();
assertNull(suppressField.getMySecondValue());
}
use of samples.suppressfield.SuppressField in project powermock by powermock.
the class MemberModificationExampleTest method suppressSingleFieldExample.
@Test
public void suppressSingleFieldExample() throws Exception {
suppress(field(SuppressField.class, "domainObject"));
SuppressField tested = new SuppressField();
assertNull(tested.getDomainObject());
}
use of samples.suppressfield.SuppressField in project powermock by powermock.
the class SupressMethodExampleTest method verifySuppression.
@Test
public void verifySuppression() throws Exception {
getObjectSuppression.doIt();
getIntSuppression.doIt();
fieldSuppression.doIt();
assertEquals("getObject return-value", getObjectSuppression.expectedReturnValue, new SuppressMethod().getObject());
assertEquals("getInt return-value", getIntSuppression.expectedReturnValue, new SuppressMethod().getInt());
assertThat("Value from field", new SuppressField().getDomainObject(), is(fieldSuppression.expectation));
if (suppressConstructor) {
suppress(constructor(SuppressConstructorHierarchy.class));
} else {
expectedException.expect(RuntimeException.class);
}
SuppressConstructorHierarchy tested = new SuppressConstructorHierarchy("message");
assertTrue("Or a runtime exception should have been thrown by now", suppressConstructor);
assertEquals(42, tested.getNumber());
assertNull(tested.getMessage());
}
use of samples.suppressfield.SuppressField in project powermock by powermock.
the class SuppressFieldTest method assertThatSpecificInstanceFinalPrimitiveFieldSuppressionWorks.
@Ignore("Final primitive types doesn't work, see issue at https://github.com/jayway/powermock/issues/105")
@Test
public void assertThatSpecificInstanceFinalPrimitiveFieldSuppressionWorks() throws Exception {
suppress(field(SuppressField.class, "myBoolean"));
SuppressField suppressField = new SuppressField();
assertEquals(false, suppressField.isMyBoolean());
}
use of samples.suppressfield.SuppressField in project powermock by powermock.
the class SuppressFieldTest method assertThatAllFieldSuppressionWorks.
// TODO Add final tests here as well when they work
@Test
public void assertThatAllFieldSuppressionWorks() throws Exception {
suppress(fields(SuppressField.class));
SuppressField suppressField = new SuppressField();
assertNull(suppressField.getMySecondValue());
assertEquals(' ', suppressField.getMyChar());
assertNull(suppressField.getMyWrappedBoolean());
assertNull(SuppressField.getMyObject());
}
Aggregations