Changeset 5549 for ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.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/rest/RegistryTestHelper.java
r4098 r5549 16 16 import clarin.cmdi.componentregistry.ComponentRegistry; 17 17 import clarin.cmdi.componentregistry.DatesHelper; 18 import clarin.cmdi.componentregistry.ItemNotFoundException; 18 19 import clarin.cmdi.componentregistry.MDMarshaller; 20 import clarin.cmdi.componentregistry.UserUnauthorizedException; 19 21 import clarin.cmdi.componentregistry.components.CMDComponentSpec; 20 22 import clarin.cmdi.componentregistry.model.Comment; … … 27 29 import java.io.InputStreamReader; 28 30 29 import javax.xml.transform.TransformerException;30 31 import org.junit.Before;32 import org.junit.BeforeClass;33 31 import org.springframework.beans.factory.annotation.Autowired; 34 32 … … 46 44 } 47 45 48 public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id ) throws ParseException, JAXBException {49 return addComponent(testRegistry, id, getComponentTestContent() );50 } 51 52 public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, String content ) throws ParseException,46 public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException { 47 return addComponent(testRegistry, id, getComponentTestContent(), isPublic); 48 } 49 50 public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, String content, boolean isPublic) throws ParseException, 53 51 JAXBException, UnsupportedEncodingException { 54 return addComponent(testRegistry, id, new ByteArrayInputStream(content.getBytes("UTF-8")) );55 } 56 57 private static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, InputStream content ) throws ParseException,52 return addComponent(testRegistry, id, new ByteArrayInputStream(content.getBytes("UTF-8")), isPublic); 53 } 54 55 private static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException, 58 56 JAXBException { 59 57 ComponentDescription desc = ComponentDescription.createNewDescription(); 60 58 desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName()); 61 desc.setUserId(DummyPrincipal.DUMMY_CREDENTIALS.getPrincipalName());59 desc.setUserId(DummyPrincipal.DUMMY_PRINCIPAL.getName()); 62 60 desc.setName(id); 63 61 desc.setDescription("Test Description"); 64 62 desc.setId(ComponentDescription.COMPONENT_PREFIX + id); 65 63 desc.setHref("link:" + desc.getId()); 64 desc.setPublic(isPublic); 66 65 CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema()); 67 66 testRegistry.register(desc, spec); … … 104 103 } 105 104 106 public static ProfileDescription addProfile(ComponentRegistry testRegistry, String id ) throws ParseException, JAXBException {107 return addProfile(testRegistry, id, RegistryTestHelper.getTestProfileContent() );108 } 109 110 public static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, String content ) throws ParseException,111 JAXBException {112 return addProfile(testRegistry, id, new ByteArrayInputStream(content.getBytes()) );113 } 114 115 private static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, InputStream content ) throws ParseException,116 JAXBException {105 public static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException, ItemNotFoundException { 106 return addProfile(testRegistry, id, RegistryTestHelper.getTestProfileContent(), isPublic); 107 } 108 109 public static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, String content, boolean isPublic) throws ParseException, 110 JAXBException, ItemNotFoundException { 111 return addProfile(testRegistry, id, new ByteArrayInputStream(content.getBytes()), isPublic); 112 } 113 114 private static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException, 115 JAXBException, ItemNotFoundException { 117 116 ProfileDescription desc = ProfileDescription.createNewDescription(); 118 117 desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName()); … … 122 121 desc.setId(ProfileDescription.PROFILE_PREFIX + id); 123 122 desc.setHref("link:" + ProfileDescription.PROFILE_PREFIX + id); 123 desc.setPublic(isPublic); 124 124 CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema()); 125 125 testRegistry.register(desc, spec); … … 216 216 } 217 217 218 public static Comment addComment(ComponentRegistry testRegistry, String id, String descriptionId, String principal) throws ParseException, JAXBException, ComponentRegistryException {218 public static Comment addComment(ComponentRegistry testRegistry, String id, String descriptionId, String principal) throws ParseException, JAXBException, ComponentRegistryException, ItemNotFoundException,UserUnauthorizedException { 219 219 return addComment(testRegistry, RegistryTestHelper.getTestCommentContent(id, descriptionId), principal); 220 220 } … … 222 222 private static Comment addComment(ComponentRegistry testRegistry, InputStream content, String principal) throws ParseException, 223 223 JAXBException, 224 ComponentRegistryException {224 ComponentRegistryException, ItemNotFoundException,UserUnauthorizedException { 225 225 Comment spec = marshaller.unmarshal(Comment.class, content, null); 226 226 testRegistry.registerComment(spec, principal);
Note: See TracChangeset
for help on using the changeset viewer.