Created
October 17, 2017 18:53
-
-
Save thombergs/f7e8ea54703776780077b5d913362fe3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AssumeConnectionCondition implements ExecutionCondition { | |
| @Override | |
| public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { | |
| Optional<AssumeConnection> annotation = findAnnotation(context.getElement(), AssumeConnection.class); | |
| if (annotation.isPresent()) { | |
| String uri = annotation.get().uri(); | |
| ConnectionChecker checker = new ConnectionChecker(uri); | |
| if (!checker.connect()) { | |
| return ConditionEvaluationResult.disabled(String.format("Could not connect to '%s'. Skipping test!", uri)); | |
| } else { | |
| return ConditionEvaluationResult.enabled(String.format("Successfully connected to '%s'. Continuing test!", uri)); | |
| } | |
| } | |
| return ConditionEvaluationResult.enabled("No AssumeConnection annotation found. Continuing test."); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment