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


Java TestRunner.assertTransferCount方法代码示例

本文整理汇总了Java中org.apache.nifi.util.TestRunner.assertTransferCount方法的典型用法代码示例。如果您正苦于以下问题:Java TestRunner.assertTransferCount方法的具体用法?Java TestRunner.assertTransferCount怎么用?Java TestRunner.assertTransferCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.nifi.util.TestRunner的用法示例。


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

示例1: payloadWithBadFloatSubstitution

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void payloadWithBadFloatSubstitution() {

    String payload = "{\"pi\": \"{{pi:float}}\"}";
    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("pi", "This is not a float!");
    ff = session.putAllAttributes(ff, props);
    runner.enqueue(ff);
    runner.run();

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

    FlowFile actualFlowFile = runner.getFlowFilesForRelationship(CreateJsonContent.REL_FAILURE).get(0);
    assertEquals("$.pi", actualFlowFile.getAttribute("json.error.key"));
    assertEquals("This is not a float!", actualFlowFile.getAttribute("json.error.value"));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:24,代码来源:CreateJsonContentTest.java

示例2: testNoResults

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testNoResults() throws Exception {
    final TestRunner runner = TestRunners.newTestRunner(new QueryMongo());
    addMongoService(runner);
    runner.setProperty(MongoProps.DATABASE, MONGO_DATABASE_NAME);
    runner.setProperty(MongoProps.COLLECTION, "insert_test");
    runner.setProperty(MongoProps.QUERY, "{\"criteria\": \"${test_attribute}\"}");

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    ff = session.putAttribute(ff, "test_attribute", "98765");

    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(AbstractMongoProcessor.REL_FAILURE, 0);
    runner.assertTransferCount(AbstractMongoProcessor.REL_SUCCESS, 0);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:19,代码来源:QueryMongoIT.java

示例3: payloadWithoutSubstitutions

import org.apache.nifi.util.TestRunner; //导入方法依赖的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

示例4: payloadWithSubstitutions

import org.apache.nifi.util.TestRunner; //导入方法依赖的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

示例5: payloadWithTokenAttributes

import org.apache.nifi.util.TestRunner; //导入方法依赖的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

示例6: insert_refined_payload_test

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void insert_refined_payload_test() throws Exception {
    final TestRunner runner = TestRunners.newTestRunner(new StoreInMongo());
    addMongoService(runner);
    runner.setProperty(MongoProps.DATABASE, MONGO_DATABASE_NAME);
    runner.setProperty(MongoProps.COLLECTION, "insert_test");

    String contents = FileUtils.readFileToString(Paths.get("src/test/resources/payload.json").toFile());

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

    runner.assertTransferCount(AbstractMongoProcessor.REL_FAILURE, 0);
    runner.assertTransferCount(AbstractMongoProcessor.REL_SUCCESS, 1);

    // Verify Wrapped Payload
    MockFlowFile out = runner.getFlowFilesForRelationship(AbstractMongoProcessor.REL_SUCCESS).get(0);
    BasicDBObject actual = (BasicDBObject) JSON.parse(new String(out.toByteArray(), StandardCharsets.UTF_8));
    assertNotNull(actual.getString("d"));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:21,代码来源:StoreInMongoIT.java

示例7: testBackPressured

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testBackPressured() {
    final TestRunner runner = TestRunners.newTestRunner(RouteOnBackPressure.class);
    runner.assertValid();

    for (int i = 0; i < 100; ++i) {
        runner.enqueue(new byte[0]);
    }

    runner.run(100);

    runner.assertTransferCount(RouteOnBackPressure.PASS_THROUGH, 100);
    runner.assertTransferCount(RouteOnBackPressure.BACK_PRESSURED, 0);

    runner.setRelationshipUnavailable(RouteOnBackPressure.PASS_THROUGH);

    for (int i = 0; i < 100; ++i) {
        runner.enqueue(new byte[0]);
    }

    runner.run(100);

    runner.assertTransferCount(RouteOnBackPressure.PASS_THROUGH, 100);
    runner.assertTransferCount(RouteOnBackPressure.BACK_PRESSURED, 100);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:26,代码来源:RouteOnBackPressureTest.java

示例8: testMalformedJsonUpdate

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testMalformedJsonUpdate() throws Exception {
    final TestRunner runner = TestRunners.newTestRunner(new UpdateMongo());
    addMongoService(runner);
    runner.setProperty(MongoProps.DATABASE, MONGO_DATABASE_NAME);
    runner.setProperty(MongoProps.COLLECTION, "insert_test");
    runner.setProperty(MongoProps.UPDATE_QUERY_KEYS, "d.id");
    runner.setProperty(MongoProps.UPDATE_KEYS, "d.media");
    runner.setProperty(MongoProps.UPDATE_OPERATOR, "$push");

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

    runner.assertTransferCount(AbstractMongoProcessor.REL_FAILURE, 1);
    runner.assertTransferCount(AbstractMongoProcessor.REL_SUCCESS, 0);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:17,代码来源:UpdateMongoIT.java

示例9: testQuery

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testQuery() throws Exception {
    final TestRunner runner = TestRunners.newTestRunner(new QueryMongo());
    addMongoService(runner);
    runner.setProperty(MongoProps.DATABASE, MONGO_DATABASE_NAME);
    runner.setProperty(MongoProps.COLLECTION, "insert_test");
    runner.setProperty(MongoProps.QUERY, "{\"criteria\": \"${test_attribute}\"}");

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    ff = session.putAttribute(ff, "test_attribute", "12345");

    runner.enqueue(ff);
    runner.run();

    runner.assertTransferCount(AbstractMongoProcessor.REL_FAILURE, 0);
    runner.assertTransferCount(AbstractMongoProcessor.REL_SUCCESS, 1);

    MockFlowFile out = runner.getFlowFilesForRelationship(AbstractMongoProcessor.REL_SUCCESS).get(0);
    BasicDBObject actual = (BasicDBObject) JSON.parse(new String(out.toByteArray(), StandardCharsets.UTF_8));
    assertEquals("[ \"12345\" , \"23456\" , \"34567\"]", actual.getString("criteria"));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:23,代码来源:QueryMongoIT.java

示例10: singleAttributeTest

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void singleAttributeTest() {
    TestRunner runner = TestRunners.newTestRunner(Md5HashAttributes.class);
    runner.setProperty("hash", "${attribute1}");

    ProcessSession session = runner.getProcessSessionFactory().createSession();
    FlowFile ff = session.create();
    ff = session.putAttribute(ff, "attribute1", "pbs.twimg.com/media/ClvFsHiUgAE4fT6.jpg");
    runner.enqueue(ff);
    runner.run();


    // All results were processed with out failure
    runner.assertQueueEmpty();

    runner.assertTransferCount(Md5HashAttributes.REL_SUCCESS, 1);

    // If you need to read or do additional tests on results you can access the content
    List<MockFlowFile> results = runner.getFlowFilesForRelationship(Md5HashAttributes.REL_SUCCESS);
    assertTrue("1 match", results.size() == 1);
    MockFlowFile result = results.get(0);

    result.assertAttributeEquals("hash", "e2c26a2479f497562a615a42ecb1ef7e");
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:25,代码来源:Md5HashAttributesTest.java

示例11: payloadWithSpecialCharacters

import org.apache.nifi.util.TestRunner; //导入方法依赖的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

示例12: insert_test

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void insert_test() throws Exception {
    final TestRunner runner = TestRunners.newTestRunner(new StoreInMongo());
    addMongoService(runner);
    runner.setProperty(MongoProps.DATABASE, MONGO_DATABASE_NAME);
    runner.setProperty(MongoProps.COLLECTION, "insert_test");

    runner.enqueue("{\"a\":\"a\"}".getBytes());
    runner.run();

    runner.assertTransferCount(AbstractMongoProcessor.REL_FAILURE, 0);
    runner.assertTransferCount(AbstractMongoProcessor.REL_SUCCESS, 1);

    // Verify Wrapped Payload
    MockFlowFile out = runner.getFlowFilesForRelationship(AbstractMongoProcessor.REL_SUCCESS).get(0);
    BasicDBObject actual = (BasicDBObject) JSON.parse(new String(out.toByteArray(), StandardCharsets.UTF_8));
    assertEquals("a", actual.getString("a"));
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:19,代码来源:StoreInMongoIT.java

示例13: payloadWithSpacesWithinDelimiters

import org.apache.nifi.util.TestRunner; //导入方法依赖的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

示例14: payloadWithSpanishCharacters

import org.apache.nifi.util.TestRunner; //导入方法依赖的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

示例15: testTrueHeaderCreation

import org.apache.nifi.util.TestRunner; //导入方法依赖的package包/类
@Test
public void testTrueHeaderCreation() {
    TestRunner runner = TestRunners.newTestRunner(new GenerateTimeSeriesFlowFile());
    runner.setProperty(GenerateTimeSeriesFlowFile.PRINT_HEADER, "true");
    runner.setProperty(GenerateTimeSeriesFlowFile.SIMULATOR_CONFIG, getClass().getResource("/configs/unitTestConfig.json").getPath());
    runner.setProperty(GenerateTimeSeriesFlowFile.DATA_FORMAT, "CSV");
    runner.run();
    runner.assertTransferCount(GenerateTimeSeriesFlowFile.SUCCESS, 1);
    runner.getFlowFilesForRelationship(GenerateTimeSeriesFlowFile.SUCCESS).get(0).assertContentEquals("name, ts, value" + System.lineSeparator() + "test,2016-01-01T00:00:00.000,17.5");
}
 
开发者ID:hashmapinc,项目名称:nifi-simulator-bundle,代码行数:11,代码来源:GenerateTimeSeriesFlowfileTest.java


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