package com.tngtech.test.junit.dataprovider;

import static com.tngtech.junit.dataprovider.DataProviders.$;
import static com.tngtech.junit.dataprovider.DataProviders.$$;
import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;

import com.tngtech.junit.dataprovider.DataProvider;
import com.tngtech.junit.dataprovider.UseDataProvider;
import com.tngtech.junit.dataprovider.UseDataProviderExtension;

@TestInstance(Lifecycle.PER_CLASS)
@ExtendWith(UseDataProviderExtension.class)
class NonStaticDataProviderAcceptanceTest {

    @DataProvider
    Object[][] dataProviderDivide() {
        // @formatter:off
        return $$(
                $(  0,   1,  0 ),
                $(  0,  -1,  0 ),
                $(  1,  1,   1 ),
                $(  1, -1,  -1 ),
                $(  2,  1,   2 )
        );
        // @formatter:on
    }

    @TestTemplate
    @UseDataProvider
    void testDivide(int a, int b, int expected) {
        // Given:

        // When:
        int result = a / b;

        // Then:
        assertThat(result).isEqualTo(expected);
    }
}

@@ -223,16 +223,53 @@
 tThat;%0A%0A
+import org.junit.jupiter.api.Nested;%0A
 import o
@@ -1284,11 +1284,641 @@
 );%0A    %7D
+%0A%0A    @TestInstance(Lifecycle.PER_CLASS)%0A    @Nested%0A    class NestedTests %7B%0A%0A        @DataProvider%0A        Object%5B%5D%5B%5D dataProviderPow() %7B%0A            // @formatter:off%0A            return $$(%0A                    $( 0,  0 ),%0A                    $( 1,  1 ),%0A                    $( 2,  4 ),%0A                    $( 4, 16 )%0A            );%0A            // @formatter:on%0A        %7D%0A%0A        @TestTemplate%0A        @UseDataProvider%0A        void testPow(int a, int expected) %7B%0A            // Given:%0A%0A            // When:%0A            int result = a * a;%0A%0A            // Then:%0A            assertThat(result).isEqualTo(expected);%0A        %7D%0A    %7D
 %0A%7D%0A

add integration test for nested dataprovider