Esempio n. 1
0
  @Test
  public void testMapperOnCustomLowercaseString() throws Exception {
    /*
     * Test mapper on Custom - lowercase myString
     */

    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

    DataSet<CustomType> ds = CollectionDataSets.getCustomTypeDataSet(env);
    DataSet<CustomType> customMapDs = ds.map(new Mapper6());

    List<CustomType> result = customMapDs.collect();

    String expected =
        "1,0,hi\n"
            + "2,1,hello\n"
            + "2,2,hello world\n"
            + "3,3,hello world, how are you?\n"
            + "3,4,i am fine.\n"
            + "3,5,luke skywalker\n"
            + "4,6,comment#1\n"
            + "4,7,comment#2\n"
            + "4,8,comment#3\n"
            + "4,9,comment#4\n"
            + "5,10,comment#5\n"
            + "5,11,comment#6\n"
            + "5,12,comment#7\n"
            + "5,13,comment#8\n"
            + "5,14,comment#9\n"
            + "6,15,comment#10\n"
            + "6,16,comment#11\n"
            + "6,17,comment#12\n"
            + "6,18,comment#13\n"
            + "6,19,comment#14\n"
            + "6,20,comment#15\n";

    compareResultAsText(result, expected);
  }
Esempio n. 2
0
  @Test
  public void testTypeConversionMapperCustomToTuple() throws Exception {
    /*
     * Test type conversion mapper (Custom -> Tuple)
     */

    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

    DataSet<CustomType> ds = CollectionDataSets.getCustomTypeDataSet(env);
    DataSet<Tuple3<Integer, Long, String>> typeConversionMapDs = ds.map(new Mapper3());

    List<Tuple3<Integer, Long, String>> result = typeConversionMapDs.collect();

    String expected =
        "1,0,Hi\n"
            + "2,1,Hello\n"
            + "2,2,Hello world\n"
            + "3,3,Hello world, how are you?\n"
            + "3,4,I am fine.\n"
            + "3,5,Luke Skywalker\n"
            + "4,6,Comment#1\n"
            + "4,7,Comment#2\n"
            + "4,8,Comment#3\n"
            + "4,9,Comment#4\n"
            + "5,10,Comment#5\n"
            + "5,11,Comment#6\n"
            + "5,12,Comment#7\n"
            + "5,13,Comment#8\n"
            + "5,14,Comment#9\n"
            + "6,15,Comment#10\n"
            + "6,16,Comment#11\n"
            + "6,17,Comment#12\n"
            + "6,18,Comment#13\n"
            + "6,19,Comment#14\n"
            + "6,20,Comment#15\n";

    compareResultAsTuples(result, expected);
  }