PageRenderTime 16ms CodeModel.GetById 7ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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