• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test.hook;
2 
3 import org.testng.*;
4 import org.testng.annotations.DataProvider;
5 import org.testng.annotations.Test;
6 
7 import javax.inject.Named;
8 import java.lang.annotation.Annotation;
9 import java.lang.reflect.Method;
10 
11 public class HookSuccess862Test implements IHookable {
12 
13     @Override
run(IHookCallBack callBack, ITestResult testResult)14     public void run(IHookCallBack callBack, ITestResult testResult) {
15         Method method = testResult.getMethod().getConstructorOrMethod().getMethod();
16         for (int i = 0; i < callBack.getParameters().length; i++) {
17             Annotation[] annotations = method.getParameterAnnotations()[i];
18             for (Annotation annotation : annotations) {
19                 if (annotation instanceof Named) {
20                     Named named = (Named) annotation;
21                     callBack.getParameters()[0] = callBack.getParameters()[0] + named.value();
22                 }
23             }
24         }
25         callBack.runTestMethod(testResult);
26     }
27 
28     @DataProvider
dp()29     public Object[][] dp() {
30         return new Object[][]{
31                 new Object[]{"foo", "test"}
32         };
33     }
34 
35     @Test(dataProvider = "dp")
verify(@amed"bar") String bar, String test)36     public void verify(@Named("bar") String bar, String test) {
37         Assert.assertEquals(bar, "foobar");
38         Assert.assertEquals(test, "test");
39     }
40 }
41