public class FlatPackEntityMergeTest extends FlatPackTest {
@Test
public void test() throws IOException {
Employee e1 = makeEmployee();
Employee e2 = makeEmployee();
JsonElement j1 = flatpack.getPacker().pack(FlatPackEntity.entity(e1));
JsonElement j2 = flatpack.getPacker().pack(FlatPackEntity.entity(e2));
JsonObject merged = FlatPackEntityMerge.merge(j2, j1).getAsJsonObject();
assertEquals(2, merged.entrySet().size());
assertEquals(e1.getUuid().toString(), merged.get("value").getAsString());
JsonArray employeeArray = merged.get("data").getAsJsonObject().get("employee").getAsJsonArray();
assertEquals(2, employeeArray.size());
FlatPackEntity<Employee> entity =
flatpack.getUnpacker().<Employee> unpack(Employee.class, merged, null);
Employee u1 = entity.getValue();
assertEquals(e1, u1);
assertEquals(2, entity.getExtraEntities().size());
}