Ignore:
Timestamp:
08/18/14 17:33:47 (10 years ago)
Author:
olhsha@mpi.nl
Message:

Unit test for deleting comments from groups.

File:
1 edited

Legend:

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

    r5565 r5566  
    11501150        assertEquals(0, baseRegistry.getProfileDescriptions().size());
    11511151    }
     1152     
     1153      @Test 
     1154    public void testDeleteCommentFromGroupComponentAndProfile() throws Exception {
     1155
     1156        System.out.println("test deleteCommentFromGroupComponent");
     1157
     1158       
     1159        fillUpGroupA();
     1160        fillUpGroupB();       
     1161        fillUpGroupC();
     1162       
     1163         RegistryTestHelper.addComment(baseRegistry, "COMMENTc1",  ComponentDescription.COMPONENT_PREFIX + "component-1",
     1164                "JUnit@test.com");
     1165        RegistryTestHelper.addComment(baseRegistry, "COMMENTp1",  ProfileDescription.PROFILE_PREFIX + "profile-1",
     1166                "JUnit@test.com");
     1167        RegistryTestHelper.addComment(baseRegistry, "COMMENTBc1",  ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1",
     1168                "anotherPrincipal");
     1169        RegistryTestHelper.addComment(baseRegistry, "COMMENTBp1",  ProfileDescription.PROFILE_PREFIX + "Bprofile-1",
     1170                "anotherPrincipal");
     1171       (new RegistryTestHelper()).addCommentBypassAuthorisation(commentsDao, "COMMENTCc1",  ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1",
     1172                "anotherPrincipal");
     1173       (new RegistryTestHelper()).addCommentBypassAuthorisation(commentsDao, "COMMENTCp1",  ProfileDescription.PROFILE_PREFIX + "Cprofile-1","anotherPrincipal");
     1174         
     1175        ClientResponse response = getAuthenticatedResource(
     1176                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1/comments/1").delete(
     1177                ClientResponse.class);
     1178        assertEquals(200, response.getStatus());
     1179        response = getAuthenticatedResource(
     1180                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1/comments/1").get(
     1181                ClientResponse.class);
     1182        assertEquals(404, response.getStatus());
     1183       
     1184        response = getAuthenticatedResource(
     1185                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1/comments/3").delete(
     1186                ClientResponse.class);
     1187        assertEquals(403, response.getStatus());
     1188       
     1189       
     1190        response = getAuthenticatedResource(
     1191                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1/comments/5").delete(
     1192                ClientResponse.class);
     1193        assertEquals(403, response.getStatus());
     1194
     1195       
     1196       response = getAuthenticatedResource(
     1197                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1/comments/2").delete(
     1198                ClientResponse.class);
     1199        assertEquals(200, response.getStatus());
     1200        response = getAuthenticatedResource(
     1201                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1/comments/2").get(
     1202                ClientResponse.class);
     1203        assertEquals(404, response.getStatus());
     1204       
     1205        response = getAuthenticatedResource(
     1206                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1/comments/4").delete(
     1207                ClientResponse.class);
     1208        assertEquals(403, response.getStatus());
     1209       
     1210       
     1211        response = getAuthenticatedResource(
     1212                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Cprofile-1/comments/6").delete(
     1213                ClientResponse.class);
     1214        assertEquals(403, response.getStatus());
     1215       
     1216    }
    11521217}
Note: See TracChangeset for help on using the changeset viewer.