1 package test.factory;
2 
3 import org.testng.Assert;
4 import org.testng.annotations.Factory;
5 import org.testng.annotations.Test;
6 
7 public class GitHub876Sample {
8 
9     @Factory
createInstances()10     public Object[] createInstances() {
11         return new Object[]{
12                 new GitHub876Sample(new DataTest("foo", true)),
13                 new GitHub876Sample(new DataTest("FOO", false))
14         };
15     }
16 
17     private final DataTest dataTest;
18 
GitHub876Sample(DataTest dataTest)19     public GitHub876Sample(DataTest dataTest) {
20         this.dataTest = dataTest;
21     }
22 
23     @Test
test()24     public void test() {
25         switch (dataTest.s) {
26             case "FOO":
27                 Assert.assertFalse(dataTest.b);
28                 break;
29             case "foo":
30                 Assert.assertTrue(dataTest.b);
31                 break;
32             default:
33                 Assert.fail("Unknown value");
34         }
35     }
36 
37     public static class DataTest {
38 
39         private final String s;
40         private final boolean b;
41 
DataTest(String s, boolean b)42         public DataTest(String s, boolean b) {
43             this.s = s;
44             this.b = b;
45         }
46     }
47 }
48