/src/test/java/com/google/ie/business/dao/impl/IdeaCategoryDaoImplTest.java

http://thoughtsite.googlecode.com/ · Java · 67 lines · 47 code · 13 blank · 7 comment · 0 complexity · b0507f8bee13709a27c1c82ce9ea3c4b MD5 · raw file

  1. // Copyright 2009 Google Inc. All Rights Reserved.
  2. package com.google.ie.business.dao.impl;
  3. import static org.junit.Assert.assertEquals;
  4. import static org.junit.Assert.assertNotNull;
  5. import com.google.ie.business.domain.IdeaCategory;
  6. import com.google.ie.test.DatastoreTest;
  7. import org.junit.Before;
  8. import org.junit.Test;
  9. import java.util.List;
  10. /**
  11. * Test case for IdeaCategoryDaoImpl class
  12. *
  13. * @author Sachneet
  14. *
  15. */
  16. public class IdeaCategoryDaoImplTest extends DatastoreTest {
  17. IdeaCategoryDaoImpl categoryDaoImpl = null;
  18. @Before
  19. public void setUp() {
  20. super.setUp();
  21. this.categoryDaoImpl = new IdeaCategoryDaoImpl();
  22. this.categoryDaoImpl.setPersistenceManagerFactory(pmf);
  23. }
  24. @Test
  25. public void getCategories() {
  26. IdeaCategory expectedCategory = new IdeaCategory();
  27. expectedCategory.setName("CategoryTest");
  28. categoryDaoImpl.saveIdeaCategory(expectedCategory);
  29. List<IdeaCategory> listOfCategoryObjects =
  30. categoryDaoImpl.getIdeaCategories();
  31. assertNotNull(listOfCategoryObjects);
  32. IdeaCategory actualCategory = listOfCategoryObjects.get(0);
  33. assertEquals(expectedCategory.getName(), actualCategory.getName());
  34. }
  35. @Test
  36. public void saveCategory() {
  37. IdeaCategory expectedCategory = new IdeaCategory();
  38. expectedCategory.setName("CategoryTest");
  39. IdeaCategory actualCategory =
  40. categoryDaoImpl.saveIdeaCategory(expectedCategory);
  41. assertNotNull(actualCategory);
  42. assertEquals(expectedCategory.getName(), actualCategory.getName());
  43. }
  44. @Test
  45. public void getCategoryByName() {
  46. IdeaCategory expectedCategory = new IdeaCategory();
  47. expectedCategory.setName("CategoryTest");
  48. categoryDaoImpl.saveIdeaCategory(expectedCategory);
  49. IdeaCategory actualCategory =
  50. categoryDaoImpl.getCategoryByName(expectedCategory.getName());
  51. assertNotNull(actualCategory);
  52. assertEquals(expectedCategory.getName(), actualCategory.getName());
  53. }
  54. }