use of net.morimekta.test.providence.testing.OptionalFields in project providence by morimekta.
the class ProvidenceTest method testOptionalFields.
@Test
public void testOptionalFields() {
OptionalFields of = OptionalFields.builder().build();
assertThat(of.hasBooleanValue(), is(false));
assertThat(of.isBooleanValue(), is(false));
assertThat(of.hasByteValue(), is(false));
assertThat(of.getByteValue(), is((byte) 0));
assertThat(of.hasShortValue(), is(false));
assertThat(of.getShortValue(), is((short) 0));
assertThat(of.hasIntegerValue(), is(false));
assertThat(of.getIntegerValue(), is(0));
assertThat(of.hasLongValue(), is(false));
assertThat(of.getLongValue(), is(0L));
assertThat(of.hasDoubleValue(), is(false));
assertThat(of.getDoubleValue(), is(0.0));
assertThat(of.hasStringValue(), is(false));
assertThat(of.getStringValue(), is(nullValue()));
assertThat(of.hasBinaryValue(), is(false));
assertThat(of.getBinaryValue(), is(nullValue()));
assertThat(of.hasEnumValue(), is(false));
assertThat(of.getEnumValue(), is(nullValue()));
assertThat(of.hasCompactValue(), is(false));
assertThat(of.getCompactValue(), is(nullValue()));
}
use of net.morimekta.test.providence.testing.OptionalFields in project providence by morimekta.
the class ProvidenceTest method testMutable.
@Test
public void testMutable() {
OptionalFields of = OptionalFields.builder().setCompactValue(new CompactFields("a", 4, null)).build();
Containers a = Containers.builder().setOptionalFields(of).build();
Containers._Builder b = a.mutate();
assertThat(b.build().getOptionalFields(), is(sameInstance(of)));
b.mutableOptionalFields().setIntegerValue(55);
Containers c = b.build();
// Even if the intermediate structure is mutated
// inner contained structures are not rebuilt.
assertThat(c.getOptionalFields().getIntegerValue(), is(55));
assertThat(c.getOptionalFields().getCompactValue(), is(sameInstance(of.getCompactValue())));
}
Aggregations