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

Unit test for getting profiles and components from groups. A little bug is fixed

File:
1 edited

Legend:

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

    r5553 r5556  
    4949        return addComponent(testRegistry, id, getComponentTestContent(), isPublic);
    5050    }
    51 
     51   
     52   
    5253    public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, String content, boolean isPublic) throws ParseException,
    5354            JAXBException, UnsupportedEncodingException {
     
    6061        desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
    6162        desc.setUserId(DummyPrincipal.DUMMY_PRINCIPAL.getName());
     63        desc.setName(id);
     64        desc.setDescription("Test Description");
     65        desc.setId(ComponentDescription.COMPONENT_PREFIX + id);
     66        desc.setHref("link:" + desc.getId());
     67        desc.setPublic(isPublic);
     68        CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
     69        testRegistry.register(desc, spec);
     70        return desc;
     71    }
     72   
     73    public static ComponentDescription addComponentAnotherPrincipal(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException {
     74        return addComponentAnotherPrincipal(testRegistry, id, getComponentTestContent(), isPublic);
     75    }
     76
     77     private static ComponentDescription addComponentAnotherPrincipal(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
     78            JAXBException {
     79        ComponentDescription desc = ComponentDescription.createNewDescription();
     80        desc.setCreatorName("AnotherPrincipal");
     81        desc.setUserId("AnotherPrincipal");
     82        desc.setDbUserId(2);
    6283        desc.setName(id);
    6384        desc.setDescription("Test Description");
     
    121142        desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
    122143        desc.setUserId(DummyPrincipal.DUMMY_CREDENTIALS.getPrincipalName());
     144        desc.setName(id);
     145        desc.setDescription("Test Description");
     146        desc.setId(ProfileDescription.PROFILE_PREFIX + id);
     147        desc.setHref("link:" + ProfileDescription.PROFILE_PREFIX + id);
     148        desc.setPublic(isPublic);
     149        CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
     150        testRegistry.register(desc, spec);
     151        return desc;
     152    }
     153   
     154    public static ProfileDescription addProfileAnotherPrincipal(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException, ItemNotFoundException {
     155        return addProfileAnotherPrincipal(testRegistry, id, RegistryTestHelper.getTestProfileContent(), isPublic);
     156    }
     157   
     158    private static ProfileDescription addProfileAnotherPrincipal(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
     159            JAXBException, ItemNotFoundException {
     160        ProfileDescription desc = ProfileDescription.createNewDescription();
     161        desc.setCreatorName("AnotherPrincipal");
     162        desc.setUserId("AnotherPrincipal");
     163        desc.setDbUserId(2);
    123164        desc.setName(id);
    124165        desc.setDescription("Test Description");
Note: See TracChangeset for help on using the changeset viewer.