Ignore:
Timestamp:
08/18/14 16:56:51 (10 years ago)
Author:
olhsha@mpi.nl
Message:

Unit test for deleting profiles and components from groups.

File:
1 edited

Legend:

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

    r5564 r5565  
    10661066    }
    10671067   
     1068      @Test
     1069    public void testDeleteProfileAndComponentFromGroup() throws Exception {
     1070
     1071        System.out.println("test deleteProfileAndComponentFromGroup");
     1072
     1073        fillUpGroupA();
     1074        fillUpGroupB();       
     1075        fillUpGroupC();
     1076       
     1077        ClientResponse response = getAuthenticatedResource(
     1078                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX
     1079                + "component-1").delete(ClientResponse.class);
     1080        assertEquals(200, response.getStatus());
     1081       
     1082        response = getAuthenticatedResource(
     1083                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX
     1084                + "component-1").get(ClientResponse.class);
     1085        assertEquals(404, response.getStatus());
     1086       
     1087        // my group, not my component
     1088       
     1089        response = getAuthenticatedResource(
     1090                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX
     1091                + "Bcomponent-1").delete(ClientResponse.class);
     1092        assertEquals(200, response.getStatus());
     1093       
     1094        response = getAuthenticatedResource(
     1095                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX
     1096                + "Bcomponent-1").get(ClientResponse.class);
     1097        assertEquals(404, response.getStatus());
     1098       
     1099        // not my group
     1100        response = getAuthenticatedResource(
     1101                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX
     1102                + "Ccomponent-1").delete(ClientResponse.class);
     1103        assertEquals(403, response.getStatus());
     1104       
     1105        baseRegistry.setRegistrySpace(RegistrySpace.GROUP);
     1106        baseRegistry.setGroupId(1);
     1107        assertEquals(1, baseRegistry.getComponentDescriptions().size());
     1108        baseRegistry.setGroupId(2);
     1109        assertEquals(1, baseRegistry.getComponentDescriptions().size());
     1110//        baseRegistry.setGroupId(3);
     1111//        assertEquals(2, baseRegistry.getComponentDescriptions().size());
     1112       
     1113        baseRegistry.setRegistrySpace(null);
     1114        baseRegistry.setGroupId(null);
     1115       
     1116        // profiles
     1117       
     1118        response = getAuthenticatedResource(
     1119                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
     1120                + "profile-1").delete(ClientResponse.class);
     1121        assertEquals(200, response.getStatus());
     1122       
     1123        response = getAuthenticatedResource(
     1124                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
     1125                + "profile-1").get(ClientResponse.class);
     1126        assertEquals(404, response.getStatus());
     1127       
     1128        // my group, not my component
     1129       
     1130        response = getAuthenticatedResource(
     1131                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
     1132                + "Bprofile-1").delete(ClientResponse.class);
     1133        assertEquals(200, response.getStatus());
     1134       
     1135        response = getAuthenticatedResource(
     1136                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
     1137                + "Bprofile-1").get(ClientResponse.class);
     1138        assertEquals(404, response.getStatus());
     1139       
     1140        // not my group
     1141        response = getAuthenticatedResource(
     1142                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
     1143                + "Cprofile-1").delete(ClientResponse.class);
     1144        assertEquals(403, response.getStatus());
     1145       
     1146        baseRegistry.setRegistrySpace(RegistrySpace.GROUP);
     1147        baseRegistry.setGroupId(1);
     1148        assertEquals(0, baseRegistry.getProfileDescriptions().size());
     1149        baseRegistry.setGroupId(2);
     1150        assertEquals(0, baseRegistry.getProfileDescriptions().size());
     1151    }
    10681152}
Note: See TracChangeset for help on using the changeset viewer.