Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/426#discussion_r26994167
  
    --- Diff: 
flink-tests/src/test/java/org/apache/flink/test/io/CsvReaderWithPOJOITCase.java 
---
    @@ -0,0 +1,132 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.test.io;
    +
    +import com.google.common.base.Charsets;
    +import com.google.common.io.Files;
    +import org.apache.flink.api.common.functions.MapFunction;
    +import org.apache.flink.api.java.DataSet;
    +import org.apache.flink.api.java.ExecutionEnvironment;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.test.util.MultipleProgramsTestBase;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.rules.TemporaryFolder;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.Parameterized;
    +
    +import java.io.File;
    +
    +@RunWith(Parameterized.class)
    +public class CsvReaderWithPOJOITCase extends MultipleProgramsTestBase {
    +   private String resultPath;
    +   private String expected;
    +
    +   @Rule
    +   public TemporaryFolder tempFolder = new TemporaryFolder();
    +
    +   public CsvReaderWithPOJOITCase(ExecutionMode mode) {
    +           super(mode);
    +   }
    +
    +   @Before
    +   public void before() throws Exception {
    +           resultPath = tempFolder.newFile("result").toURI().toString();
    +   }
    +
    +   @After
    +   public void after() throws Exception {
    +           compareResultsByLinesInMemory(expected, resultPath);
    +   }
    +
    +   private String createInputData(String data) throws Exception {
    +           File file = tempFolder.newFile("input");
    +           Files.write(data, file, Charsets.UTF_8);
    +
    +           return file.toURI().toString();
    +   }
    +
    +   @Test
    +   public void testPOJOType() throws Exception {
    +           final String dataPath = 
createInputData("ABC,2.20,3\nDEF,5.1,5\nDEF,3.30,1\nGHI,3.30,10");
    +           final ExecutionEnvironment env = 
ExecutionEnvironment.getExecutionEnvironment();
    +
    +           DataSet<POJOItem> data = 
env.readCsvFile(dataPath).pojoType(POJOItem.class, new String[]{"f1", "f3", 
"f2"});
    +           DataSet<Tuple2<String, Integer>> result = data.map(new 
POJOToTupleMapper()).groupBy(0).sum(1);
    --- End diff --
    
    I would remove the `POJOToTupleMapper` and the aggregation and instead 
directly emit the POJO data with `writeAsText()`. This will use the 
`toString()` method of the POJO to write the data.
    Simplifies the test and restricts it to the essential part.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to