Search in sources :

Example 1 with Push

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());
}
Also used : GHRepository(org.kohsuke.github.GHRepository) Push(org.kohsuke.github.GHEventPayload.Push) Test(org.junit.Test)

Example 2 with Push

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

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