use of net.morimekta.test.providence.testing.CompactFields 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())));
}
use of net.morimekta.test.providence.testing.CompactFields in project providence by morimekta.
the class ProvidenceTest method testUnionConstructorOverload.
@Test
public void testUnionConstructorOverload() {
assertThat(UnionFields.withCompactValue((CompactFields._Builder) null), is(UnionFields.withCompactValue((CompactFields) null)));
assertThat(UnionFields.withCompactValue(CompactFields.builder()), is(UnionFields.withCompactValue(CompactFields.builder().build())));
assertThat(UnionFields.withCompactValue(CompactFields.builder().setName("a").setId(4)), is(UnionFields.withCompactValue(new CompactFields("a", 4, null))));
}
Aggregations