static Employee filledEmployee() { Collection<String> departments = new ArrayList<String>(); departments.add("Engineering"); departments.add("IT"); Collection<ITask> tasks = new ArrayList<ITask>(); tasks.add(filledTask()); Employee p = new Employee(); p.setId(1); p.setDepartments(departments); p.setTasks(tasks); return p; }
public void testTask() throws Exception { RuntimeSchema<Task> schema = getSchema(Task.class); Task task = CollectionTest.filledTask(); roundTrip(task, schema, schema.getPipeSchema()); }
@Test public void testIEmployee() throws Exception { // Because we mapped IEmployee to Employee, this is ok. Schema<AbstractEmployee> schema = RuntimeSchema .getSchema(AbstractEmployee.class); Collection<String> departments = new ArrayList<String>(); departments.add("Engineering"); departments.add("IT"); Collection<ITask> tasks = new ArrayList<ITask>(); tasks.add(filledTask()); AbstractEmployee p = new Employee(); p.setId(1); p.setDepartments(departments); p.setTasks(tasks); byte[] data = ProtostuffIOUtil.toByteArray(p, schema, LinkedBuffer.allocate(512)); AbstractEmployee p2 = new Employee(); ProtostuffIOUtil.mergeFrom(data, p2, schema); // System.err.println(p2); assertEquals(p, p2); }
@Test public void testSimpleTask() throws Exception { Schema<Task> schema = RuntimeSchema.getSchema(Task.class); Task p = filledTask(); byte[] data = ProtostuffIOUtil.toByteArray(p, schema, LinkedBuffer.allocate(512)); Task p2 = new Task(); ProtostuffIOUtil.mergeFrom(data, p2, schema); // System.err.println(p2); assertEquals(p, p2); }
@Test public void testITask() throws Exception { // Because we mapped ITask to Task, this is ok. Schema<ITask> schema = RuntimeSchema.getSchema(ITask.class); ITask p = filledTask(); byte[] data = ProtostuffIOUtil.toByteArray(p, schema, LinkedBuffer.allocate(512)); ITask p2 = new Task(); ProtostuffIOUtil.mergeFrom(data, p2, schema); // System.err.println(p2); assertEquals(p, p2); }