当前位置: 首页>>代码示例>>Java>>正文


Java MockFlowFile类代码示例

本文整理汇总了Java中org.apache.nifi.util.MockFlowFile的典型用法代码示例。如果您正苦于以下问题:Java MockFlowFile类的具体用法?Java MockFlowFile怎么用?Java MockFlowFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MockFlowFile类属于org.apache.nifi.util包,在下文中一共展示了MockFlowFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: payloadWithoutSubstitutions

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithoutSubstitutions() {

    String payload = "{\"a\": \"a\"}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateContent());
    runner.setProperty(CreateContent.CONTENT_FIELD, payload);

    runner.enqueue(payload.getBytes());
    runner.run();

    runner.assertTransferCount(CreateContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateContent.REL_ORIGINAL, 1);

    final MockFlowFile out = runner.getFlowFilesForRelationship(CreateContent.REL_SUCCESS).get(0);
    assertEquals(payload, new String(out.toByteArray()));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:18,代码来源:CreateContentTest.java

示例2: payloadWithSubstitutions

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithSubstitutions() {

    String payload = "{\"a\": {{from}}, \"pi\": {{pi}}, \"boolean\": {{boolean}}}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateContent());
    runner.setProperty(CreateContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "\"[email protected]\"");
    props.put("pi", "3.14");
    props.put("boolean", "true");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateContent.REL_ORIGINAL, 1);

    String expected = "{\"a\": \"[email protected]\", \"pi\": 3.14, \"boolean\": true}";
    final MockFlowFile out = runner.getFlowFilesForRelationship(CreateContent.REL_SUCCESS).get(0);
    assertEquals(expected, new String(out.toByteArray()));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:26,代码来源:CreateContentTest.java

示例3: payloadWithMissingAttributes

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithMissingAttributes() {

    String payload = "{\"a\": {{from}}, \"pi\": {{pi}}, \"boolean\": {{boolean}}}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateContent());
    runner.setProperty(CreateContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "\"[email protected]\"");
    props.put("pi", "3.14");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateContent.REL_ORIGINAL, 1);

    String expected = "{\"a\": \"[email protected]\", \"pi\": 3.14, \"boolean\": null}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:26,代码来源:CreateContentTest.java

示例4: payloadWithTokenAttributes

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithTokenAttributes() {

    String payload = "{\"a\": {{from}}, \"pi\": {{pi}}, \"text\": {{text}}}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateContent());
    runner.setProperty(CreateContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "\"[email protected]\"");
    props.put("pi", "3.14");
    props.put("text", "\"here is some {{text}}\"");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateContent.REL_ORIGINAL, 1);

    String expected = "{\"a\": \"[email protected]\", \"pi\": 3.14, \"text\": \"here is some {{text}}\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateContentTest.java

示例5: payloadWithSpecialCharacters

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithSpecialCharacters() {

    String payload = "{\"a\": {{from}}, \"pi\": {{pi}}, \"text\": {{text}}}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateContent());
    runner.setProperty(CreateContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "\"[email protected]\"");
    props.put("pi", "3.14");
    props.put("text", "\"here is some &$^()}{{}[email protected]#\"");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateContent.REL_ORIGINAL, 1);

    String expected = "{\"a\": \"[email protected]\", \"pi\": 3.14, \"text\": \"here is some &$^()}{{}[email protected]#\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateContentTest.java

示例6: payloadWithDoubleQuotes

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithDoubleQuotes() {

    String payload = "{\"a\": {{from}}, \"pi\": {{pi}}, \"text\": {{text}}}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateContent());
    runner.setProperty(CreateContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "\"[email protected]\"");
    props.put("pi", "3.14");
    props.put("text", "\"here is some \"text\"\"");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateContent.REL_ORIGINAL, 1);

    String expected = "{\"a\": \"[email protected]\", \"pi\": 3.14, \"text\": \"here is some \"text\"\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateContentTest.java

示例7: payloadWithSpacesWithinDelimiters

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithSpacesWithinDelimiters() {

    String payload = "{\"a\": {{ from}}, \"pi\": {{pi }}, \"text\": {{ text }}}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateContent());
    runner.setProperty(CreateContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "\"[email protected]\"");
    props.put("pi", "3.14");
    props.put("text", "\"here is some text\"");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateContent.REL_ORIGINAL, 1);

    String expected = "{\"a\": \"[email protected]\", \"pi\": 3.14, \"text\": \"here is some text\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateContentTest.java

示例8: payloadWithSpanishCharacters

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithSpanishCharacters() {

    String payload = "{\"a\": {{from}}, \"pi\": {{pi}}, \"text\": {{text}}}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateContent());
    runner.setProperty(CreateContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "\"[email protected]\"");
    props.put("pi", "3.14");
    props.put("text", "\"Mañana se me va un amigo capas el mejor que tuve y que voy a tener, te re quiero turrasdf Pasa que cada cosa que pienso/hago quiero contarle a mi él.  Quiero gelatina y la bastarda no se hace mas -.-\"");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateContent.REL_ORIGINAL, 1);

    String expected = "{\"a\": \"[email protected]\", \"pi\": 3.14, \"text\": \"Mañana se me va un amigo capas el mejor que tuve y que voy a tener, te re quiero turrasdf Pasa que cada cosa que pienso/hago quiero contarle a mi él.  Quiero gelatina y la bastarda no se hace mas -.-\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateContentTest.java

示例9: payloadWithSubstitutions

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithSubstitutions() {

    String payload = "{\"a\": \"{{from}}\", \"pi\": \"{{pi:float}}\", \"boolean\": \"{{boolean:bool}}\", \"long\": \"{{long:int}}\"}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateJsonContent());
    runner.setProperty(CreateJsonContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "[email protected]");
    props.put("pi", "3.14");
    props.put("long", "12345678901234");
    props.put("boolean", "true");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateJsonContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateJsonContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateJsonContent.REL_ORIGINAL, 1);

    String expected = "{\"a\":\"[email protected]\",\"pi\":3.14,\"boolean\":true,\"long\":12345678901234}";
    final MockFlowFile out = runner.getFlowFilesForRelationship(CreateJsonContent.REL_SUCCESS).get(0);
    assertEquals(expected, new String(out.toByteArray()));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateJsonContentTest.java

示例10: payloadWithMissingAttributes

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithMissingAttributes() {

    String payload = "{\"a\": \"{{from}}\", \"pi\": \"{{pi:float}}\", \"boolean\": \"{{boolean:bool}}\"}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateJsonContent());
    runner.setProperty(CreateJsonContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "[email protected]");
    props.put("pi", "3.14");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateJsonContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateJsonContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateJsonContent.REL_ORIGINAL, 1);

    String expected = "{\"a\":\"[email protected]\",\"pi\":3.14,\"boolean\":null}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateJsonContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:26,代码来源:CreateJsonContentTest.java

示例11: payloadWithTokenAttributes

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithTokenAttributes() {

    String payload = "{\"a\": \"{{from}}\", \"pi\": \"{{pi:float}}\", \"text\": \"{{text}}\"}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateJsonContent());
    runner.setProperty(CreateJsonContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "[email protected]");
    props.put("pi", "3.14");
    props.put("text", "\"here is some {{text}}\"");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateJsonContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateJsonContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateJsonContent.REL_ORIGINAL, 1);

    String expected = "{\"a\":\"[email protected]\",\"pi\":3.14,\"text\":\"\\\"here is some {{text}}\\\"\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateJsonContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateJsonContentTest.java

示例12: payloadWithSpecialCharacters

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithSpecialCharacters() {

    String payload = "{\"a\": \"{{from}}\", \"pi\": \"{{pi:float}}\", \"text\": \"{{text}}\"}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateJsonContent());
    runner.setProperty(CreateJsonContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "[email protected]");
    props.put("pi", "3.14");
    props.put("text", "\"here is some &$^()}{{}[email protected]#\"");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateJsonContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateJsonContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateJsonContent.REL_ORIGINAL, 1);

    String expected = "{\"a\":\"[email protected]\",\"pi\":3.14,\"text\":\"\\\"here is some &$^()}{{}[email protected]#\\\"\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateJsonContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateJsonContentTest.java

示例13: payloadWithDoubleQuotes

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithDoubleQuotes() {

    String payload = "{\"a\": \"{{from}}\", \"pi\": \"{{pi:float}}\", \"text\": \"{{text}}\"}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateJsonContent());
    runner.setProperty(CreateJsonContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "[email protected]");
    props.put("pi", "3.14");
    props.put("text", "here is some \"text\"");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateJsonContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateJsonContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateJsonContent.REL_ORIGINAL, 1);

    String expected = "{\"a\":\"[email protected]\",\"pi\":3.14,\"text\":\"here is some \\\"text\\\"\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateJsonContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateJsonContentTest.java

示例14: payloadWithSpacesWithinDelimiters

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithSpacesWithinDelimiters() {

    String payload = "{\"a\": \"{{ from}}\", \"pi\": \"{{pi }}\", \"text\": \" {{ text }} \"}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateJsonContent());
    runner.setProperty(CreateJsonContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "[email protected]");
    props.put("pi", "3.14");
    props.put("text", "here is some text");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateJsonContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateJsonContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateJsonContent.REL_ORIGINAL, 1);

    String expected = "{\"a\":\"[email protected]\",\"pi\":\"3.14\",\"text\":\"here is some text\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateJsonContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateJsonContentTest.java

示例15: payloadWithSpanishCharacters

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void payloadWithSpanishCharacters() {

    String payload = "{\"a\": \"{{from}}\", \"pi\": \"{{pi}}\", \"text\": \"{{text}}\"}";
    final TestRunner runner = TestRunners.newTestRunner(new CreateJsonContent());
    runner.setProperty(CreateJsonContent.CONTENT_FIELD, payload);

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    Map<String, String> props = new HashMap<>();
    props.put("from", "[email protected]");
    props.put("pi", "3.14");  // This should be a string representation of the number 3.14
    props.put("text", "Mañana se me va un amigo capas el mejor que tuve y que voy a tener, te re quiero turrasdf Pasa que cada cosa que pienso/hago quiero contarle a mi él.  Quiero gelatina y la bastarda no se hace mas -.-");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(CreateJsonContent.REL_FAILURE, 0);
    runner.assertTransferCount(CreateJsonContent.REL_SUCCESS, 1);
    runner.assertTransferCount(CreateJsonContent.REL_ORIGINAL, 1);

    String expected = "{\"a\":\"[email protected]\",\"pi\":\"3.14\",\"text\":\"Mañana se me va un amigo capas el mejor que tuve y que voy a tener, te re quiero turrasdf Pasa que cada cosa que pienso/hago quiero contarle a mi él.  Quiero gelatina y la bastarda no se hace mas -.-\"}";
    MockFlowFile out = runner.getFlowFilesForRelationship(CreateJsonContent.REL_SUCCESS).get(0);
    String actual = new String(out.toByteArray());
    assertEquals(expected, actual);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CreateJsonContentTest.java


注:本文中的org.apache.nifi.util.MockFlowFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。