use of net.morimekta.test.providence.testing.Containers in project providence by morimekta.
the class ProvidenceBuilderTest method testEmptyCollections.
@Test
public void testEmptyCollections() {
Containers._Builder builder = Containers.builder().setBinarySet(Collections.EMPTY_SET).setIntegerList(Collections.EMPTY_LIST).setLongMap(Collections.EMPTY_MAP);
assertThat(builder.isModifiedBinarySet(), is(true));
assertThat(builder.isModifiedIntegerList(), is(true));
assertThat(builder.isModifiedLongMap(), is(true));
assertThat(builder.modifiedFields().size(), is(3));
assertThat(builder.modifiedFields(), hasItems(Containers._Field.BINARY_SET, Containers._Field.INTEGER_LIST, Containers._Field.LONG_MAP));
Containers containers = builder.build();
assertThat(containers.hasBinarySet(), is(true));
assertThat(containers.hasIntegerList(), is(true));
assertThat(containers.hasLongMap(), is(true));
assertThat(containers.mutate().build(), is(equalToMessage(containers)));
}
use of net.morimekta.test.providence.testing.Containers 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