Java Code Examples for org.jboss.arquillian.core.spi.Validate#notNull()

The following examples show how to use org.jboss.arquillian.core.spi.Validate#notNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedmineGovernorClient.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Override
public ExecutionDecision resolve(Redmine annotation) {
    Validate.notNull(redmineManager, "Redmine manager must be specified.");
    Validate.notNull(redmineGovernorStrategy, "Governor strategy must be specified. Have you already called setGovernorStrategy()?");

    final String redmineIssueKey = annotation.value();

    if (redmineIssueKey == null || redmineIssueKey.length() == 0) {
        return ExecutionDecision.execute();
    }

    final Issue redmineIssue = getIssue(redmineIssueKey);

    // when there is some error while we are getting the issue, we execute that test
    if (redmineIssue == null) {
        logger.warning(String.format("Redmine Issue %s couldn't be retrieved from configured repository.", redmineIssueKey));
        return ExecutionDecision.execute();
    }

    return redmineGovernorStrategy.annotation(annotation).issue(redmineIssue).resolve();
}
 
Example 2
Source File: GitHubGovernorClient.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Override
public ExecutionDecision resolve(GitHub annotation) {
    Validate.notNull(gitHubClient, "GitHub REST client must be specified.");
    Validate.notNull(gitHubGovernorStrategy, "Governor strategy must be specified. Have you already called setGovernorStrategy()?");

    final String gitHubIssueKey = annotation.value();

    if (gitHubIssueKey == null || gitHubIssueKey.length() == 0) {
        return ExecutionDecision.execute();
    }

    final Issue gitHubIssue = getIssue(gitHubIssueKey);

    // when there is some error while we are getting the issue, we execute that test
    if (gitHubIssue == null) {
        logger.warning(String.format("GitHub Issue %s couldn't be retrieved from configured repository.", gitHubIssueKey));
        return ExecutionDecision.execute();
    }

    return gitHubGovernorStrategy.annotation(annotation).issue(gitHubIssue).resolve();
}
 
Example 3
Source File: GitHubGovernorClientFactory.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Override
public GitHubGovernorClient build(
        GitHubGovernorConfiguration governorConfiguration) throws Exception {
    Validate.notNull(governorConfiguration, "GitHub governor configuration has to be set.");
    this.gitHubGovernorConfiguration = governorConfiguration;

    final GitHubClient gitHubClient = new GitHubClient();
    if (this.gitHubGovernorConfiguration.getUsername() != null && this.gitHubGovernorConfiguration.getUsername().length() > 0 && this.gitHubGovernorConfiguration.getPassword() != null && this.gitHubGovernorConfiguration.getPassword().length() > 0) {
        gitHubClient.setCredentials(this.gitHubGovernorConfiguration.getUsername(), this.gitHubGovernorConfiguration.getPassword());
    }

    if (this.gitHubGovernorConfiguration.getToken() != null && this.gitHubGovernorConfiguration.getToken().length() > 0) {
        gitHubClient.setOAuth2Token(gitHubGovernorConfiguration.getToken());
    }

    final GitHubGovernorClient gitHubGovernorClient = new GitHubGovernorClient(gitHubClient, gitHubGovernorConfiguration);
    gitHubGovernorClient.setGovernorStrategy(new GitHubGovernorStrategy(this.gitHubGovernorConfiguration));

    return gitHubGovernorClient;
}
 
Example 4
Source File: GitHubGovernorClient.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Override
public void close(String issueId) {
    Validate.notNull(gitHubClient, "GitHub REST client must be specified.");

    Comment comment = null;

    try {
        final Issue issue = getIssue(issueId);
        issue.setState(IssueService.STATE_CLOSED);
        comment =
                this.issueService.createComment(this.gitHubGovernorConfiguration.getRepositoryUser(), this.gitHubGovernorConfiguration.getRepository(), issueId,
                        getClosingMessage());
        this.issueService.editIssue(this.gitHubGovernorConfiguration.getRepositoryUser(), this.gitHubGovernorConfiguration.getRepository(), issue);
    } catch (Exception e) {
        if (comment != null) {
            deleteComment(comment);
        }

        logger.warning(String.format("An exception has occured while closing the issue %s. Exception: %s", issueId, e.getMessage()));
    }
}
 
Example 5
Source File: GovernorRegistryImpl.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Override
public List<Method> getMethodsForAnnotation(Class<? extends Annotation> annotationClass) {
    Validate.notNull(annotationClass, "An annotation class to get methods for must be specified.");

    if (annotationClass.getAnnotation(Governor.class) == null) {
        throw new IllegalStateException("Annotation class to get methods for is not annotated with Governor class.");
    }

    final List<Method> methods = new ArrayList<Method>();

    for (final Map.Entry<Method, List<Annotation>> entry : scannedTestMethods.entrySet()) {
        for (final Annotation methodAnnotation : entry.getValue()) {
            if (methodAnnotation.annotationType() == annotationClass) {
                methods.add(entry.getKey());
                break;
            }
        }
    }

    return methods;
}
 
Example 6
Source File: CacheStatisticsControllerEnricher.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void enrich(Object testCase) {
    Validate.notNull(registry.get(), "registry should not be null");
    Validate.notNull(jmxConnectorRegistry.get(), "jmxConnectorRegistry should not be null");
    Validate.notNull(suiteContext.get(), "suiteContext should not be null");

    for (Field field : FieldUtils.getAllFields(testCase.getClass())) {
        JmxInfinispanCacheStatistics annotation = field.getAnnotation(JmxInfinispanCacheStatistics.class);

        if (annotation == null) {
            continue;
        }

        try {
            FieldUtils.writeField(field, testCase, getInfinispanCacheStatistics(annotation), true);
        } catch (IOException | IllegalAccessException | MalformedObjectNameException e) {
            throw new RuntimeException("Could not set value on field " + field);
        }
    }
}
 
Example 7
Source File: TestMethodExecutionRegister.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
public MethodExecutionDecision(String testMethod, Class<? extends Annotation> annotation, ExecutionDecision executionDecision) {
    Validate.notNull(testMethod, "Test method has to be specified.");
    Validate.notNull(annotation, "Annotation has to be specified.");
    Validate.notNull(executionDecision, "Execution decision has to be specified.");

    this.testMethod = testMethod;
    this.annotation = annotation;
    this.executionDecision = executionDecision;
}
 
Example 8
Source File: GitHubGovernorClient.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
private String getClosingMessage() {
    Validate.notNull(gitHubGovernorConfiguration, "GitHub Governor configuration must be set.");

    String username = gitHubGovernorConfiguration.getUsername();

    if (username == null || username.isEmpty()) {
        username = "unknown";
    }

    return String.format(gitHubGovernorConfiguration.getClosingMessage(), username);
}
 
Example 9
Source File: DesktopVideoRecorder.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Override
public void startRecording(VideoType videoType) {
    Validate.notNull(videoType, "Video type is a null object!");
    VideoMetaData metaData = new VideoMetaData();
    metaData.setResourceType(videoType);
    startRecording(
        new File(new DefaultFileNameBuilder().withMetaData(metaData).build()),
        videoType);
}
 
Example 10
Source File: JiraGovernorClientFactory.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
@Override
public JiraGovernorClient build(JiraGovernorConfiguration jiraGovernorConfiguration) throws Exception {
    Validate.notNull(jiraGovernorConfiguration, "Jira governor configuration has to be set.");
    this.jiraGovernorConfiguration = jiraGovernorConfiguration;

    final URI jiraServerUri = this.jiraGovernorConfiguration.getServerURI();
    final String username = this.jiraGovernorConfiguration.getUsername();
    final String password = this.jiraGovernorConfiguration.getPassword();

    final AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();

    final AuthenticationHandler authHandler;

    if (username == null || username.isEmpty()) {
        authHandler = new AnonymousAuthenticationHandler();

    } else {
        authHandler = new BasicHttpAuthenticationHandler(username, password);
    }

    final JiraRestClient restClient = factory.create(jiraServerUri, authHandler);

    final JiraGovernorClient client = new JiraGovernorClient();
    client.setConfiguration(this.jiraGovernorConfiguration);
    client.initializeRestClient(restClient);
    client.setGovernorStrategy(new JiraGovernorStrategy(jiraGovernorConfiguration));

    return client;
}
 
Example 11
Source File: Resource.java    From arquillian-recorder with Apache License 2.0 4 votes vote down vote up
public void setResourceMetaData(T resourceMetaData) {
    Validate.notNull(resourceMetaData, "Resource metadata you are trying to set is a null object!");
    this.resourceMetaData = resourceMetaData;
}
 
Example 12
Source File: GitHubGovernorClient.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
private void initializeGitHubClient(final GitHubClient gitHubClient) {
    Validate.notNull(gitHubClient, "GitHub client must be specified.");
    this.gitHubClient = gitHubClient;

    this.issueService = new IssueService(this.gitHubClient);
}
 
Example 13
Source File: JiraGovernorClient.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
void initializeRestClient(final JiraRestClient restClient) throws Exception {
    Validate.notNull(restClient, "Jira REST client must be specified.");
    this.restClient = restClient;

    jiraBuildNumber = this.restClient.getMetadataClient().getServerInfo().claim().getBuildNumber();
}
 
Example 14
Source File: TakenResourceRegister.java    From arquillian-recorder with Apache License 2.0 4 votes vote down vote up
public boolean addReported(Video video) {
    Validate.notNull(video, "Video can not be a null object!");
    return reportedVideos.add(video);
}
 
Example 15
Source File: ExecutionDecisionEvent.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
public ExecutionDecisionEvent(final Annotation annotation) {
    Validate.notNull(annotation, "Annotation has to be specified.");

    this.annotation = annotation;
}
 
Example 16
Source File: JiraGovernorStrategy.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
public JiraGovernorStrategy(JiraGovernorConfiguration jiraGovernorConfiguration) {
    Validate.notNull(jiraGovernorConfiguration, "Jira Governor configuration has to be set.");
    this.jiraGovernorConfiguration = jiraGovernorConfiguration;
}
 
Example 17
Source File: AfterScreenshotTaken.java    From arquillian-recorder with Apache License 2.0 4 votes vote down vote up
public void setMetaData(ScreenshotMetaData metaData) {
    Validate.notNull(metaData, "Meta data is a null object.");
    this.metaData = metaData;
}
 
Example 18
Source File: DefaultScreenshootingStrategy.java    From arquillian-recorder with Apache License 2.0 4 votes vote down vote up
@Override
public void setConfiguration(ScreenshooterConfiguration configuration) {
    Validate.notNull(configuration, "Screenshooter configuration is a null object!");
    this.configuration = configuration;
}
 
Example 19
Source File: ResourceMetaData.java    From arquillian-recorder with Apache License 2.0 2 votes vote down vote up
/**
 * Sets a class for some particular {@code Resource} where that resource was created.
 *
 * @param testClass test class where some resource was created
 * @return {@code this}
 * @throws IllegalArgumentException if {@code TestClass} is a null object
 */
public ResourceMetaData setTestClass(TestClass testClass) {
    Validate.notNull(testClass, "Test class is a null object!");
    this.testClass = testClass;
    return this;
}
 
Example 20
Source File: ResourceMetaData.java    From arquillian-recorder with Apache License 2.0 2 votes vote down vote up
/**
 * Sets a test method for some particular {@code Resource} where that resource was created.
 *
 * @param testMethod test method where some resource was created
 * @return {@code this}
 * @throws IllegalArgumentException if {@code testMethod} is a null object.
 */
public ResourceMetaData setTestMethod(Method testMethod) {
    Validate.notNull(testMethod, "Method is a null object!");
    this.testMethod = testMethod;
    return this;
}