Ignore:
Timestamp:
08/11/14 16:07:55 (10 years ago)
Author:
olhsha@mpi.nl
Message:

Added group service. Tested via the tomcat on loclahots (test URI and postman), old unit tests are adjusted and work well. Todo: retest on localhost tomcat, look at run-time exceptions, add new unit tests, adjust front-end

File:
1 edited

Legend:

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

    r4098 r5549  
    1616import clarin.cmdi.componentregistry.ComponentRegistry;
    1717import clarin.cmdi.componentregistry.DatesHelper;
     18import clarin.cmdi.componentregistry.ItemNotFoundException;
    1819import clarin.cmdi.componentregistry.MDMarshaller;
     20import clarin.cmdi.componentregistry.UserUnauthorizedException;
    1921import clarin.cmdi.componentregistry.components.CMDComponentSpec;
    2022import clarin.cmdi.componentregistry.model.Comment;
     
    2729import java.io.InputStreamReader;
    2830
    29 import javax.xml.transform.TransformerException;
    30 
    31 import org.junit.Before;
    32 import org.junit.BeforeClass;
    3331import org.springframework.beans.factory.annotation.Autowired;
    3432
     
    4644    }
    4745
    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,
    5351            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,
    5856            JAXBException {
    5957        ComponentDescription desc = ComponentDescription.createNewDescription();
    6058        desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
    61         desc.setUserId(DummyPrincipal.DUMMY_CREDENTIALS.getPrincipalName());
     59        desc.setUserId(DummyPrincipal.DUMMY_PRINCIPAL.getName());
    6260        desc.setName(id);
    6361        desc.setDescription("Test Description");
    6462        desc.setId(ComponentDescription.COMPONENT_PREFIX + id);
    6563        desc.setHref("link:" + desc.getId());
     64        desc.setPublic(isPublic);
    6665        CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
    6766        testRegistry.register(desc, spec);
     
    104103    }
    105104
    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 {
    117116        ProfileDescription desc = ProfileDescription.createNewDescription();
    118117        desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
     
    122121        desc.setId(ProfileDescription.PROFILE_PREFIX + id);
    123122        desc.setHref("link:" + ProfileDescription.PROFILE_PREFIX + id);
     123        desc.setPublic(isPublic);
    124124        CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
    125125        testRegistry.register(desc, spec);
     
    216216    }
    217217
    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 {
    219219        return addComment(testRegistry, RegistryTestHelper.getTestCommentContent(id, descriptionId), principal);
    220220    }
     
    222222    private static Comment addComment(ComponentRegistry testRegistry, InputStream content, String principal) throws ParseException,
    223223            JAXBException,
    224             ComponentRegistryException {
     224            ComponentRegistryException, ItemNotFoundException,UserUnauthorizedException {
    225225        Comment spec = marshaller.unmarshal(Comment.class, content, null);
    226226        testRegistry.registerComment(spec, principal);
Note: See TracChangeset for help on using the changeset viewer.