コード例 #1
0
  @Test
  public void readAirlineCompanyCSVFileWithOneRecordTest() throws IOException, ParseException {
    Files.deleteIfExists(Paths.get(projectPath + CSVFileTest.AIRLINECOMPANYCSV.value()));

    AirlineCompany airlineCompany = new AirlineCompany();
    airlineCompany.setAirline("Cathay Pacific Airways");

    ArrayList<AirlineCompany> airlineCompanies = new ArrayList<AirlineCompany>();
    airlineCompanies.add(airlineCompany);

    SourceWriter<List<AirlineCompany>> airlineCompanyCSVFileWriter =
        new AirlineCompanyCSVFileWriter(projectPath + CSVFileTest.AIRLINECOMPANYCSV.value());
    airlineCompanyCSVFileWriter.write(airlineCompanies);
    airlineCompanyCSVFileWriter.close();

    SourceReader<AirlineCompany> airlineCompanyCSVFileReader =
        new AirlineCompanyCSVFileReader(projectPath + CSVFileTest.AIRLINECOMPANYCSV.value());
    List<AirlineCompany> airlineCompanyResultList =
        airlineCompanyCSVFileReader.read(new AirlineCompanyParser());
    airlineCompanyCSVFileReader.close();

    assertThat(airlineCompany.getAirline(), is(airlineCompanyResultList.get(0).getAirline()));

    assertThat(
        airlineCompany.getFlights().size(),
        is(airlineCompanyResultList.get(0).getFlights().size()));
  }
コード例 #2
0
  @Test
  public void readAirlineCompanyCSVFileWithThreeRecordTest() throws IOException, ParseException {
    Files.deleteIfExists(Paths.get(projectPath + CSVFileTest.AIRLINECOMPANYCSV.value()));

    AirlineCompany airlineCompanyCP = new AirlineCompany();
    airlineCompanyCP.setAirline("Cathay Pacific Airways");

    AirlineCompany airlineCompanyCA = new AirlineCompany();
    airlineCompanyCA.setAirline("China Airlines");

    AirlineCompany airlineCompanyHKA = new AirlineCompany();
    airlineCompanyHKA.setAirline("Hong Kong Airlines");

    ArrayList<AirlineCompany> airlineCompanies = new ArrayList<AirlineCompany>();
    airlineCompanies.add(airlineCompanyCP);
    airlineCompanies.add(airlineCompanyCA);
    airlineCompanies.add(airlineCompanyHKA);

    SourceWriter<List<AirlineCompany>> airlineCompanyCSVFileWriter =
        new AirlineCompanyCSVFileWriter(projectPath + CSVFileTest.AIRLINECOMPANYCSV.value());
    airlineCompanyCSVFileWriter.write(airlineCompanies);
    airlineCompanyCSVFileWriter.close();

    SourceReader<AirlineCompany> airlineCompanyCSVFileReader =
        new AirlineCompanyCSVFileReader(projectPath + CSVFileTest.AIRLINECOMPANYCSV.value());
    List<AirlineCompany> airlineCompanyResultList =
        airlineCompanyCSVFileReader.read(new AirlineCompanyParser());
    airlineCompanyCSVFileReader.close();

    assertThat(airlineCompanies.size(), is(airlineCompanyResultList.size()));

    for (int i = 0; i < airlineCompanies.size(); i++) {
      assertThat(
          airlineCompanies.get(i).getAirline(), is(airlineCompanyResultList.get(i).getAirline()));
    }

    assertThat(
        airlineCompanyCP.getFlights().size(),
        is(airlineCompanyResultList.get(0).getFlights().size()));
  }