arquillian-testsuite fixed whitespaces

This commit is contained in:
vramik 2015-10-27 11:43:49 +01:00
parent f45e0aa387
commit 2fd7e5b355
3 changed files with 42 additions and 42 deletions

View file

@ -22,17 +22,17 @@ public class JBossJiraParser {
private static final String JBOSS_TRACKER_REST_URL = "https://issues.jboss.org/rest/api/latest/issue/"; private static final String JBOSS_TRACKER_REST_URL = "https://issues.jboss.org/rest/api/latest/issue/";
public static boolean isIssueClosed(String issueId) { public static boolean isIssueClosed(String issueId) {
Status issueStatus; Status issueStatus;
try { try {
issueStatus = getIssueStatus(issueId); issueStatus = getIssueStatus(issueId);
} catch(Exception e) { } catch (Exception e) {
issueStatus = Status.CLOSED; //let the test run in case there is no connection issueStatus = Status.CLOSED; //let the test run in case there is no connection
} }
return issueStatus == Status.CLOSED || issueStatus == Status.RESOLVED; return issueStatus == Status.CLOSED || issueStatus == Status.RESOLVED;
} }
private static Status getIssueStatus(String issueId) throws Exception { private static Status getIssueStatus(String issueId) throws Exception {
Client client = ClientBuilder.newClient(); Client client = ClientBuilder.newClient();
WebTarget target = client.target(JBOSS_TRACKER_REST_URL); WebTarget target = client.target(JBOSS_TRACKER_REST_URL);
String json = target.path(issueId).request().accept(MediaType.APPLICATION_JSON_TYPE).get(String.class); String json = target.path(issueId).request().accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
JsonObject jsonObject = new Gson().fromJson(json, JsonElement.class).getAsJsonObject(); JsonObject jsonObject = new Gson().fromJson(json, JsonElement.class).getAsJsonObject();

View file

@ -24,5 +24,5 @@ import java.lang.annotation.Target;
public @interface Jira { public @interface Jira {
String value(); String value();
boolean enabled() default true; boolean enabled() default true;
} }

View file

@ -19,43 +19,43 @@ import static org.keycloak.testsuite.arquillian.jira.JBossJiraParser.isIssueClos
*/ */
public class JiraTestExecutionDecider implements TestExecutionDecider { public class JiraTestExecutionDecider implements TestExecutionDecider {
private static Map<String, Boolean> cache = new HashMap<String, Boolean>(); private static Map<String, Boolean> cache = new HashMap<>();
@Override @Override
public ExecutionDecision decide(Method method) { public ExecutionDecision decide(Method method) {
Jira jiraAnnotation = method.getAnnotation(Jira.class); Jira jiraAnnotation = method.getAnnotation(Jira.class);
if (jiraAnnotation != null && jiraAnnotation.enabled()) { if (jiraAnnotation != null && jiraAnnotation.enabled()) {
boolean executeTest = true; boolean executeTest = true;
String[] issueIds = getIssuesId(jiraAnnotation.value()); String[] issueIds = getIssuesId(jiraAnnotation.value());
for (String issueId : issueIds) { for (String issueId : issueIds) {
if (cache.containsKey(issueId)) { if (cache.containsKey(issueId)) {
executeTest = cache.get(issueId); executeTest = cache.get(issueId);
} else { } else {
if (isIssueClosed(issueId)) { if (isIssueClosed(issueId)) {
cache.put(issueId, true); cache.put(issueId, true);
} else { } else {
executeTest = false; executeTest = false;
cache.put(issueId, false); cache.put(issueId, false);
} }
} }
} }
if (executeTest) { if (executeTest) {
return ExecutionDecision.execute(); return ExecutionDecision.execute();
} else { } else {
return ExecutionDecision.dontExecute("Issue is still opened, therefore skipping the test " + method.getName()); return ExecutionDecision.dontExecute("Issue is still opened, therefore skipping the test " + method.getName());
} }
} }
return ExecutionDecision.execute(); return ExecutionDecision.execute();
} }
private String[] getIssuesId(String value) { private String[] getIssuesId(String value) {
return value.replaceAll("\\s+", "").split(","); return value.replaceAll("\\s+", "").split(",");
} }
@Override @Override
public int precedence() { public int precedence() {
return 0; return 0;
} }
} }