@Before
  public void setUp() throws Exception {
    Category category_one = new Category();
    Category category_two = new Category();
    category_one.setName("Breakfast");
    category_one.setName("Dinner");

    SessionFactory factory = new Configuration().configure().buildSessionFactory();
    Session session = factory.openSession();
    Transaction transaction = session.beginTransaction();
    session.save(category_one);
    session.save(category_two);
    transaction.commit();
    session.close();
  }
  @Before
  public void setUp() {
    category1 = new Category();
    category1.setId(1L);
    category1.setColor("#ffffff");
    category1.setCount(10);
    category1.setDescription("first cat description");
    category1.setName("first cat name");

    category2 = new Category();
    category2.setId(2L);
    category2.setColor("#000000");
    category2.setCount(5);
    category2.setDescription("second cat description");
    category2.setName("second cat name");
  }
 @Test
 public void itUpdatesCategory() {
   Category category = categoryDAO.find((long) 1);
   category.setName("Salads");
   categoryDAO.update(category);
   assertEquals("Salads", categoryDAO.find((long) 1).getName());
 }
 @Test
 public void itAddsNewCategories() {
   Category category = new Category();
   category.setName("Salads");
   categoryDAO.create(category);
   assertEquals("Salads", categoryDAO.find((long) 3).getName());
 }
  @Test
  public void listContainsNote() {
    List<Category> categories = new ArrayList<>();
    categories.add(category1);
    categories.add(category2);
    assertTrue(categories.contains(category2));
    assertTrue(categories.contains(category1));

    Category newCategory = new Category();
    newCategory.setName("newCat");
    newCategory.setDescription("newCat desc");
    newCategory.setColor("#cccccc");
    assertFalse(categories.contains(newCategory));
  }
Пример #6
0
  private Pet createRandomPet() {
    Pet pet = new Pet();
    pet.setId(TestUtils.nextId());
    pet.setName("gorilla");

    Category category = new Category();
    category.setName("really-happy");

    pet.setCategory(category);
    pet.setStatus(Pet.StatusEnum.AVAILABLE);
    List<String> photos =
        Arrays.asList(new String[] {"http://foo.bar.com/1", "http://foo.bar.com/2"});
    pet.setPhotoUrls(photos);

    return pet;
  }