source: ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/RssCreatorTest.java @ 2158

Last change on this file since 2158 was 2158, checked in by olhsha, 12 years ago

# 181 is a sort of fixed and tested. Next: make tests with input/output streams and files, then -- with a server (howto???)

File size: 3.7 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package clarin.cmdi.componentregistry;
6
7import clarin.cmdi.componentregistry.model.AbstractDescription;
8import clarin.cmdi.componentregistry.model.ComponentDescription;
9import clarin.cmdi.componentregistry.model.ProfileDescription;
10import clarin.cmdi.componentregistry.rss.RssItem;
11import org.junit.After;
12import org.junit.AfterClass;
13import org.junit.Before;
14import org.junit.BeforeClass;
15import org.junit.Test;
16import static org.junit.Assert.*;
17
18/**
19 *
20 * @author olhsha
21 */
22public class RssCreatorTest {
23   
24    public RssCreatorTest() {
25    }
26   
27    // ????????????????
28    @BeforeClass
29    public static void setUpClass() {
30    }
31   
32    @AfterClass
33    public static void tearDownClass() {
34    }
35   
36    @Before
37    public void setUp() {
38    }
39   
40    @After
41    public void tearDown() {
42    }
43
44    /**
45     * Test of toRssItem method, of class RssCreator.
46     */
47    @Test
48    public void nullTestToRssItem() {
49       
50        RssCreator creator = new RssCreator(null);
51        RssItem result = creator.toRssItem();
52        assertEquals(null, result);
53       
54    }
55   
56   
57   
58    private ProfileDescription createTestProfileDescription(int commentcount, String creatorname, 
59    String description, String domainname, String groupname, String href, 
60    String name, boolean editorflag, String uid){
61       
62        ProfileDescription pdesc = ProfileDescription.createNewDescription();
63       
64        pdesc.setCommentsCount(commentcount);
65        pdesc.setCreatorName(creatorname);
66        pdesc.setDescription(description);
67        pdesc.setDomainName(domainname);
68        pdesc.setGroupName(groupname);
69        pdesc.setHref(href);
70        pdesc.setName(name);
71        pdesc.setShowInEditor(editorflag);
72        pdesc.setUserId(uid);
73       
74        return pdesc;
75       
76       
77    }
78   
79    private ComponentDescription createTestComponentDescription(int commentcount, String creatorname, 
80    String description, String domainname, String groupname, String href, 
81    String name, String uid){
82       
83        ComponentDescription cdesc = ComponentDescription.createNewDescription();
84       
85        cdesc.setCommentsCount(commentcount);
86        cdesc.setCreatorName(creatorname);
87        cdesc.setDescription(description);
88        cdesc.setDomainName(domainname);
89        cdesc.setGroupName(groupname);
90        cdesc.setHref(href);
91        cdesc.setName(name);
92        cdesc.setUserId(uid);
93       
94        return cdesc;
95       
96       
97    }
98   
99    private void assertEqualDescriptions(AbstractDescription desc, RssItem item){
100        assertEquals(desc.getCreatorName(), item.getAuthor());
101        assertEquals(desc.getDescription(), item.getDescription());
102        assertEquals(desc.getHref(), item.getLink());
103        assertEquals(desc.getRegistrationDate(), item.getPubDate());
104        assertEquals(desc.getName(), item.getTitle());
105    }
106   
107    @Test
108    public void profileTestToRssItem() {
109       
110        ProfileDescription pdesc=
111                createTestProfileDescription(23, "creatorname", 
112                "description", "domainname", "groupname", "href", "name", true, "uid");
113       
114        RssCreator creator = new RssCreator(pdesc);
115        RssItem result = creator.toRssItem();
116        assertEqualDescriptions(pdesc, result);
117       
118    }
119   
120    @Test
121    public void componentTestToRssItem() {
122       
123        ComponentDescription cdesc=
124                createTestComponentDescription(67, "creatorname", 
125                "description", "domainname", "groupname", "href", "name", "uid");
126       
127        RssCreator creator = new RssCreator(cdesc);
128        RssItem result = creator.toRssItem();
129        assertEqualDescriptions(cdesc, result);
130       
131    }
132}
Note: See TracBrowser for help on using the repository browser.