Search in sources :

Example 6 with CompactFields

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())));
}
Also used : OptionalFields(net.morimekta.test.providence.testing.OptionalFields) Containers(net.morimekta.test.providence.testing.Containers) CompactFields(net.morimekta.test.providence.testing.CompactFields) Test(org.junit.Test)

Example 7 with CompactFields

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))));
}
Also used : CompactFields(net.morimekta.test.providence.testing.CompactFields) Test(org.junit.Test)

Aggregations

CompactFields (net.morimekta.test.providence.testing.CompactFields)7 Test (org.junit.Test)7 OptionalFields (net.morimekta.test.providence.testing.OptionalFields)4 UnionFields (net.morimekta.test.providence.testing.UnionFields)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 BinarySerializer (net.morimekta.providence.serializer.BinarySerializer)1 AutoIdFields (net.morimekta.test.providence.testing.AutoIdFields)1 Containers (net.morimekta.test.providence.testing.Containers)1 RequiredFields (net.morimekta.test.providence.testing.RequiredFields)1