Changeset 1894
- Timestamp:
- 04/20/12 07:51:13 (12 years ago)
- Location:
- ComponentRegistry/trunk/ComponentRegistry/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
r1892 r1894 312 312 @POST 313 313 @Path("/profiles/{profileId}/comments/{commentId}") 314 public Response manipulateCommentFromProfile(@PathParam("profileId") String profileId, @PathParam(" profileId") String commentId, @FormParam("method") String method,314 public Response manipulateCommentFromProfile(@PathParam("profileId") String profileId, @PathParam("commentId") String commentId, @FormParam("method") String method, 315 315 @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) { 316 316 if ("delete".equalsIgnoreCase(method)) { … … 323 323 @POST 324 324 @Path("/components/{componentId}/comments/{commentId}") 325 public Response manipulateCommentFromComponent(@PathParam("componentId") String componentId, @PathParam(" profileId") String commentId, @FormParam("method") String method,325 public Response manipulateCommentFromComponent(@PathParam("componentId") String componentId, @PathParam("commentId") String commentId, @FormParam("method") String method, 326 326 @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) { 327 327 if ("delete".equalsIgnoreCase(method)) { -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTest.java
r1870 r1894 14 14 import com.sun.jersey.api.client.ClientResponse; 15 15 import com.sun.jersey.api.client.UniformInterfaceException; 16 import com.sun.jersey.api.representation.Form; 16 17 import com.sun.jersey.multipart.FormDataMultiPart; 17 18 import java.io.ByteArrayInputStream; … … 225 226 226 227 @Test 228 public void testManipulateCommentFromComponent() throws Exception { 229 fillUp(); 230 List<Comment> comments = getResource().path("/registry/components/clarin.eu:cr1:component1/comments").get(COMMENT_LIST_GENERICTYPE); 231 assertEquals(2, comments.size()); 232 Comment aComment = getResource().path("/registry/components/clarin.eu:cr1:component1/comments/2").get(Comment.class); 233 assertNotNull(aComment); 234 235 Form manipulateForm = new Form(); 236 manipulateForm.add("method", "delete"); 237 238 // Try to delete from other component 239 ClientResponse response = getAuthenticatedResource("/registry/components/clarin.eu:cr1:component1/comments/2").post(ClientResponse.class, manipulateForm); 240 assertEquals(200, response.getStatus()); 241 242 comments = getResource().path("/registry/components/clarin.eu:cr1:component1/comments/").get(COMMENT_LIST_GENERICTYPE); 243 assertEquals(1, comments.size()); 244 } 245 246 @Test 227 247 public void testDeleteCommentFromProfile() throws Exception { 228 248 fillUp(); … … 247 267 comments = getResource().path("/registry/profiles/clarin.eu:cr1:profile1/comments").get(COMMENT_LIST_GENERICTYPE); 248 268 assertEquals(0, comments.size()); 269 } 270 271 @Test 272 public void testManipulateCommentFromProfile() throws Exception { 273 fillUp(); 274 List<Comment> comments = getResource().path("/registry/profiles/clarin.eu:cr1:profile1/comments").get(COMMENT_LIST_GENERICTYPE); 275 assertEquals(2, comments.size()); 276 Comment aComment = getResource().path("/registry/profiles/clarin.eu:cr1:profile1/comments/0").get(Comment.class); 277 assertNotNull(aComment); 278 279 Form manipulateForm = new Form(); 280 manipulateForm.add("method", "delete"); 281 // Delete from correct profile 282 ClientResponse response = getAuthenticatedResource("/registry/profiles/clarin.eu:cr1:profile1/comments/0").post(ClientResponse.class, manipulateForm); 283 assertEquals(200, response.getStatus()); 284 285 comments = getResource().path("/registry/profiles/clarin.eu:cr1:profile1/comments/").get(COMMENT_LIST_GENERICTYPE); 286 assertEquals(1, comments.size()); 249 287 } 250 288 … … 329 367 330 368 @Test 369 public void testManipulateRegisteredComponent() throws Exception { 370 fillUp(); 371 List<ComponentDescription> components = getResource().path("/registry/components").get(COMPONENT_LIST_GENERICTYPE); 372 assertEquals(2, components.size()); 373 CMDComponentSpec profile = getResource().path("/registry/components/clarin.eu:cr1:component1").get(CMDComponentSpec.class); 374 assertNotNull(profile); 375 376 Form manipulateForm = new Form(); 377 manipulateForm.add("method", "delete"); 378 379 ClientResponse response = getAuthenticatedResource("/registry/components/clarin.eu:cr1:component1").post(ClientResponse.class, manipulateForm); 380 assertEquals(200, response.getStatus()); 381 382 components = getResource().path("/registry/components").get(COMPONENT_LIST_GENERICTYPE); 383 assertEquals(1, components.size()); 384 385 response = getAuthenticatedResource("/registry/components/clarin.eu:cr1:component2").post(ClientResponse.class, manipulateForm); 386 assertEquals(200, response.getStatus()); 387 } 388 389 @Test 331 390 public void testGetRegisteredProfile() throws Exception { 332 391 fillUp(); … … 417 476 418 477 response = getAuthenticatedResource("/registry/profiles/clarin.eu:cr1:profile1").delete(ClientResponse.class); 478 assertEquals(200, response.getStatus()); 479 } 480 481 @Test 482 public void testManipulateRegisteredProfile() throws Exception { 483 fillUp(); 484 List<ProfileDescription> profiles = getResource().path("/registry/profiles").get(PROFILE_LIST_GENERICTYPE); 485 assertEquals(2, profiles.size()); 486 CMDComponentSpec profile = getResource().path("/registry/profiles/clarin.eu:cr1:profile1").get(CMDComponentSpec.class); 487 assertNotNull(profile); 488 489 Form manipulateForm = new Form(); 490 manipulateForm.add("method", "delete"); 491 492 ClientResponse response = getAuthenticatedResource("/registry/profiles/clarin.eu:cr1:profile1").post(ClientResponse.class, manipulateForm); 493 assertEquals(200, response.getStatus()); 494 495 profiles = getResource().path("/registry/profiles").get(PROFILE_LIST_GENERICTYPE); 496 assertEquals(1, profiles.size()); 497 498 response = getAuthenticatedResource("/registry/profiles/clarin.eu:cr1:profile2").post(ClientResponse.class, manipulateForm); 419 499 assertEquals(200, response.getStatus()); 420 500 }
Note: See TracChangeset
for help on using the changeset viewer.