Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java Client v4] Added ZoneId to SaveScheduleRequest #302

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,9 @@ public String getZoneId() {
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}

public SaveScheduleRequest zoneId(String zoneId) {
this.zoneId = zoneId;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class WorkflowSchedule {

private Long updatedTime = null;

private String zoneId;

public WorkflowSchedule createTime(Long createTime) {
this.createTime = createTime;
return this;
Expand Down Expand Up @@ -185,4 +187,17 @@ public Long getUpdatedTime() {
public void setUpdatedTime(Long updatedTime) {
this.updatedTime = updatedTime;
}

public String getZoneId() {
return zoneId;
}

public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}

public WorkflowSchedule zoneId(String zoneId) {
this.zoneId = zoneId;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

import java.util.List;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import io.orkes.conductor.client.SchedulerClient;
Expand All @@ -24,26 +27,38 @@
import io.orkes.conductor.client.util.ClientTestUtil;
import io.orkes.conductor.client.util.Commons;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class SchedulerClientTests {
private final String NAME = "test_sdk_java_scheduler_name";
private final String CRON_EXPRESSION = "0 * * * * *";

private final SchedulerClient schedulerClient = ClientTestUtil.getOrkesClients().getSchedulerClient();

@BeforeEach
void beforeEach() {
schedulerClient.deleteSchedule(NAME);
}

@AfterEach
void afterEach() {
schedulerClient.deleteSchedule(NAME);
}

@Test
void testMethods() {
schedulerClient.deleteSchedule(NAME);
Assertions.assertTrue(schedulerClient.getNextFewSchedules(CRON_EXPRESSION, 0L, 0L, 0).isEmpty());
schedulerClient.saveSchedule(getSaveScheduleRequest());
Assertions.assertTrue(schedulerClient.getAllSchedules(Commons.WORKFLOW_NAME).size() > 0);
WorkflowSchedule workflowSchedule = schedulerClient.getSchedule(NAME);
Assertions.assertEquals(NAME, workflowSchedule.getName());
Assertions.assertEquals(CRON_EXPRESSION, workflowSchedule.getCronExpression());
assertEquals(NAME, workflowSchedule.getName());
assertEquals(CRON_EXPRESSION, workflowSchedule.getCronExpression());
Assertions.assertFalse(schedulerClient.search(0, 10, "ASC", "*", "").getResults().isEmpty());
schedulerClient.setSchedulerTags(getTagObject(), NAME);
Assertions.assertEquals(getTagObject(), schedulerClient.getSchedulerTags(NAME));
assertEquals(getTagObject(), schedulerClient.getSchedulerTags(NAME));
schedulerClient.deleteSchedulerTags(getTagObject(), NAME);
Assertions.assertEquals(0, schedulerClient.getSchedulerTags(NAME).size());
assertEquals(0, schedulerClient.getSchedulerTags(NAME).size());
schedulerClient.pauseSchedule(NAME);
workflowSchedule = schedulerClient.getSchedule(NAME);
Assertions.assertTrue(workflowSchedule.isPaused());
Expand All @@ -60,7 +75,20 @@ void testDebugMethods() {
schedulerClient.requeueAllExecutionRecords();
}

SaveScheduleRequest getSaveScheduleRequest() {
@Test
@DisplayName("It should set the timezone to Europe/Madrid")
void testTimeZoneId() {
var schedule = new SaveScheduleRequest()
.name(NAME)
.cronExpression(CRON_EXPRESSION)
.startWorkflowRequest(Commons.getStartWorkflowRequest())
.zoneId("Europe/Madrid");
schedulerClient.saveSchedule(schedule);
var savedSchedule = schedulerClient.getSchedule(NAME);
assertEquals("Europe/Madrid", savedSchedule.getZoneId());
}

private SaveScheduleRequest getSaveScheduleRequest() {
return new SaveScheduleRequest()
.name(NAME)
.cronExpression(CRON_EXPRESSION)
Expand Down
Loading