Search in sources :

Example 1 with Deployment

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

the class GitHubDeploymentServiceTest method deployEnvironmentMismatch.

@Test
public void deployEnvironmentMismatch() throws Exception {
    apiProperties.getGitHub().setDeploymentEnvironment(ENVIRONMENT);
    Deployment deployment = mock(Deployment.class);
    GHDeployment ghDeployment = mock(GHDeployment.class);
    when(deployment.getDeployment()).thenReturn(ghDeployment);
    when(ghDeployment.getEnvironment()).thenReturn("foobar");
    instance.deploy(deployment);
    verify(applicationContext, never()).getBean(LegacyFeaturedModDeploymentTask.class);
}
Also used : GHDeployment(org.kohsuke.github.GHDeployment) Deployment(org.kohsuke.github.GHEventPayload.Deployment) GHDeployment(org.kohsuke.github.GHDeployment) Test(org.junit.Test)

Example 2 with Deployment

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

the class GitHubDeploymentServiceTest method deployEnvironmentMatch.

@Test
public void deployEnvironmentMatch() throws Exception {
    apiProperties.getGitHub().setDeploymentEnvironment(ENVIRONMENT);
    // Couldn't be mocked since calling ghDeployment.getId() threw an NPE
    GHDeployment ghDeployment = new GHDeployment() {

        @Override
        public int getId() {
            return 1;
        }

        @Override
        public String getEnvironment() {
            return ENVIRONMENT;
        }

        @Override
        public String getPayload() {
            return "faf";
        }
    };
    Deployment deployment = mock(Deployment.class);
    when(deployment.getDeployment()).thenReturn(ghDeployment);
    GHRepository ghRepository = mock(GHRepository.class);
    GHDeploymentStatusBuilder builder = mock(GHDeploymentStatusBuilder.class);
    when(builder.description(any())).thenReturn(builder);
    when(ghRepository.createDeployStatus(anyInt(), any())).thenReturn(builder);
    when(deployment.getRepository()).thenReturn(ghRepository);
    LegacyFeaturedModDeploymentTask task = mock(LegacyFeaturedModDeploymentTask.class);
    when(task.setFeaturedMod(any())).thenReturn(task);
    when(task.setStatusDescriptionListener(any())).thenReturn(task);
    when(applicationContext.getBean(LegacyFeaturedModDeploymentTask.class)).thenReturn(task);
    when(featuredModService.findModByTechnicalName("faf")).thenReturn(Optional.of(new FeaturedMod()));
    instance.deploy(deployment);
    verify(task).run();
    verify(builder).create();
}
Also used : GHRepository(org.kohsuke.github.GHRepository) GHDeployment(org.kohsuke.github.GHDeployment) GHDeploymentStatusBuilder(org.kohsuke.github.GHDeploymentStatusBuilder) Deployment(org.kohsuke.github.GHEventPayload.Deployment) GHDeployment(org.kohsuke.github.GHDeployment) FeaturedMod(com.faforever.api.data.domain.FeaturedMod) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 GHDeployment (org.kohsuke.github.GHDeployment)2 Deployment (org.kohsuke.github.GHEventPayload.Deployment)2 FeaturedMod (com.faforever.api.data.domain.FeaturedMod)1 GHDeploymentStatusBuilder (org.kohsuke.github.GHDeploymentStatusBuilder)1 GHRepository (org.kohsuke.github.GHRepository)1