Changeset 5554
- Timestamp:
- 08/15/14 17:22:12 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java
r5553 r5554 150 150 } 151 151 152 private void MakeGroupC() throws ItemNotFoundException{ 153 groupService.createNewGroup("group C", "anotherPrincipal"); 154 } 155 152 156 private void fillUpGroupB() throws ParseException, JAXBException, ItemNotFoundException{ 153 157 … … 171 175 ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-2"); 172 176 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); 173 203 ownership.setUserId(0); 174 204 groupService.addOwnership(ownership); … … 187 217 assertEquals("Group with the name newGroup is created and given an id 1", cr.getEntity(String.class)); 188 218 } 219 220 189 221 190 222 … … 223 255 MakeGroupA(); 224 256 MakeGroupB(); 225 226 257 // test itself 227 258 … … 330 361 MakeGroupA(); 331 362 MakeGroupB(); 332 333 363 // test itself 334 364 … … 427 457 // 428 458 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 429 499 430 500 }
Note: See TracChangeset
for help on using the changeset viewer.