public PullRequestStateProducer(GitHubEndpoint endpoint) throws Exception {
        super(endpoint);

        Registry registry = endpoint.getCamelContext().getRegistry();
        Object service = registry.lookupByName(GitHubConstants.GITHUB_COMMIT_SERVICE);
        if (service != null) {
            LOG.debug("Using CommitService found in registry {}", service.getClass().getCanonicalName());
            commitService = (CommitService) service;
        } else {
            commitService = new CommitService();
        }
        initService(commitService);

        state = endpoint.getState();
        targetUrl = endpoint.getTargetUrl();
    }
@Test
    public void testPullRequestStateProducer() {
        commitsha = commitService.getNextSha();

        Endpoint stateProducerEndpoint = getMandatoryEndpoint("direct:validPullRequest");
        Exchange exchange = stateProducerEndpoint.createExchange();
        String text = "Message sent at " + new Date();
        exchange.getIn().setBody(text);
        Exchange response = template.send(stateProducerEndpoint, exchange);

        assertNotNull(response.getMessage().getBody());

        if (!(response.getMessage().getBody() instanceof CommitStatus)) {
            fail("Expecting CommitStatus");
        }

        CommitStatus status = response.getMessage().getBody(CommitStatus.class);

        // Check status set on commit service
        if (commitService.getCommitStatus(commitsha) != status) {
            fail("Commit status sent to service is different from response");
        }

        assertEquals("success", status.getState());

        assertEquals(status.getDescription(), text);
    }