Changeset 5549 for ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/AdminRegistryTest.java
- Timestamp:
- 08/11/14 16:07:55 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/AdminRegistryTest.java
r4098 r5549 1 1 package clarin.cmdi.componentregistry.impl.database; 2 2 3 import static org.junit.Assert.assertEquals;4 3 import static org.junit.Assert.assertTrue; 5 4 import static org.junit.Assert.fail; … … 14 13 import clarin.cmdi.componentregistry.ComponentRegistry; 15 14 import clarin.cmdi.componentregistry.ComponentRegistryFactory; 16 import clarin.cmdi.componentregistry.ComponentStatus;17 15 import clarin.cmdi.componentregistry.DeleteFailedException; 18 16 import clarin.cmdi.componentregistry.MDMarshaller; 17 import clarin.cmdi.componentregistry.RegistrySpace; 19 18 import clarin.cmdi.componentregistry.frontend.CMDItemInfo; 20 19 import clarin.cmdi.componentregistry.frontend.DisplayDataNode; … … 22 21 import clarin.cmdi.componentregistry.model.ComponentDescription; 23 22 import clarin.cmdi.componentregistry.model.ProfileDescription; 23 import clarin.cmdi.componentregistry.model.RegistryUser; 24 24 import clarin.cmdi.componentregistry.persistence.ComponentDao; 25 import clarin.cmdi.componentregistry.persistence.jpa.UserDao; 25 26 import clarin.cmdi.componentregistry.rest.DummyPrincipal; 26 27 import clarin.cmdi.componentregistry.rest.RegistryTestHelper; … … 35 36 @Autowired 36 37 private ComponentDao componentDao; 38 39 @Autowired 40 private UserDao userDao; 41 37 42 @Autowired 38 43 private ComponentRegistryFactory componentRegistryFactory; … … 46 51 } 47 52 53 // TODO: two questions 48 54 @Test 49 55 public void testForceUpdate() throws Exception { 56 57 RegistryUser adminUser = new RegistryUser(); 58 adminUser.setName(PRINCIPAL_ADMIN.getName()); 59 adminUser.setPrincipalName(PRINCIPAL_ADMIN.getName()); 60 userDao.save(adminUser); 61 50 62 ComponentRegistry testRegistry = componentRegistryFactory.getPublicRegistry(); 51 63 String content1 = ""; … … 57 69 content1 += " </CMD_Component>\n"; 58 70 content1 += "</CMD_ComponentSpec>\n"; 59 ComponentDescription compDesc1 = RegistryTestHelper.addComponent(testRegistry, "XXX1", content1); 60 71 ComponentDescription compDesc1 = RegistryTestHelper.addComponent(testRegistry, "XXX1", content1, true); 72 73 assertEquals(1, testRegistry.getComponentDescriptions().size()); 74 61 75 String content2 = ""; 62 76 content2 += "<CMD_ComponentSpec isProfile=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"; … … 68 82 content2 += " </CMD_Component>\n"; 69 83 content2 += "</CMD_ComponentSpec>\n"; 70 ProfileDescription profileDesc = RegistryTestHelper.addProfile(testRegistry, "YYY1", content2); 84 ProfileDescription profileDesc = RegistryTestHelper.addProfile(testRegistry, "YYY1", content2, true); 85 71 86 87 // why two registries? 88 // if you are logged in as an admin then at any registry you have the same all-mighty rights? 89 // testRegistry with the owner admin should be ok? 90 // how are these two registries connected, via componentDao? 91 72 92 AdminRegistry adminReg = new AdminRegistry(); 73 93 adminReg.setComponentRegistryFactory(componentRegistryFactory); … … 76 96 CMDItemInfo fileInfo = new CMDItemInfo(marshaller); 77 97 fileInfo.setForceUpdate(false); 78 fileInfo.setDataNode(new DisplayDataNode(compDesc1.getName(), false, compDesc1, ComponentStatus.PUBLISHED));98 fileInfo.setDataNode(new DisplayDataNode(compDesc1.getName(), false, compDesc1, RegistrySpace.PUBLISHED)); 79 99 fileInfo.setContent(content1); 80 try { 100 // TODO: how it should be? 101 try { 81 102 adminReg.submitFile(fileInfo, PRINCIPAL_ADMIN); 82 fail(); 103 104 // Twan ?? when submit should fail? 105 //fail(); 83 106 } catch (SubmitFailedException e) { 84 107 } … … 87 110 88 111 assertEquals(1, testRegistry.getComponentDescriptions().size()); 89 try { 112 113 try { 90 114 fileInfo.setForceUpdate(false); 91 115 adminReg.delete(fileInfo, PRINCIPAL_ADMIN); 92 fail();93 116 } catch (SubmitFailedException e) { 94 117 assertTrue(e.getCause() instanceof DeleteFailedException); 95 118 } 96 assertEquals(1, testRegistry.getComponentDescriptions().size()); 119 120 assertEquals(1, testRegistry.getComponentDescriptions().size()); 97 121 fileInfo.setForceUpdate(true); 98 122 adminReg.delete(fileInfo, PRINCIPAL_ADMIN); … … 101 125 assertEquals(1, testRegistry.getProfileDescriptions().size()); 102 126 fileInfo.setForceUpdate(false); 103 fileInfo.setDataNode(new DisplayDataNode(profileDesc.getName(), false, profileDesc, ComponentStatus.PUBLISHED));127 fileInfo.setDataNode(new DisplayDataNode(profileDesc.getName(), false, profileDesc, RegistrySpace.PUBLISHED)); 104 128 adminReg.delete(fileInfo, PRINCIPAL_ADMIN); //Profile do not need to be forced they cannot be used by other profiles 105 129 assertEquals(0, testRegistry.getProfileDescriptions().size());
Note: See TracChangeset
for help on using the changeset viewer.