コード例 #1
0
  @Test
  public void createTOFromProductTest() {
    Product product = new Product("name", 1.0);
    ProductTO productTO = productTOUtils.createProductTO(product);

    assertNotNull("ProductTO was not created", productTO);

    assertEquals(
        "productTO.name do not match with product.name", product.getName(), productTO.getName());
    assertEquals(
        "productTO.price do not match with product.price",
        BigDecimal.valueOf(product.getPrice()),
        BigDecimal.valueOf(productTO.getPrice()));
  }
コード例 #2
0
  @Test
  public void createTOWithSettersTest() {
    productTOUtils.prepareProductTO();
    productTOUtils.setProductName("Test");
    productTOUtils.setProductPrice(5.0);

    ProductTO productTO = productTOUtils.createProductTO();

    assertNotNull("ProductTO was not created", productTO);

    assertEquals("productTO.name do not match", "Test", productTO.getName());
    assertEquals(
        "productTO.price do not match",
        BigDecimal.valueOf(5.0),
        BigDecimal.valueOf(productTO.getPrice()));
  }
コード例 #3
0
  @Test
  public void margeTosTest() {
    Product product1 = new Product("Test1", 5.0);
    productTOUtils.prepareProductTO();
    productTOUtils.setProductName("Test2");
    productTOUtils.setProductPrice(null);

    ProductTO productTO1 = productTOUtils.createProductTO();
    ProductTO productTO2 = productTOUtils.createProductTO(product1);

    ProductTO productTO3 = productTOUtils.marge(productTO1, productTO2);

    assertEquals("Marge data do not math", "Test1", productTO3.getName());
    assertEquals(
        "Marge data do not math",
        BigDecimal.valueOf(5.0),
        BigDecimal.valueOf(productTO3.getPrice()));
  }