Skip to content
This repository was archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Add planed (but not implemented) executors
Browse files Browse the repository at this point in the history
  • Loading branch information
ikikko committed Jan 2, 2015
1 parent 8e459d3 commit a6b34db
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@
@Extension
public class TypetalkWebhookAction implements RootAction {

// FIXME parameterized build
// FIXME check authentication

// TODO handle response back ( if Typetalk supports it )
// TODO add list executor ( with regexp filter )
// TODO add help executor

// TODO enable alias job name
// TODO enable alias job name to simplify build parameter

@Override
public String getIconFileName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.jenkinsci.plugins.typetalk.webhookaction;

import org.jenkinsci.plugins.typetalk.webhookaction.executorimpl.BuildExecutor;
import org.jenkinsci.plugins.typetalk.webhookaction.executorimpl.HelpExecutor;
import org.jenkinsci.plugins.typetalk.webhookaction.executorimpl.ListExecutor;
import org.jenkinsci.plugins.typetalk.webhookaction.executorimpl.UndefinedExecutor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class WebhookExecutorFactory {
public static WebhookExecutor create(StaplerRequest req, StaplerResponse rsp, String message) {
Expand All @@ -20,6 +20,10 @@ public static WebhookExecutor create(StaplerRequest req, StaplerResponse rsp, St
case "build":
String job = messageList.poll();
return new BuildExecutor(req, rsp, job, messageList);
case "list":
return new ListExecutor(req, rsp, command);
case "help":
return new HelpExecutor(req, rsp, command);
default:
return new UndefinedExecutor(req, rsp, command);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jenkinsci.plugins.typetalk.webhookaction.executorimpl;

import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

// TODO add help executor
public class HelpExecutor extends UndefinedExecutor {

public HelpExecutor(StaplerRequest req, StaplerResponse rsp, String command) {
super(req, rsp, command);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jenkinsci.plugins.typetalk.webhookaction.executorimpl;

import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

// TODO add list executor ( with regexp filter )
public class ListExecutor extends UndefinedExecutor {

public ListExecutor(StaplerRequest req, StaplerResponse rsp, String command) {
super(req, rsp, command);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jenkinsci.plugins.typetalk.webhookaction

import org.jenkinsci.plugins.typetalk.webhookaction.executorimpl.BuildExecutor
import org.jenkinsci.plugins.typetalk.webhookaction.executorimpl.HelpExecutor
import org.jenkinsci.plugins.typetalk.webhookaction.executorimpl.ListExecutor
import org.jenkinsci.plugins.typetalk.webhookaction.executorimpl.UndefinedExecutor
import org.kohsuke.stapler.StaplerRequest
import org.kohsuke.stapler.StaplerResponse
Expand All @@ -13,16 +15,7 @@ class WebhookExecutorFactorySpec extends Specification {
def res = Mock(StaplerResponse)

@Unroll
def "create UndefinedExecutor"() {
when:
def executor = WebhookExecutorFactory.create(req, res, "@jenkins+ dummy")

then:
executor.class == UndefinedExecutor
}

@Unroll
def "create BuildExecutor with : #message"() {
def "create BuildExecutor : #message"() {
when:
def executor = WebhookExecutorFactory.create(req, res, message)

Expand All @@ -38,4 +31,29 @@ class WebhookExecutorFactorySpec extends Specification {
"@jenkins+ build typetalk-plugin version=1.0.0" || ["version=1.0.0"]
"@jenkins+ build typetalk-plugin version=1.0.0 env=stage" || ["version=1.0.0", "env=stage"]
}

def "create ListExecutor"() {
when:
def executor = WebhookExecutorFactory.create(req, res, "@jenkins+ list")

then:
executor.class == ListExecutor
}

def "create HelpExecutor"() {
when:
def executor = WebhookExecutorFactory.create(req, res, "@jenkins+ help")

then:
executor.class == HelpExecutor
}

def "create UndefinedExecutor"() {
when:
def executor = WebhookExecutorFactory.create(req, res, "@jenkins+ dummy")

then:
executor.class == UndefinedExecutor
}

}

0 comments on commit a6b34db

Please sign in to comment.