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);
}
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);
}
Aggregations