Skip to content

Commit

Permalink
Add some tests for exception types
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Jul 31, 2023
1 parent 7ef6e23 commit 74e03d5
Showing 1 changed file with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

package io.temporal.client.schedules;

import static org.junit.Assume.assumeTrue;

import io.temporal.api.enums.v1.ScheduleOverlapPolicy;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.converter.EncodedValues;
Expand All @@ -40,6 +38,8 @@
import org.junit.Rule;
import org.junit.Test;

import static org.junit.Assume.assumeTrue;

public class ScheduleTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
Expand Down Expand Up @@ -86,10 +86,10 @@ private Schedule.Builder createTestSchedule() {
.build());
}

@Before
public void checkRealServer() {
assumeTrue("skipping for test server", SDKTestWorkflowRule.useExternalService);
}
@Before
public void checkRealServer() {
assumeTrue("skipping for test server", SDKTestWorkflowRule.useExternalService);
}

@Test
public void createSchedule() {
Expand All @@ -111,15 +111,15 @@ public void createSchedule() {
try {
handle.describe();
Assert.fail();
} catch (Exception e) {
} catch (ScheduleException e) {
}
// Create a handle to a non-existent schedule, creating the handle should not throw
// but any operations on it should.
try {
ScheduleHandle badHandle = client.getHandle(UUID.randomUUID().toString());
badHandle.delete();
Assert.fail();
} catch (Exception e) {
} catch (ScheduleException e) {
}
}

Expand Down Expand Up @@ -167,6 +167,12 @@ public void pauseUnpauseSchedule() {
Assert.assertEquals(false, description.getSchedule().getState().isPaused());
// Cleanup schedule
handle.delete();
// Try to unpause a deleted schedule
try {
handle.unpause("");
Assert.fail();
} catch (ScheduleException e) {
}
}

@Test
Expand Down Expand Up @@ -221,6 +227,12 @@ public void triggerSchedule() {
Assert.assertEquals(3, handle.describe().getInfo().getNumActions());
// Cleanup schedule
handle.delete();
// Try to trigger a deleted schedule
try {
handle.trigger();
Assert.fail();
} catch (ScheduleException e) {
}
}

@Test
Expand Down Expand Up @@ -253,6 +265,15 @@ public void backfillSchedules() {
waitForActions(handle, 15);
// Cleanup schedule
handle.delete();
// Try to backfill a deleted schedule
try {
handle.backfill(
Arrays.asList(
new ScheduleBackfill(now.minusMillis(5500), now.minusMillis(2500)),
new ScheduleBackfill(now.minusMillis(2500), now)));
Assert.fail();
} catch (ScheduleException e) {
}
}

@Test
Expand Down Expand Up @@ -356,6 +377,12 @@ public void describeSchedules() {
Assert.assertEquals(schedule.getState(), description.getSchedule().getState());
// Cleanup schedule
handle.delete();
// Try to describe a deleted schedule
try {
handle.describe();
Assert.fail();
} catch (ScheduleException e) {
}
}

@Test
Expand Down

0 comments on commit 74e03d5

Please sign in to comment.