// Path: src/main/java/io/github/sskorol/data/CsvReader.java
// @AllArgsConstructor
// public class CsvReader<T> implements DataReader<T> {
// 
//     @Getter
//     private final Class<T> entityClass;
//     @Getter
//     private final String path;
// 
//     public CsvReader(final Class<T> entityClass) {
//         this(entityClass, "");
//     }
// 
//     @Override
//     public StreamEx<T> read() {
//         try (val csvParser = parse(getUrl(), StandardCharsets.UTF_8,
//                 CSVFormat.Builder.create().setHeader().setSkipHeaderRecord(true).setIgnoreHeaderCase(true).setTrim(true).build())) {
//             val entityFields = StreamEx.of(entityClass.getDeclaredFields()).map(ReflectionUtils::getFieldName).toList();
//             return StreamEx.of(csvParser.getRecords())
//                     .map(csvRecord -> StreamEx.of(entityFields).map(csvRecord::get).toArray())
//                     .map(args -> onClass(entityClass).create(args).get());
//         } catch (IOException ex) {
//             throw new IllegalArgumentException(
//                     format("Unable to read CSV data to %s. Check provided path.", entityClass), ex);
//         }
//     }
// }
// 
// Path: src/test/java/io/github/sskorol/entities/CrimeRecord.java
// @Source(path = "https://raw.githubusercontent.com/JuliaData/CSV.jl/main/test/testfiles/SacramentocrimeJanuary2006.csv")
// @Data
// public class CrimeRecord {
// 
//     private final String address;
//     @FieldName("crimedescr")
//     private final String description;
// }
// 
// Path: src/test/java/io/github/sskorol/entities/MissingClient.java
// @Source(path = "unknown")
// @Data
// public class MissingClient {
// 
//     private final String firstName;
//     private final String lastName;
// }
// 
// Path: src/test/java/io/github/sskorol/entities/User.java
// @Data
// public class User {
// 
//     @FieldName("username")
//     private final String name;
//     private final String password;
// }
// 
// Path: src/main/java/io/github/sskorol/data/TestDataReader.java
// public static <T extends DataReader<?>> TestDataReader<T> use(final Class<T> dataReaderClass) {
//     return new TestDataReader<>(dataReaderClass);
// }


import io.github.sskorol.core.DataSupplier;
import io.github.sskorol.data.CsvReader;
import io.github.sskorol.entities.CrimeRecord;
import io.github.sskorol.entities.MissingClient;
import io.github.sskorol.entities.User;
import one.util.streamex.StreamEx;
import org.testng.annotations.Test;
import static io.github.sskorol.data.TestDataReader.use;
package io.github.sskorol.testcases;



public class CsvDataSupplierTests {

    @DataSupplier
    public StreamEx<User> getUsers() {
        return use(CsvReader.class)
            .withTarget(User.class)
            .withSource("users.csv")
            .read();
    }

    @DataSupplier
    public StreamEx<CrimeRecord> getCrimes() {
        return use(CsvReader.class)
            .withTarget(CrimeRecord.class)
            .read()
            .limit(1);
    }

    @DataSupplier
    public StreamEx<MissingClient> getMissingClient() {
// Path: src/main/java/io/github/sskorol/data/CsvReader.java
// @AllArgsConstructor
// public class CsvReader<T> implements DataReader<T> {
// 
//     @Getter
//     private final Class<T> entityClass;
//     @Getter
//     private final String path;
// 
//     public CsvReader(final Class<T> entityClass) {
//         this(entityClass, "");
//     }
// 
//     @Override
//     public StreamEx<T> read() {
//         try (val csvParser = parse(getUrl(), StandardCharsets.UTF_8,
//                 CSVFormat.Builder.create().setHeader().setSkipHeaderRecord(true).setIgnoreHeaderCase(true).setTrim(true).build())) {
//             val entityFields = StreamEx.of(entityClass.getDeclaredFields()).map(ReflectionUtils::getFieldName).toList();
//             return StreamEx.of(csvParser.getRecords())
//                     .map(csvRecord -> StreamEx.of(entityFields).map(csvRecord::get).toArray())
//                     .map(args -> onClass(entityClass).create(args).get());
//         } catch (IOException ex) {
//             throw new IllegalArgumentException(
//                     format("Unable to read CSV data to %s. Check provided path.", entityClass), ex);
//         }
//     }
// }
// 
// Path: src/test/java/io/github/sskorol/entities/CrimeRecord.java
// @Source(path = "https://raw.githubusercontent.com/JuliaData/CSV.jl/main/test/testfiles/SacramentocrimeJanuary2006.csv")
// @Data
// public class CrimeRecord {
// 
//     private final String address;
//     @FieldName("crimedescr")
//     private final String description;
// }
// 
// Path: src/test/java/io/github/sskorol/entities/MissingClient.java
// @Source(path = "unknown")
// @Data
// public class MissingClient {
// 
//     private final String firstName;
//     private final String lastName;
// }
// 
// Path: src/test/java/io/github/sskorol/entities/User.java
// @Data
// public class User {
// 
//     @FieldName("username")
//     private final String name;
//     private final String password;
// }
// 
// Path: src/main/java/io/github/sskorol/data/TestDataReader.java
// public static <T extends DataReader<?>> TestDataReader<T> use(final Class<T> dataReaderClass) {
//     return new TestDataReader<>(dataReaderClass);
// }


// Path: src/test/java/io/github/sskorol/testcases/CsvDataSupplierTests.java
import io.github.sskorol.core.DataSupplier;
import io.github.sskorol.data.CsvReader;
import io.github.sskorol.entities.CrimeRecord;
import io.github.sskorol.entities.MissingClient;
import io.github.sskorol.entities.User;
import one.util.streamex.StreamEx;
import org.testng.annotations.Test;
import static io.github.sskorol.data.TestDataReader.use;

package io.github.sskorol.testcases;



public class CsvDataSupplierTests {

    @DataSupplier
    public StreamEx<User> getUsers() {
        return use(CsvReader.class)
            .withTarget(User.class)
            .withSource("users.csv")
            .read();
    }

    @DataSupplier
    public StreamEx<CrimeRecord> getCrimes() {
        return use(CsvReader.class)
            .withTarget(CrimeRecord.class)
            .read()
            .limit(1);
    }

    @DataSupplier
    public StreamEx<MissingClient> getMissingClient() {
        return use(CsvReader.class).withTarget(MissingClient.class).read();