Exemplo n.º 1
0
  @Test
  public void testRemoveCategory() throws Exception {
    categoryDao.save(category);

    Category cat = categoryDao.findOne(category.getId());
    assertNotNull(cat.getId());
    assertEquals(category, cat);

    categoryDao.delete(category.getId());
    assertTrue(getIterableSize(categoryDao.findAll()) == 0);
  }
Exemplo n.º 2
0
  @Test
  public void testUpdateCategory() throws Exception {
    categoryDao.save(category);
    category.setName(CATEGOY_NAME + "MDF");
    category.setDescription(CATEGORY_DESCRIPTION + "MDF");
    categoryDao.save(category); // pourquoi on fait deux fois save?
    // Est-ce que c'est parce que la premiere va faire un create, et la 2nd un update?

    Category categorymdf = categoryDao.findOne(category.getId());
    assertEquals(category, categorymdf);
  }
Exemplo n.º 3
0
  @Test
  public void testGetCategories() throws Exception {
    categoryDao.save(category);

    Iterable<Category> lst = categoryDao.findAll();
    assertTrue(getIterableSize(lst) == 1);

    // Adding a second element
    Category cat2 = new Category();
    cat2.setName(CATEGOY_NAME + "2");
    cat2.setDescription(CATEGORY_DESCRIPTION + "2");
    cat2.setId((long) 882880);
    categoryDao.save(cat2);

    // Verifying that the second element has been added
    assertTrue(getIterableSize(categoryDao.findAll()) == 2);
  }
Exemplo n.º 4
0
  @Test
  public void testGetCategory() throws Exception {
    categoryDao.save(category);

    Category cat = categoryDao.findOne(category.getId());
    assertNotNull(cat);
    assertEquals(category, cat);
  }
Exemplo n.º 5
0
 /** create an instanciated object. The one declared as private field in the test class */
 private void loadCategory() {
   category = new Category();
   category.setId(new Random().nextLong());
   category.setName(ConstantUtils.CATEGOY_NAME);
   category.setDescription(ConstantUtils.CATEGORY_DESCRIPTION);
 }
Exemplo n.º 6
0
 @Test
 public void testCreateCategory() throws Exception {
   categoryDao.save(category);
   assertTrue("Category assigned primary key", category.getId() != null);
 }