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