Changeset 5560 for ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java
- Timestamp:
- 08/18/14 14:22:07 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java
r5556 r5560 17 17 import clarin.cmdi.componentregistry.model.ProfileDescription; 18 18 import clarin.cmdi.componentregistry.model.RegistryUser; 19 import clarin.cmdi.componentregistry.persistence.jpa.CommentsDao; 19 20 import clarin.cmdi.componentregistry.persistence.jpa.UserDao; 20 21 import com.sun.jersey.api.client.ClientResponse; … … 22 23 import java.util.List; 23 24 import javax.ws.rs.core.MediaType; 24 import javax.ws.rs.core.MultivaluedMap;25 25 import javax.xml.bind.JAXBException; 26 26 import org.junit.Before; … … 46 46 @Autowired 47 47 private UserDao userDao; 48 @Autowired 49 private CommentsDao commentsDao; 48 50 49 51 private ComponentRegistry baseRegistry; … … 507 509 fillUpGroupC(); 508 510 511 // lists 509 512 510 513 List<ProfileDescription> response = this.getAuthenticatedResource(getResource() … … 534 537 assertEquals(403, clientResponse.getStatus()); 535 538 539 // particular components and profiles 536 540 537 541 CMDComponentSpec component = this.getAuthenticatedResource(getResource() … … 570 574 571 575 } 576 577 @Test 578 public void testGetGroupComments() throws Exception { 579 580 System.out.println("test getGroupComments"); 581 582 fillUpGroupA(); 583 fillUpGroupB(); 584 fillUpGroupC(); 585 586 587 RegistryTestHelper.addComment(baseRegistry, "COMMENTc1", ComponentDescription.COMPONENT_PREFIX + "component-1", 588 "JUnit@test.com"); 589 RegistryTestHelper.addComment(baseRegistry, "COMMENTp1", ProfileDescription.PROFILE_PREFIX + "profile-1", 590 "JUnit@test.com"); 591 RegistryTestHelper.addComment(baseRegistry, "COMMENTBc1", ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1", 592 "anotherPrincipal"); 593 RegistryTestHelper.addComment(baseRegistry, "COMMENTBp1", ProfileDescription.PROFILE_PREFIX + "Bprofile-1", 594 "anotherPrincipal"); 595 (new RegistryTestHelper()).addCommentBypassAuthorisation(commentsDao, "COMMENTCc1", ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1", 596 "anotherPrincipal"); 597 (new RegistryTestHelper()).addCommentBypassAuthorisation(commentsDao, "COMMENTCp1", ProfileDescription.PROFILE_PREFIX + "Cprofile-1","anotherPrincipal"); 598 599 600 // lists 601 602 List<Comment> response = this.getAuthenticatedResource(getResource() 603 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1" + "/comments/")) 604 .accept(MediaType.APPLICATION_XML) 605 .get(COMMENT_LIST_GENERICTYPE); 606 assertEquals(1, response.size()); 607 608 response = this.getAuthenticatedResource(getResource() 609 .path("/registry/components/" + ProfileDescription.PROFILE_PREFIX + "profile-1" + "/comments/")) 610 .accept(MediaType.APPLICATION_XML) 611 .get(COMMENT_LIST_GENERICTYPE); 612 assertEquals(1, response.size()); 613 614 response = this.getAuthenticatedResource(getResource() 615 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1" + "/comments/")) 616 .accept(MediaType.APPLICATION_XML) 617 .get(COMMENT_LIST_GENERICTYPE); 618 assertEquals(1, response.size()); 619 620 response = this.getAuthenticatedResource(getResource() 621 .path("/registry/components/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1" + "/comments/")) 622 .accept(MediaType.APPLICATION_XML) 623 .get(COMMENT_LIST_GENERICTYPE); 624 assertEquals(1, response.size()); 625 626 627 628 ClientResponse clientResponse = this.getAuthenticatedResource(getResource() 629 .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1")) 630 .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); 631 assertEquals(403, clientResponse.getStatus()); 632 633 clientResponse = this.getAuthenticatedResource(getResource() 634 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1")) 635 .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); 636 assertEquals(403, clientResponse.getStatus()); 637 638 // particular comments 639 640 Comment responseComment = this.getAuthenticatedResource(getResource() 641 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1" + "/comments/1")) 642 .accept(MediaType.APPLICATION_XML) 643 .get(Comment.class); 644 assertNotNull(responseComment); 645 646 assertEquals(1, Long.parseLong(responseComment.getId())); 647 648 responseComment = this.getAuthenticatedResource(getResource() 649 .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1" + "/comments/2")) 650 .accept(MediaType.APPLICATION_XML) 651 .get(Comment.class); 652 assertNotNull(responseComment); 653 654 assertEquals(2, Long.parseLong(responseComment.getId())); 655 656 responseComment = this.getAuthenticatedResource(getResource() 657 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1" + "/comments/3")) 658 .accept(MediaType.APPLICATION_XML) 659 .get(Comment.class); 660 assertNotNull(responseComment); 661 assertEquals(3, Long.parseLong(responseComment.getId())); 662 663 responseComment = this.getAuthenticatedResource(getResource() 664 .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1" + "/comments/4")) 665 .accept(MediaType.APPLICATION_XML) 666 .get(Comment.class); 667 assertNotNull(responseComment); 668 assertEquals(4, Long.parseLong(responseComment.getId())); 669 670 clientResponse = this.getAuthenticatedResource(getResource() 671 .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1/comments/6")) 672 .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); 673 assertEquals(403, clientResponse.getStatus()); 674 675 clientResponse = this.getAuthenticatedResource(getResource() 676 .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1/comments/5")) 677 .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); 678 assertEquals(403, clientResponse.getStatus()); 679 680 } 572 681 573 682 }
Note: See TracChangeset
for help on using the changeset viewer.