Changeset 2158


Ignore:
Timestamp:
08/28/12 12:11:18 (12 years ago)
Author:
olhsha
Message:

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

Location:
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/RssCreator.java

    r2150 r2158  
    33
    44import clarin.cmdi.componentregistry.model.AbstractDescription;
    5 import clarin.cmdi.componentregistry.model.ProfileDescription;
     5
    66import clarin.cmdi.componentregistry.rss.RssItem;
    77
     
    4040        //retval.setEnclosure(desc.???);
    4141        //retval.setGuid(desc.getId()); type mismatch
    42         retval.setLink(desc.getHref()); //???
     42        retval.setLink(desc.getHref());
    4343        retval.setPubDate(desc.getRegistrationDate());
    4444        //retval.setSource(desc.???);
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/RssCreatorTest.java

    r2150 r2158  
    55package clarin.cmdi.componentregistry;
    66
     7import clarin.cmdi.componentregistry.model.AbstractDescription;
     8import clarin.cmdi.componentregistry.model.ComponentDescription;
     9import clarin.cmdi.componentregistry.model.ProfileDescription;
    710import clarin.cmdi.componentregistry.rss.RssItem;
    811import org.junit.After;
     
    2225    }
    2326   
     27    // ????????????????
    2428    @BeforeClass
    2529    public static void setUpClass() {
     
    4347    @Test
    4448    public void nullTestToRssItem() {
    45         System.out.println("toRssItem");
    46         RssCreator instance = new RssCreator(null);
    47         RssItem expResult = null;
    48         RssItem result = instance.toRssItem();
    49         assertEquals(expResult, result);
    50         // TODO review the generated test code and remove the default call to fail.
    51         // fail("The test case is a prototype.");
     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       
    52131    }
    53132}
Note: See TracChangeset for help on using the changeset viewer.