Changeset 5565 for ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java
- Timestamp:
- 08/18/14 16:56:51 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java
r5564 r5565 230 230 231 231 232 233 public void test PublishGroupProfileAndComponent() throws Exception {234 235 System.out.println("test PublishProfile");232 @Test 233 public void testDeleteProfileAndComponentFromGroup() throws Exception { 234 235 System.out.println("test deleteProfileAndComponentFromGroup"); 236 236 237 237 fillUpGroupA(); … … 239 239 fillUpGroupC(); 240 240 241 baseRegistry.setRegistrySpace(RegistrySpace.PUBLISHED); 242 243 FormDataMultiPart form = createFormData( 244 RegistryTestHelper.getTestProfileContent("publishedName"), 245 "Published"); 246 RegisterResponse response = getAuthenticatedResource(getResource().path( 247 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"profile-1" + "/publish")) 248 .type(MediaType.MULTIPART_FORM_DATA).post( 249 RegisterResponse.class, form); 250 assertFalse(response.isInUserSpace()); 251 assertTrue(response.isProfile()); 252 assertEquals(ProfileDescription.PROFILE_PREFIX+"profile-1", response.getDescription().getId()); 253 254 255 List<ProfileDescription> profiles = baseRegistry.getProfileDescriptions(); 256 assertEquals(1, profiles.size()); 257 ProfileDescription profileDescription = profiles.get(0); 258 assertEquals(ProfileDescription.PROFILE_PREFIX+"profile-1", profileDescription.getId()); 259 assertEquals("link:" + ProfileDescription.PROFILE_PREFIX+"profile-1", 260 profileDescription.getHref()); 261 assertEquals("Published", profileDescription.getDescription()); 262 263 264 265 266 // not my profile from "my" group 267 268 form = createFormData( 269 RegistryTestHelper.getTestProfileContent("publishedName"), 270 "Published"); 271 response = getAuthenticatedResource(getResource().path( 272 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1" + "/publish")) 273 .type(MediaType.MULTIPART_FORM_DATA).post( 274 RegisterResponse.class, form); 275 assertFalse(response.isInUserSpace()); 276 assertTrue(response.isProfile()); 277 assertEquals(ProfileDescription.PROFILE_PREFIX+"Bprofile-1", response.getDescription().getId()); 278 279 profiles = baseRegistry.getProfileDescriptions(); 280 assertEquals(2, profiles.size()); 281 profileDescription = profiles.get(0); 282 assertEquals(ProfileDescription.PROFILE_PREFIX+"Bprofile-1", profileDescription.getId()); 283 assertEquals("link:" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1", 284 profileDescription.getHref()); 285 assertEquals("Published", profileDescription.getDescription()); 286 287 // not my profile, not my group 288 289 form = createFormData( 290 RegistryTestHelper.getTestProfileContent("publishedName"), 291 "Published"); 292 ClientResponse cr = getAuthenticatedResource(getResource().path( 293 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1" + "/publish")) 294 .type(MediaType.MULTIPART_FORM_DATA).post( 295 ClientResponse.class, form); 296 assertEquals(403, cr.getStatus()); 297 profiles = baseRegistry.getProfileDescriptions(); 298 assertEquals(2, profiles.size()); 299 300 /// components 301 302 303 form = createFormData( 304 RegistryTestHelper.getComponentTestContentAsStream("publishedName"), 305 "Published"); 306 response = getAuthenticatedResource(getResource().path( 307 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"component-1" + "/publish")) 308 .type(MediaType.MULTIPART_FORM_DATA).post( 309 RegisterResponse.class, form); 310 assertFalse(response.isInUserSpace()); 311 assertFalse(response.isProfile()); 312 assertEquals(ComponentDescription.COMPONENT_PREFIX+"component-1", response.getDescription().getId()); 313 314 315 List<ComponentDescription> components = baseRegistry.getComponentDescriptions(); 316 assertEquals(1, components.size()); 317 ComponentDescription componentDescription = components.get(0); 318 assertEquals(ComponentDescription.COMPONENT_PREFIX+"component-1", componentDescription.getId()); 319 assertEquals("link:" + ComponentDescription.COMPONENT_PREFIX+"component-1", 320 componentDescription.getHref()); 321 assertEquals("Published", componentDescription.getDescription()); 322 323 324 325 326 // not my profile from "my" group 327 328 329 form = createFormData( 330 RegistryTestHelper.getComponentTestContentAsStream("publishedName"), 331 "Published"); 332 response = getAuthenticatedResource(getResource().path( 333 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1" + "/publish")) 334 .type(MediaType.MULTIPART_FORM_DATA).post( 335 RegisterResponse.class, form); 336 assertFalse(response.isInUserSpace()); 337 assertFalse(response.isProfile()); 338 assertEquals(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1", response.getDescription().getId()); 339 340 341 components = baseRegistry.getComponentDescriptions(); 342 assertEquals(2, components.size()); 343 componentDescription = components.get(0); 344 assertEquals(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1", componentDescription.getId()); 345 assertEquals("link:" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1", 346 componentDescription.getHref()); 347 assertEquals("Published", componentDescription.getDescription()); 348 349 350 // not my profile, not my group 351 352 form = createFormData( 353 RegistryTestHelper.getComponentTestContentAsStream("publishedName"), 354 "Published"); 355 cr = getAuthenticatedResource(getResource().path( 356 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1" + "/publish")) 357 .type(MediaType.MULTIPART_FORM_DATA).post( 358 ClientResponse.class, form); 359 assertEquals(403, cr.getStatus()); 360 components = baseRegistry.getComponentDescriptions(); 361 assertEquals(2, components.size()); 241 ClientResponse response = getAuthenticatedResource( 242 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 243 + "component-1").delete(ClientResponse.class); 244 assertEquals(200, response.getStatus()); 245 246 response = getAuthenticatedResource( 247 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 248 + "component-1").get(ClientResponse.class); 249 assertEquals(404, response.getStatus()); 250 251 // my group, not my component 252 253 response = getAuthenticatedResource( 254 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 255 + "Bcomponent-1").delete(ClientResponse.class); 256 assertEquals(200, response.getStatus()); 257 258 response = getAuthenticatedResource( 259 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 260 + "Bcomponent-1").get(ClientResponse.class); 261 assertEquals(404, response.getStatus()); 262 263 // not my group 264 response = getAuthenticatedResource( 265 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 266 + "Ccomponent-1").delete(ClientResponse.class); 267 assertEquals(403, response.getStatus()); 268 269 baseRegistry.setRegistrySpace(RegistrySpace.GROUP); 270 baseRegistry.setGroupId(1); 271 assertEquals(1, baseRegistry.getComponentDescriptions().size()); 272 baseRegistry.setGroupId(2); 273 assertEquals(1, baseRegistry.getComponentDescriptions().size()); 274 // baseRegistry.setGroupId(3); 275 // assertEquals(2, baseRegistry.getComponentDescriptions().size()); 276 277 baseRegistry.setRegistrySpace(null); 278 baseRegistry.setGroupId(null); 279 280 // profiles 281 282 response = getAuthenticatedResource( 283 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 284 + "profile-1").delete(ClientResponse.class); 285 assertEquals(200, response.getStatus()); 286 287 response = getAuthenticatedResource( 288 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 289 + "profile-1").get(ClientResponse.class); 290 assertEquals(404, response.getStatus()); 291 292 // my group, not my component 293 294 response = getAuthenticatedResource( 295 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 296 + "Bprofile-1").delete(ClientResponse.class); 297 assertEquals(200, response.getStatus()); 298 299 response = getAuthenticatedResource( 300 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 301 + "Bprofile-1").get(ClientResponse.class); 302 assertEquals(404, response.getStatus()); 303 304 // not my group 305 response = getAuthenticatedResource( 306 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 307 + "Cprofile-1").delete(ClientResponse.class); 308 assertEquals(403, response.getStatus()); 309 310 baseRegistry.setRegistrySpace(RegistrySpace.GROUP); 311 baseRegistry.setGroupId(1); 312 assertEquals(0, baseRegistry.getProfileDescriptions().size()); 313 baseRegistry.setGroupId(2); 314 assertEquals(0, baseRegistry.getProfileDescriptions().size()); 362 315 } 363 316
Note: See TracChangeset
for help on using the changeset viewer.