use of net.morimekta.test.providence.testing.RequiredFields in project providence by morimekta.
the class ProvidenceTest method testHashCode.
@Test
public void testHashCode() {
OptionalFields of = OptionalFields.builder().build();
OptionalFields of2 = OptionalFields.builder().build();
RequiredFields rf = RequiredFields.builder().build();
UnionFields uf = UnionFields.withCompactValue(new CompactFields("a", 4, null));
assertThat(of, not(sameInstance(of2)));
assertThat(of.hashCode(), is(equalTo(of2.hashCode())));
assertThat(of.hashCode(), not(equalTo(rf.hashCode())));
assertThat(uf.hashCode(), not(equalTo(rf.hashCode())));
}
use of net.morimekta.test.providence.testing.RequiredFields in project providence by morimekta.
the class ProvidenceTest method testRequiredFields.
@Test
public void testRequiredFields() {
RequiredFields rf = RequiredFields.builder().build();
assertThat(rf.hasBooleanValue(), is(true));
assertThat(rf.isBooleanValue(), is(false));
assertThat(rf.hasByteValue(), is(true));
assertThat(rf.getByteValue(), is((byte) 0));
assertThat(rf.hasShortValue(), is(true));
assertThat(rf.getShortValue(), is((short) 0));
assertThat(rf.hasIntegerValue(), is(true));
assertThat(rf.getIntegerValue(), is(0));
assertThat(rf.hasLongValue(), is(true));
assertThat(rf.getLongValue(), is(0L));
assertThat(rf.hasDoubleValue(), is(true));
assertThat(rf.getDoubleValue(), is(0.0));
// null pointers, presence = false.
assertThat(rf.hasStringValue(), is(true));
assertThat(rf.getStringValue(), is(""));
assertThat(rf.hasBinaryValue(), is(true));
assertThat(rf.getBinaryValue(), is(Binary.empty()));
assertThat(rf.hasEnumValue(), is(false));
assertThat(rf.getEnumValue(), is(nullValue()));
assertThat(rf.hasCompactValue(), is(false));
assertThat(rf.getCompactValue(), is(nullValue()));
}
Aggregations