コード例 #1
0
ファイル: MergerTest.java プロジェクト: togaurav/transfuse
  @Test
  public void testUnidentified() throws MergerException {
    One before = buildOne("1", buildTwo(buildThree("3", "before")));
    One after = buildOne("1", buildTwo(buildThree("3", "after")));

    One merged = merger.merge(One.class, before, after);

    assertEquals(1, merged.getTwo().size());
    Two mergedTwo = merged.getTwo().get(0);
    assertEquals(1, mergedTwo.getThree().size());
    Three mergedThree = mergedTwo.getThree().get(0);
    assertEquals("after", mergedThree.getValue());
  }
コード例 #2
0
ファイル: MergerTest.java プロジェクト: togaurav/transfuse
  @Test
  public void testEmptyCollection() throws MergerException {
    List<SubMergeable> subMergeablesOne = new ArrayList<SubMergeable>();
    List<SubMergeable> subMergeablesTwo = new ArrayList<SubMergeable>();

    subMergeablesOne.add(buildSubMergeable("1", "five", "six", true));

    MergeableRoot one = buildMergeableRoot("2", "one", "two", 5, subMergeablesOne, true);
    MergeableRoot two = buildMergeableRoot("2", "three", "four", 6, subMergeablesTwo, true);

    MergeableRoot merged = merger.merge(MergeableRoot.class, one, two);

    assertEquals("one", merged.getDontMerge());
    assertEquals("four", merged.getStringValue());
    assertEquals(6, merged.getIntValue());
    assertEquals(0, merged.getSubMergeables().size());
  }
コード例 #3
0
ファイル: MergerTest.java プロジェクト: togaurav/transfuse
  @Test
  public void testNullCollection() throws MergerException {
    List<SubMergeable> subMergeablesTwo = new ArrayList<SubMergeable>();

    subMergeablesTwo.add(buildSubMergeable("1", "seven", "eight", true));

    MergeableRoot one = buildMergeableRoot("3", "one", "two", 5, null, true);
    MergeableRoot two = buildMergeableRoot("3", null, null, 6, subMergeablesTwo, true);

    MergeableRoot merged = merger.merge(MergeableRoot.class, one, two);

    assertEquals("one", merged.getDontMerge());
    assertNull(merged.getStringValue());
    assertEquals(6, merged.getIntValue());
    assertEquals(1, merged.getSubMergeables().size());
    SubMergeable subMergeable = merged.getSubMergeables().iterator().next();
    assertEquals("seven", subMergeable.getValue());
    assertEquals("eight", subMergeable.getDontMergeValue());
  }
コード例 #4
0
ファイル: MergerTest.java プロジェクト: togaurav/transfuse
  @Test
  public void testNonMatchingMerge() throws MergerException {
    List<SubMergeable> subMergeablesOne = new ArrayList<SubMergeable>();
    List<SubMergeable> subMergeablesTwo = new ArrayList<SubMergeable>();

    subMergeablesOne.add(buildSubMergeable("1", "five", "six", true));
    subMergeablesTwo.add(buildSubMergeable("2", "seven", "eight", true));

    MergeableRoot one = buildMergeableRoot("3", "one", "two", 5, subMergeablesOne, true);
    MergeableRoot two = buildMergeableRoot("4", "three", "four", 6, subMergeablesTwo, true);

    MergeableRoot merged = merger.merge(MergeableRoot.class, one, two);

    assertEquals("one", merged.getDontMerge());
    assertEquals("four", merged.getStringValue());
    assertEquals(6, merged.getIntValue());
    assertEquals(1, merged.getSubMergeables().size());
    SubMergeable subMergeableTwo = buildSubMergeableMap(merged.getSubMergeables()).get("2");
    assertEquals("seven", subMergeableTwo.getValue());
    assertEquals("eight", subMergeableTwo.getDontMergeValue());
  }
コード例 #5
0
ファイル: MergerTest.java プロジェクト: togaurav/transfuse
  @Test
  public void testUnidentifiedList() throws MergerException {
    OneContainer before = new OneContainer();
    OneContainer after = new OneContainer();

    before.getOnes().add(buildOne("1", buildTwo(buildThree("3", "before"))));
    before.getOnes().add(buildOne("2"));
    after.getOnes().add(buildOne("1"));
    after.getOnes().add(buildOne("2", buildTwo(buildThree("3", "after"))));

    OneContainer merged = merger.merge(OneContainer.class, before, after);

    assertEquals(2, merged.getOnes().size());
    One first = merged.getOnes().get(0);
    One second = merged.getOnes().get(1);
    // assertEquals(0, first.getTwo().size());
    assertEquals(1, second.getTwo().size());
    Two mergedTwo = second.getTwo().get(0);
    assertEquals(1, mergedTwo.getThree().size());
    Three mergedThree = mergedTwo.getThree().get(0);
    assertEquals("after", mergedThree.getValue());
  }
コード例 #6
0
ファイル: MergerTest.java プロジェクト: togaurav/transfuse
  @Test
  public void testPreviouslyUntagWritten() throws MergerException {
    List<SubMergeable> subMergeablesOne = new ArrayList<SubMergeable>();
    List<SubMergeable> subMergeablesTwo = new ArrayList<SubMergeable>();

    subMergeablesOne.add(buildSubMergeable("1", "five", "six", false));
    subMergeablesOne.add(buildSubMergeable("2", "nine", "ten", false));
    subMergeablesTwo.add(buildSubMergeable("1", "seven", "eight", true));

    MergeableRoot one = buildMergeableRoot("2", "one", "two", 5, subMergeablesOne, false);
    MergeableRoot two = buildMergeableRoot("2", "three", "four", 6, subMergeablesTwo, true);

    MergeableRoot merged = merger.merge(MergeableRoot.class, one, two);

    assertEquals("one", merged.getDontMerge());
    assertEquals("two", merged.getStringValue());
    assertEquals(5, merged.getIntValue());
    assertEquals(2, merged.getSubMergeables().size());
    SubMergeable subMergeable = buildSubMergeableMap(merged.getSubMergeables()).get("1");
    assertEquals("five", subMergeable.getValue());
    assertEquals("six", subMergeable.getDontMergeValue());
  }