com.jcabi.github.Github Java Examples

The following examples show how to use com.jcabi.github.Github. 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: LastCommentTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Mock an issue on Github.
 * @return 2 Issues: 1 from the commander's Github (where the comments
 * are posted) and 1 from the agent's Github (where comments are checked)
 * @throws IOException If something goes wrong.
 */
private Issue[] mockIssue() throws IOException {
    MkStorage storage = new MkStorage.InFile();
    Github commanderGithub = new MkGithub(storage, "amihaiemil");
    commanderGithub.users().self().emails().add(Arrays.asList("[email protected]"));
    Github agentGithub = new MkGithub(storage, "charlesmike");
    
    RepoCreate repoCreate = new RepoCreate("amihaiemil.github.io", false);
    commanderGithub.repos().create(repoCreate);
    Issue[] issues = new Issue[2];
    Coordinates repoCoordinates = new Coordinates.Simple("amihaiemil", "amihaiemil.github.io");
    Issue authorsIssue = commanderGithub.repos().get(repoCoordinates).issues().create("Test issue for commands", "test body");
    Issue agentsIssue = agentGithub.repos().get(repoCoordinates).issues().get(authorsIssue.number());
    issues[0] = authorsIssue;
    issues[1] = agentsIssue;
    
    return issues;
}
 
Example #2
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getSpringCloudVersionBomRangesMissingTest() {
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	when(rest.getForObject(anyString(), eq(Map.class))).thenReturn(new HashMap());
	InitializrSpringCloudInfoService service = new InitializrSpringCloudInfoService(
			rest, github, githubPomReader);
	try {
		service.getSpringCloudVersion("2.1.0");
		fail("Exception should have been thrown");
	}
	catch (SpringCloudVersionNotFoundException e) {
		assertThat(e.getCause().getMessage(), Matchers.startsWith("bom-ranges"));
	}
}
 
Example #3
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getSpringCloudVersionSpringCloudMissingTest() {
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	Map<String, Map<String, String>> info = new HashMap<>();
	info.put("bom-ranges", new HashMap<>());
	when(rest.getForObject(anyString(), eq(Map.class))).thenReturn(info);
	InitializrSpringCloudInfoService service = new InitializrSpringCloudInfoService(
			rest, github, githubPomReader);
	try {
		service.getSpringCloudVersion("2.1.0");
		fail("Exception should have been thrown");
	}
	catch (SpringCloudVersionNotFoundException e) {
		assertThat(e.getCause().getMessage(), Matchers.startsWith("spring-cloud"));
	}
}
 
Example #4
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getSpringCloudReleaseVersionTest() throws Exception {
	String bomVersion = "vHoxton.BUILD-SNAPSHOT";
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	when(githubPomReader.readPomFromUrl(eq(String
			.format(SpringCloudRelease.SPRING_CLOUD_STARTER_PARENT_RAW, bomVersion))))
					.thenReturn(new MavenXpp3Reader()
							.read(new FileReader(new ClassPathResource(
									"spring-cloud-starter-parent-pom.xml")
											.getFile())));
	when(githubPomReader.readPomFromUrl(eq(String.format(
			SpringCloudRelease.SPRING_CLOUD_RELEASE_DEPENDENCIES_RAW, bomVersion))))
					.thenReturn(new MavenXpp3Reader().read(new FileReader(
							new ClassPathResource("spring-cloud-dependencies-pom.xml")
									.getFile())));
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	doReturn(Arrays.asList(new String[] { bomVersion })).when(service)
			.getSpringCloudVersions();
	Map<String, String> releaseVersionsResult = service
			.getReleaseVersions(bomVersion);
	assertThat(releaseVersionsResult,
			Matchers.equalTo(SpringCloudInfoTestData.releaseVersions));
}
 
Example #5
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test(expected = SpringCloudVersionNotFoundException.class)
public void getSpringCloudReleaseVersionNotFoundTest() throws Exception {
	String bomVersion = "vFooBar.BUILD-SNAPSHOT";
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	when(githubPomReader.readPomFromUrl(eq(String
			.format(SpringCloudRelease.SPRING_CLOUD_STARTER_PARENT_RAW, bomVersion))))
					.thenReturn(new MavenXpp3Reader()
							.read(new FileReader(new ClassPathResource(
									"spring-cloud-starter-parent-pom.xml")
											.getFile())));
	when(githubPomReader.readPomFromUrl(eq(String.format(
			SpringCloudRelease.SPRING_CLOUD_RELEASE_DEPENDENCIES_RAW, bomVersion))))
					.thenReturn(new MavenXpp3Reader().read(new FileReader(
							new ClassPathResource("spring-cloud-dependencies-pom.xml")
									.getFile())));
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	doReturn(new ArrayList()).when(service).getSpringCloudVersions();
	service.getReleaseVersions(bomVersion);
}
 
Example #6
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getSpringCloudVersionsTest() throws Exception {
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	Response response = mock(Response.class);
	Request request = mock(Request.class);
	RequestURI requestURI = mock(RequestURI.class);
	JsonResponse jsonResponse = new JsonResponse(new DefaultResponse(request, 200, "",
			new Array<>(),
			IOUtils.toByteArray(new ClassPathResource("spring-cloud-versions.json")
					.getInputStream())));
	doReturn(request).when(requestURI).back();
	doReturn(requestURI).when(requestURI).path(eq(SPRING_CLOUD_RELEASE_TAGS_PATH));
	doReturn(requestURI).when(request).uri();
	doReturn(jsonResponse).when(response).as(eq(JsonResponse.class));
	doReturn(response).when(request).fetch();
	doReturn(request).when(github).entry();
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	assertThat(service.getSpringCloudVersions(),
			Matchers.equalTo(SpringCloudInfoTestData.springCloudVersions.stream()
					.map(v -> v.replaceFirst("v", "")).collect(Collectors.toList())));
}
 
Example #7
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getMilestoneDueDateTest() throws Exception {
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	Repos repos = mock(Repos.class);
	Repo repo = mock(Repo.class);
	Milestones milestones = mock(Milestones.class);
	Iterable iterable = buildMilestonesIterable();
	doReturn(iterable).when(milestones).iterate(any(Map.class));
	doReturn(milestones).when(repo).milestones();
	doReturn(repo).when(repos).get(any(Coordinates.class));
	doReturn(repos).when(github).repos();
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	assertThat(service.getMilestoneDueDate("Finchley.SR4"),
			Matchers.equalTo(new SpringCloudInfoService.Milestone("No Due Date")));
	assertThat(service.getMilestoneDueDate("Hoxton.RELEASE"),
			Matchers.equalTo(new SpringCloudInfoService.Milestone("2019-07-31")));
}
 
Example #8
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getMilestonesTest() throws Exception {
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	Repos repos = mock(Repos.class);
	Repo repo = mock(Repo.class);
	Milestones milestones = mock(Milestones.class);
	Iterable iterable = buildMilestonesIterable();
	doReturn(iterable).when(milestones).iterate(any(Map.class));
	doReturn(milestones).when(repo).milestones();
	doReturn(repo).when(repos).get(any(Coordinates.class));
	doReturn(repos).when(github).repos();
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	assertThat(service.getMilestones(), Matchers.equalTo(milestoneStrings.keySet()));

}
 
Example #9
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getSpringCloudVersionTest() throws Exception {
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	Map<String, String> springCloudVersions = generateSpringCloudData();
	Map<String, Map<String, String>> springCloud = new HashMap<>();
	springCloud.put("spring-cloud", springCloudVersions);
	Map<String, Map<String, Map<String, String>>> info = new HashMap<>();
	info.put("bom-ranges", springCloud);
	when(rest.getForObject(anyString(), eq(Map.class))).thenReturn(info);
	InitializrSpringCloudInfoService service = new InitializrSpringCloudInfoService(
			rest, github, githubPomReader);
	String version = service.getSpringCloudVersion("2.1.0.RELEASE").getVersion();
	assertThat(version, Matchers.equalTo("Greenwich.SR1"));
	version = service.getSpringCloudVersion("2.1.4.RELEASE").getVersion();
	assertThat(version, Matchers.equalTo("Greenwich.SR1"));
	version = service.getSpringCloudVersion("2.1.5.RELEASE").getVersion();
	assertThat(version, Matchers.equalTo("Greenwich.BUILD-SNAPSHOT"));
	version = service.getSpringCloudVersion("1.5.5.RELEASE").getVersion();
	assertThat(version, Matchers.equalTo("Edgware.SR5"));
	version = service.getSpringCloudVersion("1.5.21.BUILD-SNAPSHOT").getVersion();
	assertThat(version, Matchers.equalTo("Edgware.BUILD-SNAPSHOT"));
}
 
Example #10
Source File: Follow.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void perform(Command command, Logger logger) throws IOException {
    final String author = command.authorLogin();
    final Github github = command.issue().repo().github();
    final Request follow = github.entry()
        .uri().path("/user/following/").path(author).back()
        .method("PUT");
    logger.info("Following Github user " + author + " ...");
    try {
        final int status = follow.fetch().status();
        if(status != HttpURLConnection.HTTP_NO_CONTENT) {
            logger.error("User follow status response is " + status + " . Should have been 204 (NO CONTENT)");
        } else {
            logger.info("Followed user " + author + " .");
        }
    } catch (final IOException ex) {//don't rethrow, this is just a cosmetic step, not critical.
        logger.error("IOException while trying to follow the user.");
    }
    this.next().perform(command, logger);
}
 
Example #11
Source File: ValidCommandTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void getsAuthorEmail() throws Exception {
    MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    
    MkGithub authorGh = new MkGithub(storage, "amihaiemil");
    authorGh.users().self().emails().add(Arrays.asList("[email protected]"));
    Repo authorRepo = authorGh.randomRepo();
    Comment com = authorRepo.issues().create("", "").comments().post("@charlesmike do something");

    Github agentGh = new MkGithub(storage, "charlesmike");
    Issue issue = agentGh.repos().get(authorRepo.coordinates()).issues().get(com.issue().number());
    Command comm = Mockito.mock(Command.class);
    
    JsonObject authorInfo = Json.createObjectBuilder().add("login", "amihaiemil").build();
    JsonObject json = Json.createObjectBuilder()
        .add("user", authorInfo)
        .add("body", com.json().getString("body"))
        .add("id", 2)
        .build();
    Mockito.when(comm.json()).thenReturn(json);
    Mockito.when(comm.issue()).thenReturn(issue);

    ValidCommand vc = new ValidCommand(comm);
    assertTrue(vc.authorEmail().equals("[email protected]"));
}
 
Example #12
Source File: StarRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * StarRepo can successfully star a given repository.
 * @throws Exception If something goes wrong.
 */
@Test
public void starsRepo() throws Exception {
    Logger logger = Mockito.mock(Logger.class);
    Mockito.doNothing().when(logger).info(Mockito.anyString());
    Mockito.doThrow(new IllegalStateException("Unexpected error; test failed")).when(logger).error(Mockito.anyString());
    
    Github gh = new MkGithub("amihaiemil");
    Repo repo =  gh.repos().create(
        new RepoCreate("amihaiemil.github.io", false)
    );
    Command com = Mockito.mock(Command.class);
    Issue issue = Mockito.mock(Issue.class);
    Mockito.when(issue.repo()).thenReturn(repo);
    Mockito.when(com.issue()).thenReturn(issue);
    
    Step sr = new StarRepo(Mockito.mock(Step.class));
    assertFalse(com.issue().repo().stars().starred());
    sr.perform(com, logger);
    assertTrue(com.issue().repo().stars().starred());
}
 
Example #13
Source File: StarRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * StarRepo tries to star a repo twice.
 * @throws Exception If something goes wrong.
 */
@Test
public void starsRepoTwice() throws Exception {
    Logger logger = Mockito.mock(Logger.class);
    Mockito.doNothing().when(logger).info(Mockito.anyString());
    Mockito.doThrow(new IllegalStateException("Unexpected error; test failed")).when(logger).error(Mockito.anyString());

    Github gh = new MkGithub("amihaiemil");
    Repo repo =  gh.repos().create(
        new RepoCreate("amihaiemil.github.io", false)
    );
    Command com = Mockito.mock(Command.class);
    Issue issue = Mockito.mock(Issue.class);
    Mockito.when(issue.repo()).thenReturn(repo);
    Mockito.when(com.issue()).thenReturn(issue);

    Step sr = new StarRepo(Mockito.mock(Step.class));
    assertFalse(com.issue().repo().stars().starred());
    sr.perform(com, logger);
    sr.perform(com, logger);
    assertTrue(com.issue().repo().stars().starred());
}
 
Example #14
Source File: TextReplyTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Mock a Github command where the agent is mentioned.
 * @return The created Command.
 * @throws IOException If something goes wrong.
 */
public Command mockCommand(String msg) throws IOException {
    Github gh = new MkGithub("amihaiemil");
    RepoCreate repoCreate = new RepoCreate("amihaiemil.github.io", false);
    gh.repos().create(repoCreate);
    Issue issue = gh.repos().get(
                      new Coordinates.Simple("amihaiemil", "amihaiemil.github.io")
                  ).issues().create("Test issue for commands", "test body");
    Comment c = issue.comments().post(msg);
    
    Command com = Mockito.mock(Command.class);

    Mockito.when(com.json()).thenReturn(c.json());
    Mockito.when(com.issue()).thenReturn(issue);
     
    return com;
}
 
Example #15
Source File: LastCommentTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Agent already replied once to the last comment.
 * @throws Exception if something goes wrong.
 */
@Test
public void agentRepliedAlreadyToTheLastComment() throws Exception {
    final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    final Repo repoMihai = new MkGithub(storage, "amihaiemil").repos().create( new RepoCreate("amihaiemil.github.io", false));
    final Issue issue = repoMihai.issues().create("test issue", "body");
    issue.comments().post("@charlesmike hello!");
    
    final Github charlesmike = new MkGithub(storage, "charlesmike");
    Issue issueCharlesmike = charlesmike.repos().get(repoMihai.coordinates()).issues().get(issue.number());
    issueCharlesmike.comments().post("@amihaiemil hi there, I can help you index... ");

    issue.comments().post("@someoneelse, please check that...");
    
    LastComment lastComment = new LastComment(issueCharlesmike);
    JsonObject jsonComment = lastComment.json();
    JsonObject emptyMentionComment = Json.createObjectBuilder().add("id", "-1").add("body", "").build();
    assertTrue(emptyMentionComment.equals(jsonComment)); 
}
 
Example #16
Source File: LastCommentTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * There is more than 1 mention of the agent in the issue and it has already 
 * replied to others, but the last one is not replied to yet.
 * @throws Exception if something goes wrong.
 */
@Test
public void agentRepliedToPreviousMention() throws Exception {
    final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    final Repo repoMihai = new MkGithub(storage, "amihaiemil").repos().create( new RepoCreate("amihaiemil.github.io", false));
    final Issue issue = repoMihai.issues().create("test issue", "body");
    issue.comments().post("@charlesmike hello!");//first mention
    
    final Github charlesmike = new MkGithub(storage, "charlesmike");
    Issue issueCharlesmike = charlesmike.repos().get(repoMihai.coordinates()).issues().get(issue.number());
    issueCharlesmike.comments().post("@amihaiemil hi there, I can help you index... "); //first reply

    Comment lastMention = issue.comments().post("@charlesmike hello again!!");//second mention
    issue.comments().post("@someoneelse, please check that..."); //some other comment that is the last on the ticket.
    
    LastComment lastComment = new LastComment(issueCharlesmike);
    JsonObject jsonComment = lastComment.json();
    assertTrue(lastMention.json().equals(jsonComment)); 
}
 
Example #17
Source File: SendReplyTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Mock a command.
 * @return The created Command.
 * @throws IOException If something goes wrong.
 */
public Command mockCommand() throws IOException {
    Github gh = new MkGithub("amihaiemil");
    RepoCreate repoCreate = new RepoCreate("amihaiemil.github.io", false);
    gh.repos().create(repoCreate);
    Issue issue = gh.repos().get(
                      new Coordinates.Simple("amihaiemil", "amihaiemil.github.io")
                  ).issues().create("Test issue for commands", "test body");
    Command com = Mockito.mock(Command.class);
    Mockito.when(com.issue()).thenReturn(issue);
    Mockito.when(com.json()).thenReturn(Json.createObjectBuilder().add("body", "@charlesmike hello").build());
    return com;
}
 
Example #18
Source File: StepsTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Mock a command.
 * @return The created Command.
 * @throws IOException If something goes wrong.
 */
private Command mockCommand() throws IOException {
    Github gh = new MkGithub("amihaiemil");
    RepoCreate repoCreate = new RepoCreate("amihaiemil.github.io", false);
    gh.repos().create(repoCreate);
    Issue issue = gh.repos().get(
                      new Coordinates.Simple("amihaiemil", "amihaiemil.github.io")
                  ).issues().create("Test issue for commands", "test body");
    Command com = Mockito.mock(Command.class);
    Mockito.when(com.language()).thenReturn(new English());
    Mockito.when(com.authorLogin()).thenReturn("amihaiemil");
    Mockito.when(com.issue()).thenReturn(issue);
    Mockito.when(com.json()).thenReturn(Json.createObjectBuilder().add("body", "@charlesmike mock command").build());
    return com;
}
 
Example #19
Source File: ErrorReplyTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Mock a Github issue.
 * @return The created Issue.
 * @throws IOException If something goes wrong.
 */
public Issue mockIssue() throws IOException {
    Github gh = new MkGithub("amihaiemil");
    RepoCreate repoCreate = new RepoCreate("amihaiemil.github.io", false);
    gh.repos().create(repoCreate);
    return gh.repos().get(
                      new Coordinates.Simple("amihaiemil", "amihaiemil.github.io")
                  ).issues().create("Test issue for commands", "test body");
}
 
Example #20
Source File: NotificationsResource.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Handles notifications, starts one action thread for each of them.
 * @param notifications List of notifications.
 * @return true if actions were started successfully; false otherwise.
 */
private boolean handleNotifications(final Notifications notifications) {
    String authToken = System.getProperty("github.auth.token");
    if(authToken == null || authToken.isEmpty()) {
        LOG.error("Missing github.auth.token. Please specify a Github api access token!");
        return false;
    } else {
        Github gh = new RtGithub(
            new RtGithub(
                authToken
            ).entry().through(RetryWire.class)
        );
        try {
            for(final Notification notification : notifications) {
                this.actions.take(
                    new Action(
                        gh.repos().get(
                            new Coordinates.Simple(notification.repoFullName())
                        ).issues().get(notification.issueNumber())
                    )
                );
            }
            return true;
        } catch (IOException ex) {
            LOG.error("IOException while getting the Issue from Github API");
            return false;
        }
    }
}
 
Example #21
Source File: FollowTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Mock a command, add issue, repo and github mocks into it.
 * @return Command.
 */
private Command mockCommand() {
    final Command com = Mockito.mock(Command.class);
    Mockito.when(com.authorLogin()).thenReturn("amihaiemil");
    
    final Issue issue = Mockito.mock(Issue.class);
    final Repo repo = Mockito.mock(Repo.class);
    Mockito.when(repo.github()).thenReturn(Mockito.mock(Github.class));
    Mockito.when(issue.repo()).thenReturn(repo);
    
    Mockito.when(com.issue()).thenReturn(issue);
    
    return com;
}
 
Example #22
Source File: ActionTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates an Issue with the given command.
 * @param commander Author of the comment;
 * @param command The comment's body;
 * @return Github issue
 */
public Issue githubIssue(String commander, String command) throws Exception {
    MkStorage storage = new MkStorage.InFile();
    Github commanderGh = new MkGithub(storage, commander);
    RepoCreate repoCreate = new RepoCreate(commander + ".github.io", false);
    commanderGh.repos().create(repoCreate);
    Coordinates repoCoordinates = new Coordinates.Simple(commander, commander + ".github.io");
    Issue issue = commanderGh.repos().get(repoCoordinates).issues().create("Test issue for commands", "test body");
    issue.comments().post(command);
    Github agentGh = new MkGithub(storage, "charlesmike");
    return agentGh.repos().get(repoCoordinates).issues().get(issue.number());
    
}
 
Example #23
Source File: GithubFacadeBuilder.java    From sputnik with Apache License 2.0 5 votes vote down vote up
@NotNull
public GithubFacade build(Configuration configuration) {

    Patchset patchset = PatchsetBuilder.build(configuration);

    String oAuthKey = configuration.getProperty(GeneralOption.GITHUB_API_KEY);
    Github github = new RtGithub(
            new RtGithub(oAuthKey)
                    .entry()
                    .through(RetryWire.class)
    );

    Repo repo = github.repos().get(new Coordinates.Simple(patchset.getProjectPath()));
    return new GithubFacade(repo, patchset);
}
 
Example #24
Source File: SpringCloudInfoApplication.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringCloudInfoService initializrSpringCloudVersionService(
		SpringCloudInfoConfigurationProperties properties) {
	Github github = new RtGithub(properties.getGit().getOauthToken());
	RestTemplate rest = new RestTemplateBuilder().build();
	return new InitializrSpringCloudInfoService(rest, github,
			new GithubPomReader(new MavenXpp3Reader(), rest));
}
 
Example #25
Source File: GithubIssuesTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
public void should_not_do_anything_if_not_applicable_when_updating_startspringio()
		throws IOException {
	setupStartSpringIo();
	Github github = BDDMockito.mock(Github.class);
	GithubIssues issues = new GithubIssues(Collections.emptyList());

	issues.fileIssueInStartSpringIo(
			new Projects(new ProjectVersion("foo", "1.0.0.RELEASE"),
					new ProjectVersion("bar", "2.0.0.RELEASE"),
					new ProjectVersion("baz", "3.0.0.RELEASE")),
			new ProjectVersion("sc-release", "Edgware.RELEASE"));

	BDDMockito.then(github).shouldHaveZeroInteractions();
}
 
Example #26
Source File: GithubIssuesTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
public void should_not_do_anything_for_non_release_train_version_when_updating_startspringio()
		throws IOException {
	setupStartSpringIo();
	Github github = BDDMockito.mock(Github.class);
	GithubIssues issues = new GithubIssues(Collections.emptyList());

	issues.fileIssueInStartSpringIo(
			new Projects(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"),
					new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE")),
			new ProjectVersion("sc-release", "Edgware.BUILD-SNAPSHOT"));

	BDDMockito.then(github).shouldHaveZeroInteractions();
}
 
Example #27
Source File: GithubIssuesTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
public void should_not_do_anything_if_not_applicable() {
	Github github = BDDMockito.mock(Github.class);
	GithubIssues issues = new GithubIssues(Collections.emptyList());

	issues.fileIssueInSpringGuides(
			new Projects(new ProjectVersion("foo", "1.0.0.RELEASE"),
					new ProjectVersion("bar", "2.0.0.RELEASE"),
					new ProjectVersion("baz", "3.0.0.RELEASE")),
			new ProjectVersion("sc-release", "Edgware.RELEASE"));

	BDDMockito.then(github).shouldHaveZeroInteractions();
}
 
Example #28
Source File: GithubIssuesTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
public void should_not_do_anything_for_non_release_train_version() {
	Github github = BDDMockito.mock(Github.class);
	GithubIssues issues = new GithubIssues(Collections.emptyList());

	issues.fileIssueInSpringGuides(
			new Projects(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"),
					new ProjectVersion("spring-cloud-build", "2.0.0.BUILD-SNAPSHOT")),
			new ProjectVersion("sc-release", "Edgware.BUILD-SNAPSHOT"));

	BDDMockito.then(github).shouldHaveZeroInteractions();
}
 
Example #29
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
void should_not_cache_repos_calls_for_different_githubs() {
	Github github1 = mock(Github.class);
	Github github2 = mock(Github.class);
	Github github3 = mock(Github.class);

	new CachingGithub(github1).repos();
	new CachingGithub(github2).repos();
	new CachingGithub(github3).repos();

	verify(github1).repos();
	verify(github2).repos();
	verify(github3).repos();
}
 
Example #30
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
void should_call_repos_only_once_for_same_github() {
	Github github = mock(Github.class);
	Repos repos = mock(Repos.class);
	given(github.repos()).willReturn(repos);
	CachingGithub cachingGithub = new CachingGithub(github);

	cachingGithub.repos();
	cachingGithub.repos();
	cachingGithub.repos();

	verify(github, only()).repos();
}