Search in sources :

Example 1 with IWebhookTrigger

use of com.openshift.restclient.model.build.IWebhookTrigger in project jbosstools-openshift by jbosstools.

the class WebhookUtilTest method testEmptyWebHooks.

@Test
public void testEmptyWebHooks() {
    IBuildConfig buildConfig = givenBuildConfigWithTriggers();
    List<IWebhookTrigger> webHooks = WebhookUtil.getWebHooks(buildConfig);
    assertNotNull(webHooks);
    assertEquals(0, webHooks.size());
}
Also used : IWebhookTrigger(com.openshift.restclient.model.build.IWebhookTrigger) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Test(org.junit.Test)

Example 2 with IWebhookTrigger

use of com.openshift.restclient.model.build.IWebhookTrigger in project jbosstools-openshift by jbosstools.

the class WebhookUtilTest method testGetWebHooks.

@Test
public void testGetWebHooks() {
    IBuildConfig buildConfig = givenBuildConfigWithTriggers(genericTrigger(), imageChangeTrigger(), githubTrigger());
    List<IWebhookTrigger> webHooks = WebhookUtil.getWebHooks(buildConfig);
    assertEquals(2, webHooks.size());
    assertNotNull(webHooks);
    assertEquals(BuildTriggerType.GENERIC, webHooks.get(0).getType());
    assertEquals(BuildTriggerType.GITHUB, webHooks.get(1).getType());
}
Also used : IWebhookTrigger(com.openshift.restclient.model.build.IWebhookTrigger) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Test(org.junit.Test)

Example 3 with IWebhookTrigger

use of com.openshift.restclient.model.build.IWebhookTrigger in project jbosstools-openshift by jbosstools.

the class WebhookUtil method getWebHooks.

public static List<IWebhookTrigger> getWebHooks(IBuildConfig buildConfig) {
    if (buildConfig == null) {
        return null;
    }
    List<IBuildTrigger> triggers = buildConfig.getBuildTriggers();
    List<IWebhookTrigger> webHooks = null;
    if (triggers == null || triggers.isEmpty()) {
        webHooks = Collections.emptyList();
    } else {
        webHooks = new ArrayList<>(triggers.size());
        for (IBuildTrigger trigger : triggers) {
            IWebhookTrigger webHook = getAsWebHook(trigger);
            if (webHook != null) {
                webHooks.add(webHook);
            }
        }
    }
    return webHooks;
}
Also used : IWebhookTrigger(com.openshift.restclient.model.build.IWebhookTrigger) IBuildTrigger(com.openshift.restclient.model.build.IBuildTrigger)

Aggregations

IWebhookTrigger (com.openshift.restclient.model.build.IWebhookTrigger)3 IBuildConfig (com.openshift.restclient.model.IBuildConfig)2 Test (org.junit.Test)2 IBuildTrigger (com.openshift.restclient.model.build.IBuildTrigger)1