[testng] 328/355: Rework test

Eugene Zhukov eugene-guest at moszumanska.debian.org
Tue Aug 18 10:20:21 UTC 2015


This is an automated email from the git hooks/post-receive script.

eugene-guest pushed a commit to annotated tag OpenBSD
in repository testng.

commit 92a38202cc6bb156ca95308b0640ae51830f93f0
Author: Julien Herr <julien.herr at alcatel-lucent.com>
Date:   Tue May 12 09:32:09 2015 +0200

    Rework test
---
 .../AnnotationTransformerTest.java                   | 10 +++++++++-
 .../annotationtransformer/MyParamTransformer.java    | 20 +++++++++++---------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/test/java/test/annotationtransformer/AnnotationTransformerTest.java b/src/test/java/test/annotationtransformer/AnnotationTransformerTest.java
index 3d9d0a2..73521fe 100644
--- a/src/test/java/test/annotationtransformer/AnnotationTransformerTest.java
+++ b/src/test/java/test/annotationtransformer/AnnotationTransformerTest.java
@@ -91,7 +91,15 @@ public class AnnotationTransformerTest extends SimpleBaseTest {
 
     tng.run();
 
-    assertThat(transformer.isCheckNull()).isTrue();
+    assertThat(transformer.isSuccess()).isTrue();
+  }
+
+  @Test
+  public void verifyMyParamTransformerOnlyOneNonNull() {
+    assertThat(MyParamTransformer.onlyOneNonNull(null, null, null)).isFalse();
+    assertThat(MyParamTransformer.onlyOneNonNull(
+        MyParamTransformer.class, MyParamTransformer.class.getConstructors()[0], null)).isFalse();
+    assertThat(MyParamTransformer.onlyOneNonNull(MyParamTransformer.class, null, null)).isTrue();
   }
 
   /**
diff --git a/src/test/java/test/annotationtransformer/MyParamTransformer.java b/src/test/java/test/annotationtransformer/MyParamTransformer.java
index bfcb7a6..33aad84 100644
--- a/src/test/java/test/annotationtransformer/MyParamTransformer.java
+++ b/src/test/java/test/annotationtransformer/MyParamTransformer.java
@@ -5,24 +5,26 @@ import org.testng.annotations.ITestAnnotation;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
 
 public class MyParamTransformer implements IAnnotationTransformer {
 
-  private boolean checkNull = true;
+  private boolean success = true;
 
   @Override
   public void transform(ITestAnnotation annotation, Class testClass,
       Constructor testConstructor, Method testMethod) {
-    if ((testClass == null && testConstructor != null && testMethod != null) ||
-        (testClass != null && testConstructor == null && testMethod != null) ||
-        (testClass != null && testConstructor != null && testMethod == null)) {
-      checkNull = false;
+    if (!onlyOneNonNull(testClass, testConstructor, testMethod)) {
+      success = false;
     }
   }
 
-  public boolean isCheckNull() {
-    return checkNull;
+  public static boolean onlyOneNonNull(Class testClass, Constructor testConstructor, Method testMethod) {
+    return ((testClass != null && testConstructor == null && testMethod == null) ||
+            (testClass == null && testConstructor != null && testMethod == null) ||
+            (testClass == null && testConstructor == null && testMethod != null) );
+  }
+
+  public boolean isSuccess() {
+    return success;
   }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git



More information about the pkg-java-commits mailing list