Ignore:
Timestamp:
08/18/14 14:48:56 (10 years ago)
Author:
olhsha@mpi.nl
Message:

Unit test for getting rss of profiles and components from groups, and their comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java

    r5560 r5561  
    1717import clarin.cmdi.componentregistry.persistence.jpa.CommentsDao;
    1818import clarin.cmdi.componentregistry.persistence.jpa.UserDao;
     19import clarin.cmdi.componentregistry.rss.Rss;
    1920import com.sun.jersey.api.client.ClientResponse;
    2021import java.text.ParseException;
     
    207208   
    208209    @Test
    209     public void testGetGroupComments() throws Exception {
    210 
    211         System.out.println("test getGroupComments");
     210    public void testGetGroupRss() throws Exception {
     211
     212        System.out.println("test getGroupRss");
    212213
    213214        fillUpGroupA();
     
    215216        fillUpGroupC();
    216217
     218       
     219         // lists of profiles and components
     220       
     221        Rss response = this.getAuthenticatedResource(getResource()
     222                .path("/registry/profiles/rss").queryParam("registrySpace", "group").queryParam("groupid", "1")).accept(MediaType.APPLICATION_XML)
     223                .get(Rss.class);
     224        assertEquals(1, response.getChannel().getItem().size());
     225       
     226         response = this.getAuthenticatedResource(getResource()
     227                .path("/registry/components/rss").queryParam("registrySpace", "group").queryParam("groupid", "1")).accept(MediaType.APPLICATION_XML)
     228                .get(Rss.class);
     229        assertEquals(2, response.getChannel().getItem().size());
     230       
     231        response = this.getAuthenticatedResource(getResource()
     232                .path("/registry/profiles/rss").queryParam("registrySpace", "group").queryParam("groupid", "2")).accept(MediaType.APPLICATION_XML)
     233                .get(Rss.class);
     234        assertEquals(1, response.getChannel().getItem().size());
     235       
     236        response = this.getAuthenticatedResource(getResource()
     237                .path("/registry/components/rss").queryParam("registrySpace", "group").queryParam("groupid", "2")).accept(MediaType.APPLICATION_XML)
     238                .get(Rss.class);
     239        assertEquals(2, response.getChannel().getItem().size());
     240       
     241        ClientResponse clientResponse = this.getAuthenticatedResource(getResource()
     242                .path("/registry/components").queryParam("registrySpace", "group").queryParam("groupid", "3")).accept(MediaType.APPLICATION_XML)
     243                .get(ClientResponse.class);
     244       
     245        assertEquals(403, clientResponse.getStatus());
    217246       
    218247        RegistryTestHelper.addComment(baseRegistry, "COMMENTc1",  ComponentDescription.COMPONENT_PREFIX + "component-1",
     
    231260                // lists
    232261       
    233         List<Comment> response = this.getAuthenticatedResource(getResource()
    234                 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1" + "/comments/"))
    235                 .accept(MediaType.APPLICATION_XML)
    236                 .get(COMMENT_LIST_GENERICTYPE);       
    237         assertEquals(1, response.size());
    238        
    239         response = this.getAuthenticatedResource(getResource()
    240                 .path("/registry/components/" + ProfileDescription.PROFILE_PREFIX + "profile-1" + "/comments/"))
    241                 .accept(MediaType.APPLICATION_XML)
    242                 .get(COMMENT_LIST_GENERICTYPE);       
    243         assertEquals(1, response.size());
    244        
    245         response = this.getAuthenticatedResource(getResource()
    246                 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1" + "/comments/"))
    247                 .accept(MediaType.APPLICATION_XML)
    248                 .get(COMMENT_LIST_GENERICTYPE);       
    249         assertEquals(1, response.size());
    250        
    251         response = this.getAuthenticatedResource(getResource()
    252                 .path("/registry/components/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1" + "/comments/"))
    253                 .accept(MediaType.APPLICATION_XML)
    254                 .get(COMMENT_LIST_GENERICTYPE);       
    255         assertEquals(1, response.size());
    256        
    257        
    258    
    259         ClientResponse clientResponse = this.getAuthenticatedResource(getResource()
    260                 .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1"))
     262        response = this.getAuthenticatedResource(getResource()
     263                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1" + "/comments/rss"))
     264                .accept(MediaType.APPLICATION_XML)
     265                .get(Rss.class);       
     266        assertEquals(1, response.getChannel().getItem().size());
     267       
     268        response = this.getAuthenticatedResource(getResource()
     269                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1" + "/comments/rss"))
     270                .accept(MediaType.APPLICATION_XML)
     271                .get(Rss.class);       
     272        assertEquals(1, response.getChannel().getItem().size());
     273       
     274        response = this.getAuthenticatedResource(getResource()
     275                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1" + "/comments/rss"))
     276                .accept(MediaType.APPLICATION_XML)
     277                .get(Rss.class);       
     278        assertEquals(1, response.getChannel().getItem().size());
     279       
     280        response = this.getAuthenticatedResource(getResource()
     281                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1" + "/comments/rss"))
     282                .accept(MediaType.APPLICATION_XML)
     283                .get(Rss.class);       
     284        assertEquals(1, response.getChannel().getItem().size());
     285       
     286       
     287   
     288        clientResponse = this.getAuthenticatedResource(getResource()
     289                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1/comments/rss"))
    261290                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    262291        assertEquals(403, clientResponse.getStatus());
    263292       
    264293         clientResponse = this.getAuthenticatedResource(getResource()
    265                 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1"))
     294                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1/comments/rss"))
    266295                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    267296        assertEquals(403, clientResponse.getStatus());
Note: See TracChangeset for help on using the changeset viewer.