Package com.linkedin.data.transform.patch.request

Examples of com.linkedin.data.transform.patch.request.PatchTree


  private final T _templateProxy;
  private final PatchTree _patchTree;

  public PatchTreeRecorder(Class<T> clazz)
  {
    _patchTree = new PatchTree();
    _templateProxy = GeneratePatchProxyFactory.newInstance(clazz, _patchTree, PathSpec.emptyPath());
  }
View Full Code Here


   */
  public PatchTree generatePatchTree()
  {
    try
    {
      return new PatchTree( _patchTree.getDataMap().copy());
    }
    catch (CloneNotSupportedException e)
    {
      throw new IllegalStateException("Error copying data map: " + _patchTree.getDataMap(), e);
    }
View Full Code Here

  }

  @Test
  public void testExplicitUpdate()
  {
    PatchTree explicitUpdateSpec = new PatchTree();
    explicitUpdateSpec.addOperation(Group.fields().id(), PatchOpFactory.setFieldOp(42));
    explicitUpdateSpec.addOperation(Group.fields().name(), PatchOpFactory.setFieldOp("Foo"));
    explicitUpdateSpec.addOperation(Group.fields().description(), PatchOpFactory.REMOVE_FIELD_OP);
    assertEquals(explicitUpdateSpec.toString(), "{$set={id=42, name=Foo}, $delete=[description]}");
  }
View Full Code Here

  {
    Group g1 = new Group();
    Group g2 = new Group(g1.data().copy());
    g2.setId(42);
    g2.setName("Some Group");
    PatchTree update = PatchCreator.diff(g1, g2);
    assertEquals(update.toString(), "{$set={id=42, name=Some Group}}");
  }
View Full Code Here

    Group g2 = new Group(g1.data().copy());
    Location loc = new Location();
    loc.setLatitude(42.0f);
    loc.setLongitude(17.0f);
    g2.setLocation(loc);
    PatchTree update = PatchCreator.diff(g1, g2);
    assertEquals(update.toString(), "{$set={location={longitude=17.0, latitude=42.0}}}");
  }
View Full Code Here

    Group g2 = new Group(g1.data().copy());
    Location loc2 = new Location();
    loc2.setLatitude(42.0f);
    loc2.setLongitude(17.0f);
    g2.setLocation(loc2);
    PatchTree update = PatchCreator.diff(g1, g2);
    assertEquals(update.toString(), "{location={$set={longitude=17.0, latitude=42.0}}}");
  }
View Full Code Here

    g1.setDescription("Some description");

    Group g2 = new Group(g1.data().copy());
    g2.setId(42);
    g2.setName("Some Group");
    PatchTree update = PatchCreator.diff(g1, g2);
    assertEquals(update.toString(), "{$set={id=42, name=Some Group}}");
  }
View Full Code Here

    Group g1 = new Group();
    g1.setId(17);
    g1.setDescription("Some description");
    Group g2 = new Group(g1.data().copy());
    g2.removeDescription();
    PatchTree update = PatchCreator.diff(g1, g2);
    assertEquals(update.toString(), "{$delete=[description]}");
  }
View Full Code Here

    Group g1 = new Group();
    g1.setId(17);
    g1.setDescription("Some description");
    Group g2 = new Group(g1.data().copy());
    g2.removeDescription();
    PatchTree update = PatchCreator.diff(g1, g2);

    assertEquals(update.toString(), "{$delete=[description]}");
    assertFalse(g1.equals(g2));

    DataComplexProcessor processor = new DataComplexProcessor(new Patch(), update.getDataMap(), g1.data());
    processor.run(false);

    assertEquals(g1, g2);
  }
View Full Code Here

    g1.setDescription("Some description");

    Group g2 = new Group(g1.data().copy());
    g2.setId(42);
    g2.setName("Some Group");
    PatchTree update = PatchCreator.diff(g1, g2);
    assertEquals(update.toString(), "{$set={id=42, name=Some Group}}");
    assertFalse(g1.equals(g2));

    DataComplexProcessor processor = new DataComplexProcessor(new Patch(), update.getDataMap(), g1.data());
    processor.run(false);

    assertEquals(g1, g2);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.data.transform.patch.request.PatchTree

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.