package junitparams;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.*;
import org.junit.runner.*;

import junitparams.usage.person_example.*;
import junitparams.usage.person_example.PersonTest.*;

@SuppressWarnings("unused")
@RunWith(JUnitParamsRunner.class)
public class MethodAnnotationArgumentTest {

    @Test
    @Parameters(method = "return1")
    public void testSingleMethodName(int number) {
        assertThat(1).isEqualTo(number);
    }

    private Integer[] return1() {
        return new Integer[] {1};
    }

    @Test
    @Parameters(method = "return1,return2")
    public void testMultipleMethodNames(int number) {
        assertThat(number)
                .isLessThanOrEqualTo(2)
                .isGreaterThanOrEqualTo(1);
    }

    @Test
    @Parameters(method = "return1, return2")
    public void testMultipleMethodNamesWithWhitespaces(int number) {
        assertThat(number)
                .isLessThanOrEqualTo(2)
                .isGreaterThanOrEqualTo(1);
    }

    private Integer[] return2() {
        return new Integer[] {2};
    }

    @Test
    @Parameters(source = PersonTest.class, method = "adultValues")
    public void testSingleMethodFromDifferentClass(int age, boolean valid) {
        assertThat(new Person(age).isAdult()).isEqualTo(valid);
    }
}

@@ -85,46 +85,47 @@
 ort 
-org.junit.*;%0Aimport org.junit.runner.*
+java.util.Arrays;%0Aimport java.util.List
 ;%0A%0Ai
@@ -163,17 +163,26 @@
 example.
-*
+PersonTest
 ;%0Aimport
@@ -230,9 +230,71 @@
 est.
-*
+Person;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith
 ;%0A%0A@
@@ -608,17 +608,19 @@
 eger%5B%5D %7B
-1
+ 1 
 %7D;%0A    %7D
@@ -1153,17 +1153,19 @@
 eger%5B%5D %7B
-2
+ 2 
 %7D;%0A    %7D
@@ -1389,11 +1389,478 @@
 );%0A    %7D
+%0A%0A    @Test%0A    @Parameters(method = %22stringParams%22)%0A    public void shouldPassStringParamsFromMethod(String parameter) %7B%0A        // given%0A        List%3CString%3E acceptedParams = Arrays.asList(%221%22, %222%22, %223%22, null);%0A%0A        // then%0A        assertThat(acceptedParams).contains(parameter);%0A    %7D%0A%0A    Object%5B%5D stringParams() %7B%0A        return genericArray(%221%22, %222%22, %223%22, null);%0A    %7D%0A%0A    private static %3CT%3E T%5B%5D genericArray(T... elements) %7B%0A        return elements;%0A    %7D
 %0A%7D%0A

Test explaining reason to change Utils.safelyCastParamsToArray method