// Path: src/main/java/io/github/sskorol/model/DataSupplierMetaData.java
// public class DataSupplierMetaData {
// 
//     @Getter
//     private final List<Object[]> testData;
//     private final boolean transpose;
//     private final boolean flatMap;
//     private final int[] indices;
//     @Getter
//     private final TestNGMethod testNGMethod;
// 
//     public DataSupplierMetaData(final ITestContext context, final ITestNGMethod testMethod) {
//         this.testNGMethod = new TestNGMethod(context, testMethod);
//         this.transpose = testNGMethod.getDataSupplierArg(DataSupplier::transpose, false);
//         this.flatMap = testNGMethod.getDataSupplierArg(DataSupplier::flatMap, false);
//         this.indices = testNGMethod.getDataSupplierArg(DataSupplier::indices, new int[0]);
//         this.testData = transform();
//     }
// 
//     private List<Object[]> transform() {
//         var data = streamOf(obtainReturnValue()).toList();
//         var indicesList = indicesList(data.size());
//         var wrappedReturnValue = EntryStream.of(data).filterKeys(indicesList::contains).values();
// 
//         if (transpose) {
//             return singletonList(flatMap
//                     ? wrappedReturnValue.flatMap(ReflectionUtils::streamOf).toArray()
//                     : wrappedReturnValue.toArray());
//         }
// 
//         return wrappedReturnValue.map(ob -> flatMap ? streamOf(ob).toArray() : new Object[]{ob}).toList();
//     }
// 
//     private Object obtainReturnValue() {
//         return invokeDataSupplier(testNGMethod.getDataSupplierMetaData());
//     }
// 
//     private List<Integer> indicesList(final int collectionSize) {
//         return ofNullable(indices)
//                 .filter(indicesArray -> indicesArray.length > 0)
//                 .map(IntStreamEx::of)
//                 .orElseGet(() -> IntStreamEx.range(0, collectionSize))
//                 .boxed()
//                 .toList();
//     }
// }
// 
// Path: src/main/java/io/github/sskorol/utils/ServiceLoaderUtils.java
// public static <T> List<T> load(final Class<T> type, final ClassLoader classLoader) {
//     return Try.of(() -> StreamEx.of(ServiceLoader.load(type, classLoader).iterator()).toList())
//         .getOrElseGet(ex -> emptyList());
// }


import io.github.sskorol.model.DataSupplierMetaData;
import one.util.streamex.StreamEx;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import org.testng.annotations.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;
import java.util.function.Consumer;
import static io.github.sskorol.utils.ServiceLoaderUtils.load;
import static io.vavr.API.*;
package io.github.sskorol.core;




/**
 * Key aspect for DataSupplier interception.
 */
@Aspect
public class DataSupplierAspect {

    private static final List<DataSupplierInterceptor> DATA_SUPPLIERS =
// Path: src/main/java/io/github/sskorol/model/DataSupplierMetaData.java
// public class DataSupplierMetaData {
// 
//     @Getter
//     private final List<Object[]> testData;
//     private final boolean transpose;
//     private final boolean flatMap;
//     private final int[] indices;
//     @Getter
//     private final TestNGMethod testNGMethod;
// 
//     public DataSupplierMetaData(final ITestContext context, final ITestNGMethod testMethod) {
//         this.testNGMethod = new TestNGMethod(context, testMethod);
//         this.transpose = testNGMethod.getDataSupplierArg(DataSupplier::transpose, false);
//         this.flatMap = testNGMethod.getDataSupplierArg(DataSupplier::flatMap, false);
//         this.indices = testNGMethod.getDataSupplierArg(DataSupplier::indices, new int[0]);
//         this.testData = transform();
//     }
// 
//     private List<Object[]> transform() {
//         var data = streamOf(obtainReturnValue()).toList();
//         var indicesList = indicesList(data.size());
//         var wrappedReturnValue = EntryStream.of(data).filterKeys(indicesList::contains).values();
// 
//         if (transpose) {
//             return singletonList(flatMap
//                     ? wrappedReturnValue.flatMap(ReflectionUtils::streamOf).toArray()
//                     : wrappedReturnValue.toArray());
//         }
// 
//         return wrappedReturnValue.map(ob -> flatMap ? streamOf(ob).toArray() : new Object[]{ob}).toList();
//     }
// 
//     private Object obtainReturnValue() {
//         return invokeDataSupplier(testNGMethod.getDataSupplierMetaData());
//     }
// 
//     private List<Integer> indicesList(final int collectionSize) {
//         return ofNullable(indices)
//                 .filter(indicesArray -> indicesArray.length > 0)
//                 .map(IntStreamEx::of)
//                 .orElseGet(() -> IntStreamEx.range(0, collectionSize))
//                 .boxed()
//                 .toList();
//     }
// }
// 
// Path: src/main/java/io/github/sskorol/utils/ServiceLoaderUtils.java
// public static <T> List<T> load(final Class<T> type, final ClassLoader classLoader) {
//     return Try.of(() -> StreamEx.of(ServiceLoader.load(type, classLoader).iterator()).toList())
//         .getOrElseGet(ex -> emptyList());
// }


// Path: src/main/java/io/github/sskorol/core/DataSupplierAspect.java
import io.github.sskorol.model.DataSupplierMetaData;
import one.util.streamex.StreamEx;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import org.testng.annotations.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;
import java.util.function.Consumer;
import static io.github.sskorol.utils.ServiceLoaderUtils.load;
import static io.vavr.API.*;

package io.github.sskorol.core;




/**
 * Key aspect for DataSupplier interception.
 */
@Aspect
public class DataSupplierAspect {

    private static final List<DataSupplierInterceptor> DATA_SUPPLIERS =
            load(DataSupplierInterceptor.class, DataSupplierAspect.class.getClassLoader());