Search in sources :

Example 1 with IBuildTrigger

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

the class WebhookUtilTest method mockTrigger.

private IBuildTrigger mockTrigger(Class<? extends IBuildTrigger> clazz, String type) {
    IBuildTrigger trigger = mock(clazz);
    when(trigger.getType()).thenReturn(type);
    return trigger;
}
Also used : IBuildTrigger(com.openshift.restclient.model.build.IBuildTrigger)

Example 2 with IBuildTrigger

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

the class WebhooksPropertySourceTest method test.

@Test
public void test() {
    List<IBuildTrigger> triggers = givenBuildTriggers();
    WebHooksPropertySource source = new WebHooksPropertySource(triggers);
    IPropertyDescriptor[] propertyDescriptors = source.getPropertyDescriptors();
    assertEquals("Exp. descripter for each webhook only", 2, propertyDescriptors.length);
    assertEquals("Generic", propertyDescriptors[0].getId());
    assertEquals("GitHub", propertyDescriptors[1].getId());
}
Also used : WebHooksPropertySource(org.jboss.tools.openshift.internal.ui.property.build.WebHooksPropertySource) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor) IBuildTrigger(com.openshift.restclient.model.build.IBuildTrigger) Test(org.junit.Test)

Example 3 with IBuildTrigger

use of com.openshift.restclient.model.build.IBuildTrigger 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)

Example 4 with IBuildTrigger

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

the class WebhookUtilTest method givenBuildConfigWithTriggers.

private IBuildConfig givenBuildConfigWithTriggers(IBuildTrigger... buildTriggers) {
    IBuildConfig buildConfig = mock(IBuildConfig.class);
    List<IBuildTrigger> triggers = (buildTriggers == null) ? Collections.<IBuildTrigger>emptyList() : Arrays.asList(buildTriggers);
    when(buildConfig.getBuildTriggers()).thenReturn(triggers);
    return buildConfig;
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) IBuildTrigger(com.openshift.restclient.model.build.IBuildTrigger)

Aggregations

IBuildTrigger (com.openshift.restclient.model.build.IBuildTrigger)4 IBuildConfig (com.openshift.restclient.model.IBuildConfig)1 IWebhookTrigger (com.openshift.restclient.model.build.IWebhookTrigger)1 IPropertyDescriptor (org.eclipse.ui.views.properties.IPropertyDescriptor)1 WebHooksPropertySource (org.jboss.tools.openshift.internal.ui.property.build.WebHooksPropertySource)1 Test (org.junit.Test)1