Пример #1
0
  @Test
  public void testGetItemByIdWhenItemExists() {
    StockItem stockItem = new StockItem((long) 771123, "Odav toode", "Odavad tooted", 0.5, 10);
    model.addItem(stockItem);

    assertEquals(stockItem, model.getItemById(stockItem.getId()));
  }
Пример #2
0
  @Test
  public void testHasEnoughInStock() {
    StockItem stockItem =
        new StockItem((long) 198237645, "Suvaline toode", "Suvaline tootegrupp", 100, 25);
    model.addItem(stockItem);

    assertTrue(model.getItemByName("Suvaline toode").getQuantity() >= stockItem.getQuantity());
  }
Пример #3
0
  @Test
  public void testGetColumn() {
    StockItem stockItem = new StockItem((long) 771123, "Odav toode", "Odavad tooted", 0.5, 10);
    model.addItem(stockItem);

    assertEquals(stockItem.getId(), model.getColumnValue(stockItem, 0));
    assertEquals(stockItem.getName(), model.getColumnValue(stockItem, 1));
    assertEquals(stockItem.getPrice(), model.getColumnValue(stockItem, 2));
    assertEquals(stockItem.getQuantity(), model.getColumnValue(stockItem, 3));
  }
Пример #4
0
  @Test
  public void testValidateIDUniqueness() {
    StockItem stockItem =
        new StockItem((long) 246819, "Suvaline toode", "Suvaline tootegrupp", 100, 25);
    StockItem stockItem2 =
        new StockItem((long) 246819, "Suvaline toode2", "Suvaline tootegrupp2", 50, 30);
    model.addItem(stockItem);
    model.addItem(stockItem2);

    assertEquals(25, model.getItemById(stockItem.getId()).getQuantity());
  }
Пример #5
0
  @Test
  public void testValidateNameUniqueness() {
    StockItem stockItem =
        new StockItem((long) 7162534, "Suvaline toode", "Suvaline tootegrupp", 100, 25);
    StockItem stockItem2 =
        new StockItem((long) 1726354, "Suvaline toode", "Suvaline tootegrupp", 50, 30);
    model.addItem(stockItem);
    model.addItem(stockItem2);

    assertEquals(25, model.getItemByName("Suvaline toode").getQuantity());
  }
Пример #6
0
 @Test(expected = NoSuchElementException.class)
 public void testGetItemByIdWhenThrowsException() {
   model.getItemById(646546);
 }