// Path: src/main/java/io/github/sskorol/data/JsonReader.java
// @AllArgsConstructor
// public class JsonReader<T> implements DataReader<T> {
// 
//     @Getter
//     private final Class<T> entityClass;
//     @Getter
//     private final String path;
// 
//     public JsonReader(final Class<T> entityClass) {
//         this(entityClass, "");
//     }
// 
//     @SuppressWarnings("unchecked")
//     public StreamEx<T> read() {
//         var gson = new Gson();
//         try (var streamReader = new InputStreamReader(getUrl().openStream(), StandardCharsets.UTF_8);
//              var jsonReader = new com.google.gson.stream.JsonReader(streamReader)) {
//             return StreamEx.of((T[]) Match(parseReader(jsonReader)).of(
//                 Case($(JsonElement::isJsonArray), j -> gson.fromJson(j, castToArray(entityClass))),
//                 Case($(), j -> (T[]) new Object[] {gson.fromJson(j, castToObject(entityClass))})
//             ));
//         } catch (IOException ex) {
//             throw new IllegalArgumentException(
//                 format("Unable to read JSON data to %s. Check provided path.", entityClass), ex);
//         }
//     }
// }
// 
// Path: src/test/java/io/github/sskorol/entities/Animal.java
// @Data
// public class Animal {
// 
//     private final String name;
//     private final String species;
//     private final Food foods;
// }
// 
// Path: src/test/java/io/github/sskorol/entities/Client.java
// @Source(path = "client.json")
// @Data
// public class Client {
// 
//     private final String firstName;
//     private final String lastName;
// }
// 
// Path: src/test/java/io/github/sskorol/entities/JsonUser.java
// @Source(path = "users.json")
// @Data
// public class JsonUser {
// 
//     @SerializedName("username")
//     private final String name;
//     private final String password;
// }
// 
// 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/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.JsonReader;
import io.github.sskorol.entities.Animal;
import io.github.sskorol.entities.Client;
import io.github.sskorol.entities.JsonUser;
import io.github.sskorol.entities.MissingClient;
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 JsonDataSupplierTests {

    @DataSupplier
    public StreamEx<JsonUser> getUsers() {
        return use(JsonReader.class).withTarget(JsonUser.class).read();
    }

    @DataSupplier
    public StreamEx<Client> getClient() {
        return use(JsonReader.class).withTarget(Client.class).read();
    }

    @DataSupplier
    public StreamEx<Animal> getAnimals() {
        return use(JsonReader.class)
            .withTarget(Animal.class)
            .withSource("https://raw.githubusercontent.com/LearnWebCode/json-example/master/animals-1.json")
            .read();
    }

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

    @Test(dataProvider = "getUsers")
    public void shouldReadLocalJsonArray(final JsonUser user) {
        // not implemented
    }

    @Test(dataProvider = "getClient")
    public void shouldReadLocalJson(final Client client) {
        // not implemented
    }

    @Test(dataProvider = "getAnimals")
// Path: src/main/java/io/github/sskorol/data/JsonReader.java
// @AllArgsConstructor
// public class JsonReader<T> implements DataReader<T> {
// 
//     @Getter
//     private final Class<T> entityClass;
//     @Getter
//     private final String path;
// 
//     public JsonReader(final Class<T> entityClass) {
//         this(entityClass, "");
//     }
// 
//     @SuppressWarnings("unchecked")
//     public StreamEx<T> read() {
//         var gson = new Gson();
//         try (var streamReader = new InputStreamReader(getUrl().openStream(), StandardCharsets.UTF_8);
//              var jsonReader = new com.google.gson.stream.JsonReader(streamReader)) {
//             return StreamEx.of((T[]) Match(parseReader(jsonReader)).of(
//                 Case($(JsonElement::isJsonArray), j -> gson.fromJson(j, castToArray(entityClass))),
//                 Case($(), j -> (T[]) new Object[] {gson.fromJson(j, castToObject(entityClass))})
//             ));
//         } catch (IOException ex) {
//             throw new IllegalArgumentException(
//                 format("Unable to read JSON data to %s. Check provided path.", entityClass), ex);
//         }
//     }
// }
// 
// Path: src/test/java/io/github/sskorol/entities/Animal.java
// @Data
// public class Animal {
// 
//     private final String name;
//     private final String species;
//     private final Food foods;
// }
// 
// Path: src/test/java/io/github/sskorol/entities/Client.java
// @Source(path = "client.json")
// @Data
// public class Client {
// 
//     private final String firstName;
//     private final String lastName;
// }
// 
// Path: src/test/java/io/github/sskorol/entities/JsonUser.java
// @Source(path = "users.json")
// @Data
// public class JsonUser {
// 
//     @SerializedName("username")
//     private final String name;
//     private final String password;
// }
// 
// 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/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/JsonDataSupplierTests.java
import io.github.sskorol.core.DataSupplier;
import io.github.sskorol.data.JsonReader;
import io.github.sskorol.entities.Animal;
import io.github.sskorol.entities.Client;
import io.github.sskorol.entities.JsonUser;
import io.github.sskorol.entities.MissingClient;
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 JsonDataSupplierTests {

    @DataSupplier
    public StreamEx<JsonUser> getUsers() {
        return use(JsonReader.class).withTarget(JsonUser.class).read();
    }

    @DataSupplier
    public StreamEx<Client> getClient() {
        return use(JsonReader.class).withTarget(Client.class).read();
    }

    @DataSupplier
    public StreamEx<Animal> getAnimals() {
        return use(JsonReader.class)
            .withTarget(Animal.class)
            .withSource("https://raw.githubusercontent.com/LearnWebCode/json-example/master/animals-1.json")
            .read();
    }

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

    @Test(dataProvider = "getUsers")
    public void shouldReadLocalJsonArray(final JsonUser user) {
        // not implemented
    }

    @Test(dataProvider = "getClient")
    public void shouldReadLocalJson(final Client client) {
        // not implemented
    }

    @Test(dataProvider = "getAnimals")
    public void shouldReadRemoteJson(final Animal animal) {