Package com.ap.givemetheprice.bean.item

Examples of com.ap.givemetheprice.bean.item.Item


public class ItemFactoryTest {
 
  @Test
  public void createNotTaxedAndNotImportedItem() {
    Item book = ItemFactory.getItem(ItemType.BOOKS, "Vite da un giorno", 1, false, new BigDecimal("12.49"));
    Assert.assertTrue(book instanceof NotTaxedItem);
    Assert.assertEquals(ItemType.BOOKS, book.getType());
    Assert.assertEquals("Vite da un giorno", book.getName());
    Assert.assertEquals(1, book.getQuantity());
    Assert.assertEquals(false, book.isImported());
    Assert.assertEquals(new BigDecimal("12.49"), book.getPrice());
    Assert.assertEquals(new BigDecimal("0"), book.getSalesTaxes());
    Assert.assertEquals(Utils.applyRound(new BigDecimal("12.49")), book.getTotalPrice());
    book = null;
  }
View Full Code Here


public class ItemFactory {

  //create an item see enumeration for items type
  public static Item getItem(ItemType type, String name, int quantity, boolean imported, BigDecimal price) {
       
    Item item = null;
       
    switch (type) {
          case OTHERS:
            item = new TaxedItem(type, name, quantity, imported, price);
            break;
View Full Code Here

    book = null;
  }
 
  @Test
  public void createNotTaxedAndImportedItem() {
    Item book = ItemFactory.getItem(ItemType.BOOKS, "Vite da un giorno", 1, true, new BigDecimal("12.00"));
    Assert.assertTrue(book instanceof NotTaxedItem);
    Assert.assertEquals(ItemType.BOOKS, book.getType());
    Assert.assertEquals("Vite da un giorno", book.getName());
    Assert.assertEquals(1, book.getQuantity());
    Assert.assertTrue(book.isImported());
    Assert.assertEquals(new BigDecimal("12.00"), book.getPrice());
    Assert.assertEquals(Utils.applyRound(new BigDecimal("0.60")), book.getSalesTaxes());
    Assert.assertEquals(Utils.applyRound(new BigDecimal("12.60")), book.getTotalPrice());
    book = null;
  }
View Full Code Here

    book = null;
  }
 
  @Test
  public void createTaxedAndNotImportedItem() {
    Item cd = ItemFactory.getItem(ItemType.OTHERS, "Music CD", 1, false, new BigDecimal("14.99"));
    Assert.assertTrue(cd instanceof TaxedItem);
    Assert.assertEquals(ItemType.OTHERS, cd.getType());
    Assert.assertEquals("Music CD", cd.getName());
    Assert.assertEquals(1, cd.getQuantity());
    Assert.assertFalse(cd.isImported());
    Assert.assertEquals(new BigDecimal("14.99"), cd.getPrice());
    Assert.assertEquals(Utils.applyRound(new BigDecimal("1.50")), cd.getSalesTaxes());
    Assert.assertEquals(Utils.applyRound(new BigDecimal("16.49")), cd.getTotalPrice());
    cd = null;
  }
View Full Code Here

    cd = null;
  }
 
  @Test
  public void createTaxedAndImportedItem() {
    Item bottle = ItemFactory.getItem(ItemType.OTHERS, "Imported bottle of perfume", 1, true, new BigDecimal("27.99"));
    Assert.assertTrue(bottle instanceof TaxedItem);
    Assert.assertEquals(ItemType.OTHERS, bottle.getType());
    Assert.assertEquals("Imported bottle of perfume", bottle.getName());
    Assert.assertEquals(1, bottle.getQuantity());
    Assert.assertTrue(bottle.isImported());
    Assert.assertEquals(new BigDecimal("27.99"), bottle.getPrice());
    Assert.assertEquals(Utils.applyRound(new BigDecimal("4.20")), bottle.getSalesTaxes());
    Assert.assertEquals(Utils.applyRound(new BigDecimal("32.19")), bottle.getTotalPrice());
    bottle = null
  }
View Full Code Here

TOP

Related Classes of com.ap.givemetheprice.bean.item.Item

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.