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