Search in sources :

Example 1 with StartJobTask

use of org.knowm.dropwizard.sundial.tasks.StartJobTask in project dropwizard-sundial by knowm.

the class StartJobTaskTest method shouldGiveErrorMessageIfNoJobNameSpecified.

@Test
public void shouldGiveErrorMessageIfNoJobNameSpecified() throws Exception {
    StartJobTask task = new StartJobTask();
    ImmutableMultimap<String, String> map = ImmutableMultimap.of();
    OutputStream stream = new ByteArrayOutputStream();
    PrintWriter out = new PrintWriter(stream);
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("JOB_NAME");
    task.execute(map, out);
}
Also used : StartJobTask(org.knowm.dropwizard.sundial.tasks.StartJobTask) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with StartJobTask

use of org.knowm.dropwizard.sundial.tasks.StartJobTask in project dropwizard-sundial by knowm.

the class StartJobTaskTest method shouldStartNamedTask.

@Test
public void shouldStartNamedTask() throws Exception {
    StartJobTask task = new StartJobTask();
    ImmutableMultimap<String, String> map = ImmutableMultimap.of("JOB_NAME", "test");
    OutputStream stream = new ByteArrayOutputStream();
    PrintWriter out = new PrintWriter(stream);
    PowerMock.mockStatic(SundialJobScheduler.class);
    SundialJobScheduler.startJob("test", Collections.singletonMap("JOB_NAME", (Object) "test"));
    EasyMock.expectLastCall();
    PowerMock.replay(SundialJobScheduler.class);
    task.execute(map, out);
    PowerMock.verify(SundialJobScheduler.class);
}
Also used : StartJobTask(org.knowm.dropwizard.sundial.tasks.StartJobTask) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with StartJobTask

use of org.knowm.dropwizard.sundial.tasks.StartJobTask in project dropwizard-sundial by knowm.

the class StartJobTaskTest method shouldPassParameters.

@Test
public void shouldPassParameters() throws Exception {
    StartJobTask task = new StartJobTask();
    ImmutableMultimap<String, String> map = ImmutableMultimap.of("JOB_NAME", "test", "Param1", "1", "Param2", "2");
    OutputStream stream = new ByteArrayOutputStream();
    PrintWriter out = new PrintWriter(stream);
    PowerMock.mockStatic(SundialJobScheduler.class);
    SundialJobScheduler.startJob("test", ImmutableMap.of("JOB_NAME", (Object) "test", "Param1", (Object) "1", "Param2", (Object) "2"));
    EasyMock.expectLastCall();
    PowerMock.replay(SundialJobScheduler.class);
    task.execute(map, out);
    PowerMock.verify(SundialJobScheduler.class);
}
Also used : StartJobTask(org.knowm.dropwizard.sundial.tasks.StartJobTask) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 OutputStream (java.io.OutputStream)3 PrintWriter (java.io.PrintWriter)3 Test (org.junit.Test)3 StartJobTask (org.knowm.dropwizard.sundial.tasks.StartJobTask)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3