public DocumentMetadataHandle getMetadata(String uri) { return client.newDocumentManager().readMetadata(uri, new DocumentMetadataHandle()); }
validateRecord(rec, Format.JSON); docMgr.readMetadata(rec.getUri(), mh); assertTrue("Records has permissions? ", mh.getPermissions().containsKey("flexrep-eval")); assertFalse("Record has collections ?", mh.getCollections().isEmpty());
docMgr.readMetadata(rec.getUri(), mh); System.out.println(rec.getUri()); validateMetadata(mh);
validateRecord(rec, Format.JSON); docMgr.readMetadata(rec.getUri(), mh); assertTrue("Records has permissions? ", mh.getPermissions().containsKey("flexrep-eval")); assertFalse("Record has collections ?", mh.getCollections().isEmpty());
DocumentPage page = docMgr.read("/generic/Sega.jpg"); DocumentRecord rec = page.next(); docMgr.readMetadata(rec.getUri(), mh1); assertEquals("default quality", 0, mh1.getQuality()); assertTrue("Properties contains value 19", mh1.getProperties().containsValue("19")); docMgr.readMetadata(rec.getUri(), mh1); assertEquals("default quality", 10, mh1.getQuality()); String expectedCollections = "size:1|http://permission-collections/|"; docMgr.readMetadata(rec.getUri(), mh1); expectedCollections = "size:1|http://permission-collections/|"; actualCollections = getDocumentCollectionsString(mh1.getCollections()); docMgr.readMetadata(rec.getUri(), mh1); assertEquals("default quality", 0, mh1.getQuality()); assertEquals("default collection must change",
docMgr.readMetadata(rec.getUri(), mh); System.out.println(rec.getUri()); validateMetadata(mh); page = docMgr.read("/generic/dog.json"); DocumentRecord rec = page.next(); docMgr.readMetadata(rec.getUri(), mh); assertEquals("default quality", 10, mh.getQuality()); docMgr.readMetadata(rec.getUri(), mh); assertEquals("default quality", 0, mh.getQuality()); assertEquals("default collection must change", "[genericCollection]", mh.getCollections().toString());
@Test public void testRunFlow() throws SAXException, IOException, ParserConfigurationException, XMLStreamException { addStagingDocs(); installModules(); assertEquals(2, getStagingDocCount()); assertEquals(0, getFinalDocCount()); getHubFlowRunnerConfig(); Flow flow1 = fm.getFlow("test", "my-test-flow1"); FlowRunner flowRunner = fm.newFlowRunner() .withFlow(flow1) .withBatchSize(10) .withThreadCount(1); flowRunner.run(); flowRunner.awaitCompletion(); getHubAdminConfig(); assertEquals(2, getStagingDocCount()); assertEquals(2, getFinalDocCount()); assertXMLEqual(getXmlFromResource("flow-manager-test/harmonized/harmonized1.xml"), finalDocMgr.read("/employee1.xml").next().getContent(new DOMHandle()).get() ); assertXMLEqual(getXmlFromResource("flow-manager-test/harmonized/harmonized2.xml"), finalDocMgr.read("/employee2.xml").next().getContent(new DOMHandle()).get()); DocumentMetadataHandle metadata = finalDocMgr.readMetadata("/employee1.xml", new DocumentMetadataHandle()); DocumentMetadataHandle.DocumentPermissions permissions = metadata.getPermissions(); assertEquals( permissions.get("harmonized-reader").toString(), "[READ]", "Default permissions on harmonized documents should contain harmonized-reader/read"); assertEquals(permissions.get("harmonized-updater").toString(), "[UPDATE]", "Default permissions on harmonized documents should contain harmonized-updater/update"); }
@Test public void testRunFlowWithBackwards() throws SAXException, IOException, ParserConfigurationException, XMLStreamException { addFinalDocs(); installModules(); assertEquals(0, getStagingDocCount()); assertEquals(2, getFinalDocCount()); getHubFlowRunnerConfig(); Flow flow1 = fm.getFlow("test", "my-test-flow1"); FlowRunner flowRunner = fm.newFlowRunner() .withFlow(flow1) .withBatchSize(10) .withThreadCount(1) .withSourceClient(getHubFlowRunnerConfig().newReverseFlowClient()) .withDestinationDatabase(HubConfig.DEFAULT_STAGING_NAME); flowRunner.run(); flowRunner.awaitCompletion(); getHubAdminConfig(); assertEquals(2, getStagingDocCount()); assertEquals(2, getFinalDocCount()); assertXMLEqual(getXmlFromResource("flow-manager-test/harmonized/harmonized1.xml"), stagingDocMgr.read("/employee1.xml").next().getContent(new DOMHandle()).get() ); assertXMLEqual(getXmlFromResource("flow-manager-test/harmonized/harmonized2.xml"), stagingDocMgr.read("/employee2.xml").next().getContent(new DOMHandle()).get()); DocumentMetadataHandle metadata = stagingDocMgr.readMetadata("/employee1.xml", new DocumentMetadataHandle()); DocumentMetadataHandle.DocumentPermissions permissions = metadata.getPermissions(); assertEquals(permissions.get("harmonized-reader").toString(), "[READ]", "Default permissions on harmonized documents should contain harmonized-reader/read"); assertEquals(permissions.get("harmonized-updater").toString(), "[UPDATE]", "Default permissions on harmonized documents should contain harmonized-updater/update"); }
String metadata = docMgr.readMetadata(docId, new StringHandle().withFormat(Format.XML)).get();