@Test public void testJavascriptRestTransformAdapter() throws Exception{ ServerTransform transform = new ServerTransform(MLCP_TRANSFORM_ADAPTER) .addParameter("ml.module", "/ext/RestTransformAdapter.xqy") .addParameter("ml.namespace", "http://marklogic.com/mlcp/transform/RestTransformAdapter.xqy") .addParameter("ml.transform", JS_NAME) .addParameter("value", "true"); runTransform(transform); }
@Test public void testXQueryRestTransformAdapter() throws Exception{ ServerTransform transform = new ServerTransform(MLCP_TRANSFORM_ADAPTER) .addParameter("ml.module", "/ext/RestTransformAdapter.xqy") .addParameter("ml.namespace", "http://marklogic.com/mlcp/transform/RestTransformAdapter.xqy") .addParameter("ml.transform", TransformExtensionsTest.XQUERY_NAME) .addParameter("value", "true"); runTransform(transform); }
@Test public void testXQueryMlcpTransformAdapter() throws Exception{ String transformContents = Common.testFileToString("SampleMlcpTransform.xqy"); libMgr.write("/ext/SampleMlcpTransform.xqy", new StringHandle(transformContents).withFormat(Format.TEXT)); ServerTransform transform = new ServerTransform(MLCP_TRANSFORM_ADAPTER) .addParameter("ml.module", "/ext/SampleMlcpTransform.xqy") .addParameter("ml.namespace", "http://marklogic.com/example") .addParameter("attr-value", "true"); runTransform(transform); libMgr.delete("/ext/SampleMlcpTransform.xqy"); }
@Test public void testJavascriptMlcpTransformAdapter() throws Exception{ String transformContents = Common.testFileToString("SampleMlcpTransform.sjs"); libMgr.write("/ext/SampleMlcpTransform.sjs", new StringHandle(transformContents).withFormat(Format.TEXT)); ServerTransform transform = new ServerTransform(MLCP_TRANSFORM_ADAPTER) .addParameter("ml.module", "/ext/SampleMlcpTransform.sjs") .addParameter("attr-value", "true"); runTransform(transform); libMgr.delete("/ext/SampleMlcpTransform.sjs"); }
runFlow.addParameter("entity-name", "SupportCall"); runFlow.addParameter("flow-name", "test-data"); runFlow.addParameter("job-id", UUID.randomUUID().toString());
runFlow.addParameter("entity-name", entityName); runFlow.addParameter("flow-name", flowName); runFlow.addParameter("job-id", UUID.randomUUID().toString());
.withTransform( new ServerTransform(transform) .addParameter("newValue", "test1a")
@Test public void testResultIgnore() throws Exception { DocumentMetadataHandle meta = new DocumentMetadataHandle().withCollections(collection); // write the document client.newDocumentManager().writeAs(collection + "/test2.json", meta, "{ \"testProperty\": \"test2\" }"); StructuredQueryDefinition query = sqb.value(sqb.jsonProperty("testProperty"), "test2"); ServerTransform transform = new ServerTransform(transformName2) .addParameter("newValue", "test2a"); ApplyTransformListener listener = new ApplyTransformListener() .withTransform(transform) .withApplyResult(ApplyResult.IGNORE); QueryBatcher batcher = moveMgr.newQueryBatcher(query) .onUrisReady(listener); JobTicket ticket = moveMgr.startJob( batcher ); batcher.awaitCompletion(); moveMgr.stopJob(ticket); JsonNode docContents = docMgr.readAs(collection + "/test2.json", JsonNode.class); assertEquals( "the transform should have changed testProperty to 'test2a'", "test2a", docContents.get("testProperty").textValue() ); }
@Test public void testResultReplace() throws Exception { DocumentMetadataHandle meta = new DocumentMetadataHandle().withCollections(collection); // write the document client.newDocumentManager().writeAs(collection + "/test1.json", meta, "{ \"testProperty\": \"test1\" }"); StructuredQueryDefinition query = sqb.value(sqb.jsonProperty("testProperty"), "test1"); ServerTransform transform = new ServerTransform(transformName1) .addParameter("newValue", "test1a"); ApplyTransformListener listener = new ApplyTransformListener() .withTransform(transform) .withApplyResult(ApplyResult.REPLACE); QueryBatcher batcher = moveMgr.newQueryBatcher(query) .onUrisReady(listener); JobTicket ticket = moveMgr.startJob( batcher ); batcher.awaitCompletion(); moveMgr.stopJob(ticket); JsonNode docContents = docMgr.readAs(collection + "/test1.json", JsonNode.class); assertEquals( "the transform should have changed testProperty to 'test1a'", "test1a", docContents.get("testProperty").textValue() ); }
final AtomicInteger count2 = new AtomicInteger(0); ServerTransform transform = new ServerTransform(transformName1) .addParameter("newValue", "test3a"); ApplyTransformListener listener = new ApplyTransformListener() .withTransform(transform)
ServerTransform serverTransform = new ServerTransform(transform); if (passJobId) { serverTransform.addParameter("job-id", UUID.randomUUID().toString()); serverTransform.addParameter("entity-name", ENTITY); serverTransform.addParameter("flow-name", flowName); String optionString = toJsonString(options); serverTransform.addParameter("options", optionString); FileHandle handle = new FileHandle(getResourceFile("e2e-test/input/input" + fileSuffix + "." + dataFormat.toString())); Format format = null;
ServerTransform serverTransform = new ServerTransform(transform); if (passJobId) { serverTransform.addParameter("job-id", UUID.randomUUID().toString()); serverTransform.addParameter("entity-name", ENTITY); serverTransform.addParameter("flow-name", flowName); String optionString = toJsonString(options); serverTransform.addParameter("options", optionString); FileHandle handle = new FileHandle(getResourceFile("e2e-test/input/input" + fileSuffix + "." + dataFormat.toString())); Format format = null;
XMLDocumentManager docMgr = Common.client.newXMLDocumentManager(); ServerTransform transform = new ServerTransform(TransformExtensionsTest.XQUERY_NAME) .addParameter("value", "true"); docMgr.setWriteTransform(transform); DocumentWriteSet writeset =docMgr.newWriteSet();