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());
}
Aggregations