Changeset 5554


Ignore:
Timestamp:
08/15/14 17:22:12 (10 years ago)
Author:
olhsha@mpi.nl
Message:

Adding transfer owner ship and fixing the method

File:
1 edited

Legend:

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

    r5553 r5554  
    150150    }
    151151   
     152     private void MakeGroupC() throws ItemNotFoundException{
     153        groupService.createNewGroup("group C", "anotherPrincipal");
     154    }
     155   
    152156     private void fillUpGroupB() throws ParseException, JAXBException, ItemNotFoundException{
    153157         
     
    171175        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-2");
    172176        ownership.setGroupId(2);
     177        ownership.setUserId(0);
     178        groupService.addOwnership(ownership);
     179       
     180    }
     181     
     182     private void fillUpGroupC() throws ParseException, JAXBException, ItemNotFoundException{
     183         
     184        MakeGroupC();
     185       
     186        RegistryTestHelper.addProfile(baseRegistry, "Cprofile-1", false);
     187        RegistryTestHelper.addComponent(baseRegistry, "Ccomponent-1", false);
     188        RegistryTestHelper.addComponent(baseRegistry, "Ccomponent-2", false);
     189       
     190        Ownership ownership = new Ownership();
     191        ownership.setComponentId(ProfileDescription.PROFILE_PREFIX+"Cprofile-1");
     192        ownership.setGroupId(3);
     193        ownership.setUserId(0);
     194        groupService.addOwnership(ownership);
     195       
     196        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1");
     197        ownership.setGroupId(3);
     198        ownership.setUserId(0);
     199        groupService.addOwnership(ownership);
     200       
     201        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"Ccomponent-2");
     202        ownership.setGroupId(3);
    173203        ownership.setUserId(0);
    174204        groupService.addOwnership(ownership);
     
    187217        assertEquals("Group with the name newGroup is created and given an id 1", cr.getEntity(String.class));
    188218    }
     219   
     220   
    189221   
    190222   
     
    223255        MakeGroupA();
    224256        MakeGroupB();
    225        
    226257        // test itself
    227258       
     
    330361        MakeGroupA();
    331362        MakeGroupB();
    332        
    333363        // test itself
    334364       
     
    427457//   
    428458
     459    @Test
     460    public void testTransferOwnership() throws Exception{
     461        System.out.println("test makeTransferOwnership");
     462       
     463        fillUpGroupA();
     464        fillUpGroupB();       
     465        fillUpGroupC();
     466        // test itself
     467       
     468       
     469       RegistryTestHelper.addComponent(baseRegistry, "test_component", false);
     470       RegistryTestHelper.addProfile(baseRegistry, "test_profile", false);
     471       String test_profile_id = ProfileDescription.PROFILE_PREFIX+"test_profile";
     472       String test_component_id = ComponentDescription.COMPONENT_PREFIX+"test_component";
     473       //I'm not a member
     474       ClientResponse cr  = this.getAuthenticatedResource(getResource()
     475                .path("/registry/items/"+test_profile_id+"/transferownership").queryParam("groupId", "3")).accept(MediaType.APPLICATION_XML).post(ClientResponse.class);
     476       assertEquals(403, cr.getStatus());
     477       
     478       //make me a member
     479       groupService.makeMember(DummyPrincipal.DUMMY_PRINCIPAL.getName(), "group C");
     480       assertTrue(groupService.userGroupMember(DummyPrincipal.DUMMY_PRINCIPAL.getName(), "3"));
     481       
     482       cr  = this.getAuthenticatedResource(getResource()
     483                .path("/registry/items/"+test_profile_id+"/transferownership").queryParam("groupId", "3")).accept(MediaType.APPLICATION_XML).post(ClientResponse.class);
     484       assertEquals(200, cr.getStatus());
     485       cr  = this.getAuthenticatedResource(getResource()
     486                .path("/registry/items/"+test_component_id+"/transferownership").queryParam("groupId", "3")).accept(MediaType.APPLICATION_XML).post(ClientResponse.class);
     487       assertEquals(200, cr.getStatus());
     488       
     489       
     490       List<String> components = groupService.getComponentIdsInGroup(3);
     491       assertEquals(3, components.size());
     492       assertEquals(test_component_id, components.get(2));
     493       List<String> profiles = groupService.getProfileIdsInGroup(3);
     494       assertEquals(2, profiles.size());
     495       assertEquals(test_profile_id, profiles.get(1));
     496       
     497    }
     498   
    429499
    430500}
Note: See TracChangeset for help on using the changeset viewer.