use of org.kohsuke.github.GHEventPayload.Push in project faf-java-api by FAForever.
the class GitHubDeploymentServiceTest method createDeploymentIfEligibleNoConfigurationAvailable.
@Test
public void createDeploymentIfEligibleNoConfigurationAvailable() throws Exception {
Push push = mock(Push.class);
GHRepository repository = mock(GHRepository.class);
when(repository.gitHttpTransportUrl()).thenReturn(EXAMPLE_REPO_URL);
when(push.getRepository()).thenReturn(repository);
when(push.getRef()).thenReturn("refs/heads/junit");
when(featuredModService.findByGitUrlAndGitBranch(EXAMPLE_REPO_URL, "junit")).thenReturn(Optional.empty());
instance.createDeploymentIfEligible(push);
verify(repository, never()).createDeployment(any());
}
use of org.kohsuke.github.GHEventPayload.Push 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