Search in sources :

Example 1 with CommitFile

use of org.eclipse.egit.github.core.CommitFile in project camel by apache.

the class PullRequestFilesProducerTest method testPullRequestFilesProducer.

@Test
public void testPullRequestFilesProducer() throws Exception {
    PullRequest pullRequest = pullRequestService.addPullRequest("testPullRequestFilesProducer");
    latestPullRequestNumber = pullRequest.getNumber();
    CommitFile file = new CommitFile();
    file.setFilename("testfile");
    List<CommitFile> commitFiles = new ArrayList<CommitFile>();
    commitFiles.add(file);
    pullRequestService.setFiles(latestPullRequestNumber, commitFiles);
    Endpoint filesProducerEndpoint = getMandatoryEndpoint("direct:validPullRequest");
    Exchange exchange = filesProducerEndpoint.createExchange();
    Exchange resp = template.send(filesProducerEndpoint, exchange);
    assertEquals(resp.getOut().getBody(), commitFiles);
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) PullRequest(org.eclipse.egit.github.core.PullRequest) ArrayList(java.util.ArrayList) CommitFile(org.eclipse.egit.github.core.CommitFile) Test(org.junit.Test)

Example 2 with CommitFile

use of org.eclipse.egit.github.core.CommitFile in project camel by apache.

the class GetCommitFileProducer method process.

public void process(Exchange exchange) throws Exception {
    CommitFile file = exchange.getIn().getBody(CommitFile.class);
    Blob response = dataService.getBlob(getRepository(), file.getSha());
    String text = response.getContent();
    // base64 encoding is required, then must be explicitly requested
    if (response.getEncoding().equals(Blob.ENCODING_BASE64) && encoding != null && encoding.equalsIgnoreCase(Blob.ENCODING_UTF8)) {
        text = new String(Base64.decodeBase64(text));
    }
    // copy the header of in message to the out message
    exchange.getOut().copyFrom(exchange.getIn());
    exchange.getOut().setBody(text);
}
Also used : Blob(org.eclipse.egit.github.core.Blob) CommitFile(org.eclipse.egit.github.core.CommitFile)

Aggregations

CommitFile (org.eclipse.egit.github.core.CommitFile)2 ArrayList (java.util.ArrayList)1 Endpoint (org.apache.camel.Endpoint)1 Exchange (org.apache.camel.Exchange)1 Blob (org.eclipse.egit.github.core.Blob)1 PullRequest (org.eclipse.egit.github.core.PullRequest)1 Test (org.junit.Test)1