Search in sources :

Example 1 with MockMetadataManager

use of org.mycore.pi.MockMetadataManager in project mycore by MyCoRe-Org.

the class MCRURNGranularRESTRegistrationServiceTest method fullRegister.

@Test
public void fullRegister() throws Exception {
    new MockContentTypes();
    new MockFrontendUtil();
    new MockFiles();
    new MockAccessManager();
    new MockObjectDerivate();
    new MockDerivate();
    MockMetadataManager mockMetadataManager = new MockMetadataManager();
    MCRDerivate derivate = new MCRDerivate();
    MCRObjectID mcrObjectID = MCRPIUtils.getNextFreeID();
    derivate.setId(mcrObjectID);
    mockMetadataManager.put(mcrObjectID, derivate);
    Function<MCRDerivate, Stream<MCRPath>> foo = deriv -> IntStream.iterate(0, i -> i + 1).mapToObj(i -> "/foo/" + UUID.randomUUID() + "_" + String.format(Locale.getDefault(), "%02d", i)).map(f -> MCRPath.getPath(derivate.getId().toString(), f)).limit(numOfDerivFiles);
    String serviceID = "TestService";
    MCRURNGranularRESTRegistrationService testService = new MCRURNGranularRESTRegistrationService(serviceID, foo);
    testService.register(derivate, "", true);
    timerTask();
    List<MCRPIRegistrationInfo> registeredURNs = MCREntityManagerProvider.getEntityManagerFactory().createEntityManager().createNamedQuery("Get.PI.Created", MCRPIRegistrationInfo.class).setParameter("mcrId", mcrObjectID.toString()).setParameter("type", MCRDNBURN.TYPE).setParameter("service", serviceID).getResultList();
    Assert.assertEquals("Wrong number of registered URNs: ", numOfDerivFiles + 1, registeredURNs.size());
}
Also used : IntStream(java.util.stream.IntStream) Date(java.util.Date) MCRUUIDURNGenerator(org.mycore.pi.urn.MCRUUIDURNGenerator) Function(java.util.function.Function) MCRException(org.mycore.common.MCRException) TreeSet(java.util.TreeSet) MCRDerivate(org.mycore.datamodel.metadata.MCRDerivate) MCRAccessManager(org.mycore.access.MCRAccessManager) MCRDNBURN(org.mycore.pi.urn.MCRDNBURN) LinkOption(java.nio.file.LinkOption) Locale(java.util.Locale) MCRMetaIFS(org.mycore.datamodel.metadata.MCRMetaIFS) Map(java.util.Map) After(org.junit.After) Mock(mockit.Mock) MCRFileMetadata(org.mycore.datamodel.metadata.MCRFileMetadata) Path(java.nio.file.Path) MCRObjectDerivate(org.mycore.datamodel.metadata.MCRObjectDerivate) MockUp(mockit.MockUp) MCRContentTypes(org.mycore.datamodel.niofs.MCRContentTypes) Files(java.nio.file.Files) MCRPath(org.mycore.datamodel.niofs.MCRPath) IOException(java.io.IOException) Test(org.junit.Test) MCRPIRegistrationInfo(org.mycore.pi.MCRPIRegistrationInfo) UUID(java.util.UUID) MCRFrontendUtil(org.mycore.frontend.MCRFrontendUtil) TimeUnit(java.util.concurrent.TimeUnit) MCREntityManagerProvider(org.mycore.backend.jpa.MCREntityManagerProvider) List(java.util.List) Stream(java.util.stream.Stream) MCRStoreTestCase(org.mycore.common.MCRStoreTestCase) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID) MockMetadataManager(org.mycore.pi.MockMetadataManager) MCRPIUtils(org.mycore.pi.MCRPIUtils) Assert(org.junit.Assert) MCRPIRegistrationInfo(org.mycore.pi.MCRPIRegistrationInfo) MockMetadataManager(org.mycore.pi.MockMetadataManager) MCRDerivate(org.mycore.datamodel.metadata.MCRDerivate) IntStream(java.util.stream.IntStream) Stream(java.util.stream.Stream) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 Files (java.nio.file.Files)1 LinkOption (java.nio.file.LinkOption)1 Path (java.nio.file.Path)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 TimeUnit (java.util.concurrent.TimeUnit)1 Function (java.util.function.Function)1 IntStream (java.util.stream.IntStream)1 Stream (java.util.stream.Stream)1 Mock (mockit.Mock)1 MockUp (mockit.MockUp)1 After (org.junit.After)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 MCRAccessManager (org.mycore.access.MCRAccessManager)1