예제 #1
0
  @Test
  public void testMerge() throws Exception {
    ResValue value1 = new ResValue("value1", null, Quantity.OTHER);
    ResValue value2 = new ResValue("value2", "Comment", Quantity.FEW);
    ResValue value3 = new ResValue("value3", "Comment2", Quantity.ZERO);
    resItem.addValue(value1);
    resItem.addValue(value2);
    resItem.addValue(value3);

    ResItem resItem2 = new ResItem(resItem.key + "_"); // Merge should work independent from res key
    ResValue value4 = new ResValue("value4", null, Quantity.OTHER);
    ResValue value5 = new ResValue("value5", "Comment", Quantity.FEW);
    ResValue value6 = new ResValue("value6", "Comment2", Quantity.TWO);
    resItem2.addValue(value4);
    resItem2.addValue(value5);
    resItem2.addValue(value6);

    assert resItem.merge(resItem2) == resItem;

    assertEquals(4, resItem.values.size());
    assertNotEquals(value1, resItem.valueForQuantity(Quantity.OTHER));
    assertNotEquals(value2, resItem.valueForQuantity(Quantity.FEW));
    assertEquals(value3, resItem.valueForQuantity(Quantity.ZERO));
    assertEquals(value4, resItem.valueForQuantity(Quantity.OTHER));
    assertEquals(value5, resItem.valueForQuantity(Quantity.FEW));
    assertEquals(value6, resItem.valueForQuantity(Quantity.TWO));
  }
예제 #2
0
  @Test
  public void testValueForQuantity() throws Exception {
    ResValue value1 = new ResValue("value1", null, Quantity.MANY);
    ResValue value2 = new ResValue("value2", "Comment", Quantity.FEW);

    resItem.addValue(value1);
    resItem.addValue(value2);

    assertEquals(value1, resItem.valueForQuantity(value1.quantity));
    assertEquals(value2, resItem.valueForQuantity(value2.quantity));
    assertNull(resItem.valueForQuantity(Quantity.ONE));
  }
예제 #3
0
  @Test
  public void testRemove() throws Exception {
    ResValue value1 = new ResValue("value1", null, Quantity.MANY);
    ResValue value2 = new ResValue("value2", "Comment", Quantity.FEW);

    resItem.addValue(value1);
    resItem.addValue(value2);

    assert resItem.removeValue(value1);
    assertEquals(1, resItem.values.size());
    assertNull(resItem.valueForQuantity(value1.quantity));
    assertEquals(value2, resItem.valueForQuantity(value2.quantity));
    assertEquals(value2, resItem.values.get(0));

    assert !resItem.removeValue(value1);
    assertEquals(1, resItem.values.size());
    assertEquals(value2, resItem.valueForQuantity(value2.quantity));
    assertEquals(value2, resItem.values.get(0));
  }