• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MockFlowFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testSingleFlowId

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void testSingleFlowId() {
    String data = "a";
    int n = 20;
    for (int i = 0; i < n; i++) {
        Map<String, String> attributes = new HashMap<>();
        attributes.put(FLOWID, "foobar");
        runner.enqueue(data, attributes);
    }
    runner.run();

    // all 20 originals emitted, 1 stats file
    runner.assertTransferCount(AbstractStatsProcessor.REL_STATS, 1);
    MockFlowFile flowFile = runner.getFlowFilesForRelationship(AbstractStatsProcessor.REL_STATS).get(0);

    int count = n;
    assertEquals(count, Integer.parseInt(flowFile.getAttribute("CalculateBytesTransferred.count")));
    assertEquals(count, Double.parseDouble(flowFile.getAttribute("CalculateBytesTransferred.sum")), 1e-6);
    assertEquals(1, Double.parseDouble(flowFile.getAttribute("CalculateBytesTransferred.min")), 1e-6);
    assertEquals(1, Double.parseDouble(flowFile.getAttribute("CalculateBytesTransferred.max")), 1e-6);
    assertEquals(1.0, Double.parseDouble(flowFile.getAttribute("CalculateBytesTransferred.avg")), 1e-6);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:23,代码来源:CalculateBytesTransferredTest.java


示例17: testMultipleFlowId

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void testMultipleFlowId() {
    String data = "a";
    int n = 20;
    for (int i = 0; i < n; i++) {
        Map<String, String> attributes = new HashMap<>();
        attributes.put(FLOWID, "foo");
        runner.enqueue(data, attributes);
        attributes.put(FLOWID, "bar");
        runner.enqueue(data, attributes);
    }
    runner.run();

    // all 20 originals emitted, 1 stats file
    runner.assertTransferCount(AbstractStatsProcessor.REL_STATS, 2);
    MockFlowFile flowFile = runner.getFlowFilesForRelationship(AbstractStatsProcessor.REL_STATS).get(0);

    int count = n/2;
    assertEquals(count, Integer.parseInt(flowFile.getAttribute("CalculateBytesTransferred.count")));
    assertEquals(count, Double.parseDouble(flowFile.getAttribute("CalculateBytesTransferred.sum")), 1e-6);
    assertEquals(1, Double.parseDouble(flowFile.getAttribute("CalculateBytesTransferred.min")), 1e-6);
    assertEquals(1, Double.parseDouble(flowFile.getAttribute("CalculateBytesTransferred.max")), 1e-6);
    assertEquals(1.0, Double.parseDouble(flowFile.getAttribute("CalculateBytesTransferred.avg")), 1e-6);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:25,代码来源:CalculateBytesTransferredTest.java


示例18: testValidInput

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void testValidInput() throws Exception {
    // run once to begin the reporting interval timer
    runner.run();

    // sleep for the remainder of the reporting interval
    Thread.sleep(1000);

    // send 20 files through
    for (int i = 0; i < 20; i++) {
        runner.enqueue(data, attributes);
    }
    runner.run();

    // all 20 originals emitted
    runner.assertTransferCount(AbstractStatsProcessor.REL_ORIGINAL, 20);
    for (MockFlowFile f : runner.getFlowFilesForRelationship(AbstractStatsProcessor.REL_ORIGINAL)) {
        f.assertContentEquals(data);
    }

    // 1 stats report emitted
    runner.assertTransferCount(AbstractStatsProcessor.REL_STATS, 1);
    MockFlowFile flowFile = runner.getFlowFilesForRelationship(AbstractStatsProcessor.REL_STATS).get(0);
    assertEquals(0, flowFile.getSize());
    assertStatAttributesPresent(flowFile);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CalculateLatencyStatisticsTest.java


示例19: testInputMissingAttributeName

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void testInputMissingAttributeName() throws Exception {
    runner.setProperty(CalculateLatencyStatistics.ATTR_NAME, "DOES_NOT_EXIST");
    runner.assertValid();

    for (int i = 0; i < 20; i++) {
        runner.enqueue(data, attributes);
    }
    runner.run();

    // nothing was aggregated, so no stats emitted
    runner.assertTransferCount(AbstractStatsProcessor.REL_STATS, 0);

    // nothing was aggregated, so originals are emitted without additional stat attributes
    runner.assertTransferCount(AbstractStatsProcessor.REL_ORIGINAL, 20);
    for (MockFlowFile f : runner.getFlowFilesForRelationship(AbstractStatsProcessor.REL_ORIGINAL)) {
        f.assertContentEquals(data);
        assertStatAttributesNotPresent(f);
    }
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:21,代码来源:CalculateLatencyStatisticsTest.java


示例20: testSomeFlowfilesMissingCorrelationAttributeValues

import org.apache.nifi.util.MockFlowFile; //导入依赖的package包/类
@Test
public void testSomeFlowfilesMissingCorrelationAttributeValues() {
    runner.setProperty(CalculateLatencyStatistics.CORRELATION_ATTR, "flowId");
    runner.assertValid();

    Map<String, String> attrs = new HashMap<>(attributes);
    for (int i = 0; i < 10; i++) {
        attrs.put("flowId", "foobar");
        runner.enqueue(data, attrs);
    }
    for (int i = 0; i < 10; i++) {
        runner.enqueue(data, attributes);
    }
    runner.run();
    runner.assertTransferCount(AbstractStatsProcessor.REL_STATS, 2);

    MockFlowFile foobarFlowFile = runner.getFlowFilesForRelationship(AbstractStatsProcessor.REL_STATS).get(0);
    assertStatAttributesPresent(foobarFlowFile);
    assertEquals(10, Integer.parseInt(foobarFlowFile.getAttribute("CalculateLatencyStatistics.count")));
    assertEquals(DEFAULT_MOMENT_AGGREGATOR_KEY, foobarFlowFile.getAttribute("AbstractStatsProcessor.correlationKey"));

    MockFlowFile flowFile = runner.getFlowFilesForRelationship(AbstractStatsProcessor.REL_STATS).get(1);
    assertStatAttributesPresent(flowFile);
    assertEquals(10, Integer.parseInt(flowFile.getAttribute("CalculateLatencyStatistics.count")));
    assertEquals("foobar", flowFile.getAttribute("AbstractStatsProcessor.correlationKey"));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:27,代码来源:CalculateLatencyStatisticsTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ActivityEvent类代码示例发布时间:2022-05-21
下一篇:
Java TupleQueryResult类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap