Search in sources :

Example 1 with GHDeploymentBuilder

use of org.kohsuke.github.GHDeploymentBuilder in project faf-java-api by FAForever.

the class GitHubDeploymentServiceTest method createDeploymentIfEligible.

@Test
public void createDeploymentIfEligible() throws Exception {
    Push push = mock(Push.class);
    when(push.getRef()).thenReturn("refs/heads/junit");
    when(featuredModService.findByGitUrlAndGitBranch(EXAMPLE_REPO_URL, "junit")).thenReturn(Optional.of(new FeaturedMod().setTechnicalName("faf")));
    GHRepository repository = mock(GHRepository.class);
    when(repository.gitHttpTransportUrl()).thenReturn(EXAMPLE_REPO_URL);
    GHDeploymentBuilder deploymentBuilder = mock(GHDeploymentBuilder.class);
    when(deploymentBuilder.autoMerge(false)).thenReturn(deploymentBuilder);
    when(deploymentBuilder.environment(ENVIRONMENT)).thenReturn(deploymentBuilder);
    when(deploymentBuilder.payload("faf")).thenReturn(deploymentBuilder);
    when(deploymentBuilder.requiredContexts(Collections.emptyList())).thenReturn(deploymentBuilder);
    when(repository.createDeployment("refs/heads/junit")).thenReturn(deploymentBuilder);
    when(push.getRepository()).thenReturn(repository);
    apiProperties.getGitHub().setDeploymentEnvironment(ENVIRONMENT);
    instance.createDeploymentIfEligible(push);
    verify(repository).createDeployment(any());
    verify(deploymentBuilder).autoMerge(false);
    verify(deploymentBuilder).environment(ENVIRONMENT);
    verify(deploymentBuilder).create();
}
Also used : GHRepository(org.kohsuke.github.GHRepository) GHDeploymentBuilder(org.kohsuke.github.GHDeploymentBuilder) Push(org.kohsuke.github.GHEventPayload.Push) FeaturedMod(com.faforever.api.data.domain.FeaturedMod) Test(org.junit.Test)

Aggregations

FeaturedMod (com.faforever.api.data.domain.FeaturedMod)1 Test (org.junit.Test)1 GHDeploymentBuilder (org.kohsuke.github.GHDeploymentBuilder)1 Push (org.kohsuke.github.GHEventPayload.Push)1 GHRepository (org.kohsuke.github.GHRepository)1