From a1fb2906862d4edc566a49d5a6c9133cffcfba68 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Sun, 30 Jul 2017 18:22:18 +0200 Subject: [PATCH] upd: reactivate test case that is skipped due to failed assumption When this test case was introduced. The semantics of "getById"-Methods where slightly different. These methods would throw an IllegalArgumentException when the Object was not found. This behavior was changed to returning "null" when the Object is not found. When this change occurred this testcase was missed. The general intended logic is retained: Guess random ids until one unused is found (now checking for null and not for an exception). If 20 guesses fail (which is nearly impossible) the test case is skipped instead of failed. Change-Id: Id328d3c068f375488862bd06cfa0daf42a8c425f --- .../admin/TestSEAdminPageUserDomainSearch.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/club/wpia/gigi/pages/admin/TestSEAdminPageUserDomainSearch.java b/tests/club/wpia/gigi/pages/admin/TestSEAdminPageUserDomainSearch.java index c3133d26..75741650 100644 --- a/tests/club/wpia/gigi/pages/admin/TestSEAdminPageUserDomainSearch.java +++ b/tests/club/wpia/gigi/pages/admin/TestSEAdminPageUserDomainSearch.java @@ -1,7 +1,6 @@ package club.wpia.gigi.pages.admin; import static org.junit.Assert.*; -import static org.junit.Assume.*; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -9,6 +8,8 @@ import java.net.MalformedURLException; import java.net.URLConnection; import java.net.URLEncoder; +import org.hamcrest.CoreMatchers; +import org.junit.Assume; import org.junit.Test; import club.wpia.gigi.GigiApiException; @@ -69,16 +70,11 @@ public class TestSEAdminPageUserDomainSearch extends ClientTest { public void testDomainSearchByIdNonExist() throws MalformedURLException, UnsupportedEncodingException, IOException, GigiApiException { int id = (int) (Math.random() * 10000); int count = 0; - boolean found = false; - try { - while (Domain.getById(id) != null && count < 20) { - count++; - id = (int) (Math.random() * 10000); - } - } catch (Exception e) { - found = true; + while (Domain.getById(id) != null && count < 20) { + count++; + id = (int) (Math.random() * 10000); } - assumeTrue(found); + Assume.assumeThat(Domain.getById(id), CoreMatchers.nullValue()); URLConnection uc = post(FindUserByDomainPage.PATH, "process&domain=#" + id); assertNotNull(fetchStartErrorMessage(IOUtils.readURL(uc))); } -- 2.39.2