Package com.getperka.flatpack.domain

Examples of com.getperka.flatpack.domain.PersistentEmployee


    toReturn.getAddress().setStreet("manager street");
    return toReturn;
  }

  protected PersistentEmployee makePersistentEmployee() {
    PersistentEmployee toReturn = persistentEmployees.get();
    toReturn.setEmployeeNumber(++counter);
    toReturn.setName("Employee Name");
    toReturn.getAddress().setStreet("street");
    return toReturn;
  }
View Full Code Here


   * Verify that persistent entities with no dirty properties do not have any entries in the data
   * section.
   */
  @Test
  public void testElidedEntities() throws IOException {
    PersistentEmployee e = makePersistentEmployee();
    e.markPersistent();

    StringWriter out = new StringWriter();
    flatpack.getPacker().pack(FlatPackEntity.entity(e), out);

    JsonObject payload = new JsonParser().parse(out.toString()).getAsJsonObject();
View Full Code Here

   * Verify that an entity that supports dirty-tracking results in fewer properties in the payload
   * and that the dirty-tracking methods are called as expected.
   */
  @Test
  public void testSparseProperties() throws IOException {
    PersistentEmployee e = makePersistentEmployee();
    e.setTrackedProperty("trackedProperty");
    assertEquals(Collections.singleton("trackedProperty"), e.dirtyPropertyNames());

    StringWriter out = new StringWriter();
    flatpack.getPacker().pack(FlatPackEntity.entity(e), out);

    assertFalse(out.toString().contains("name"));
    assertTrue(out.toString().contains("trackedProperty"));

    FlatPackEntity<PersistentEmployee> entity = flatpack.getUnpacker()
        .unpack(PersistentEmployee.class, new StringReader(out.toString()), null);
    PersistentEmployee e2 = entity.getValue();
    assertTrue(e2.wasPersistent());
    assertTrue(e2.dirtyPropertyNames().isEmpty());
  }
View Full Code Here

TOP

Related Classes of com.getperka.flatpack.domain.PersistentEmployee

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.