Ignore:
Timestamp:
08/18/14 09:50:16 (10 years ago)
Author:
olhsha@mpi.nl
Message:

Unit test for getting profiles and components from groups. A little bug is fixed

File:
1 edited

Legend:

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

    r5554 r5556  
    88import clarin.cmdi.componentregistry.ComponentRegistryFactory;
    99import clarin.cmdi.componentregistry.ItemNotFoundException;
     10import clarin.cmdi.componentregistry.components.CMDComponentSpec;
    1011import clarin.cmdi.componentregistry.impl.database.ComponentRegistryTestDatabase;
    1112import clarin.cmdi.componentregistry.impl.database.GroupService;
     
    184185        MakeGroupC();
    185186       
    186         RegistryTestHelper.addProfile(baseRegistry, "Cprofile-1", false);
    187         RegistryTestHelper.addComponent(baseRegistry, "Ccomponent-1", false);
    188         RegistryTestHelper.addComponent(baseRegistry, "Ccomponent-2", false);
     187        RegistryTestHelper.addProfileAnotherPrincipal(baseRegistry, "Cprofile-1", false);
     188        RegistryTestHelper.addComponentAnotherPrincipal(baseRegistry, "Ccomponent-1", false);
     189        RegistryTestHelper.addComponentAnotherPrincipal(baseRegistry, "Ccomponent-2", false);
    189190       
    190191        Ownership ownership = new Ownership();
     
    497498    }
    498499   
     500    @Test
     501    public void testGetGroupProfilesAndComponents() throws Exception {
     502
     503        System.out.println("test getGroupProfiles");
     504
     505        fillUpGroupA();
     506        fillUpGroupB();       
     507        fillUpGroupC();
     508
     509       
     510        List<ProfileDescription> response = this.getAuthenticatedResource(getResource()
     511                .path("/registry/profiles").queryParam("registrySpace", "group").queryParam("groupid", "1")).accept(MediaType.APPLICATION_XML)
     512                .get(PROFILE_LIST_GENERICTYPE);
     513        assertEquals(1, response.size());
     514       
     515        List<ComponentDescription> responseC = this.getAuthenticatedResource(getResource()
     516                .path("/registry/components").queryParam("registrySpace", "group").queryParam("groupid", "1")).accept(MediaType.APPLICATION_XML)
     517                .get(COMPONENT_LIST_GENERICTYPE);
     518        assertEquals(2, responseC.size());
     519       
     520        response = this.getAuthenticatedResource(getResource()
     521                .path("/registry/profiles").queryParam("registrySpace", "group").queryParam("groupid", "2")).accept(MediaType.APPLICATION_XML)
     522                .get(PROFILE_LIST_GENERICTYPE);
     523        assertEquals(1, response.size());
     524       
     525        responseC = this.getAuthenticatedResource(getResource()
     526                .path("/registry/components").queryParam("registrySpace", "group").queryParam("groupid", "2")).accept(MediaType.APPLICATION_XML)
     527                .get(COMPONENT_LIST_GENERICTYPE);
     528        assertEquals(2, responseC.size());
     529       
     530        ClientResponse clientResponse = this.getAuthenticatedResource(getResource()
     531                .path("/registry/components").queryParam("registrySpace", "group").queryParam("groupid", "3")).accept(MediaType.APPLICATION_XML)
     532                .get(ClientResponse.class);
     533       
     534        assertEquals(403, clientResponse.getStatus());
     535       
     536       
     537        CMDComponentSpec component = this.getAuthenticatedResource(getResource()
     538                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"profile-1"))
     539                .accept(MediaType.APPLICATION_JSON).get(CMDComponentSpec.class);
     540        assertNotNull(component);
     541        assertEquals("Actor", component.getCMDComponent().getName());
     542   
     543        component = this.getAuthenticatedResource(getResource()
     544                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"component-1"))
     545                .accept(MediaType.APPLICATION_JSON).get(CMDComponentSpec.class);
     546        assertNotNull(component);
     547        assertEquals("Access", component.getCMDComponent().getName());
     548   
     549        component = this.getAuthenticatedResource(getResource()
     550                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1"))
     551                .accept(MediaType.APPLICATION_JSON).get(CMDComponentSpec.class);
     552        assertNotNull(component);
     553        assertEquals("Actor", component.getCMDComponent().getName());
     554   
     555        component = this.getAuthenticatedResource(getResource()
     556                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1"))
     557                .accept(MediaType.APPLICATION_JSON).get(CMDComponentSpec.class);
     558        assertNotNull(component);
     559        assertEquals("Access", component.getCMDComponent().getName());
     560   
     561        clientResponse = this.getAuthenticatedResource(getResource()
     562                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1"))
     563                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
     564        assertEquals(403, clientResponse.getStatus());
     565       
     566         clientResponse = this.getAuthenticatedResource(getResource()
     567                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1"))
     568                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
     569        assertEquals(403, clientResponse.getStatus());
     570       
     571    }
    499572
    500573}
Note: See TracChangeset for help on using the changeset viewer.