use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.
the class SdkTestingExecutorTest method testWithFixedInput_illegalType.
@Test
public void testWithFixedInput_illegalType() {
SdkWorkflow workflow = new SdkWorkflow() {
@Override
public void expand(SdkWorkflowBuilder builder) {
builder.output("string", builder.inputOfString("string"));
}
};
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> SdkTestingExecutor.of(workflow).withFixedInput("string", 42).execute());
assertThat(e.getMessage(), equalTo("Fixed input [string] (of type INTEGER) doesn't match expected type STRING"));
}
use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.
the class SdkTestingExecutorTest method testGetOutput_doesntExist.
@Test
public void testGetOutput_doesntExist() {
SdkWorkflow workflow = new SdkWorkflow() {
@Override
public void expand(SdkWorkflowBuilder builder) {
builder.output("integer", builder.inputOfInteger("integer"));
}
};
SdkTestingExecutor.Result result = SdkTestingExecutor.of(workflow).withFixedInput("integer", 42).execute();
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> result.getStringOutput("string"));
assertThat(e.getMessage(), equalTo("Output [string] doesn't exist in [integer]"));
}
use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.
the class SdkTestingExecutorTest method testPrimitiveTypes.
@Test
public void testPrimitiveTypes() {
SdkWorkflow workflow = new SdkWorkflow() {
@Override
public void expand(SdkWorkflowBuilder builder) {
builder.output("boolean", builder.inputOfBoolean("boolean"));
builder.output("datetime", builder.inputOfDatetime("datetime"));
builder.output("duration", builder.inputOfDuration("duration"));
builder.output("float", builder.inputOfFloat("float"));
builder.output("integer", builder.inputOfInteger("integer"));
builder.output("string", builder.inputOfString("string"));
}
};
SdkTestingExecutor.Result result = SdkTestingExecutor.of(workflow).withFixedInput("boolean", true).withFixedInput("datetime", Instant.ofEpochSecond(1337)).withFixedInput("duration", Duration.ofDays(1)).withFixedInput("float", 1337.0).withFixedInput("integer", 42).withFixedInput("string", "forty two").execute();
assertThat(result.getBooleanOutput("boolean"), equalTo(true));
assertThat(result.getDatetimeOutput("datetime"), equalTo(Instant.ofEpochSecond(1337)));
assertThat(result.getDurationOutput("duration"), equalTo(Duration.ofDays(1)));
assertThat(result.getFloatOutput("float"), equalTo(1337.0));
assertThat(result.getIntegerOutput("integer"), equalTo(42L));
assertThat(result.getStringOutput("string"), equalTo("forty two"));
}
use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.
the class SdkTestingExecutorTest method testWithTask_missingRemoteTask.
@Test
public void testWithTask_missingRemoteTask() {
SdkWorkflow workflow = new SdkWorkflow() {
@Override
public void expand(SdkWorkflowBuilder builder) {
builder.apply("sum", RemoteSumTask.create().withInput("a", 1L).withInput("b", 2L));
}
};
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> SdkTestingExecutor.of(workflow).execute());
assertThat(e.getMessage(), equalTo("Can't execute remote task [remote_sum_task], use SdkTestingExecutor#withTaskOutput or " + "SdkTestingExecutor#withTask"));
}
use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.
the class SdkTestingExecutorTest method testWithTask_missingRemoteTaskOutput.
@Test
public void testWithTask_missingRemoteTaskOutput() {
SdkWorkflow workflow = new SdkWorkflow() {
@Override
public void expand(SdkWorkflowBuilder builder) {
builder.apply("sum", RemoteSumTask.create().withInput("a", 1L).withInput("b", 2L));
}
};
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> SdkTestingExecutor.of(workflow).withTaskOutput(RemoteSumTask.create(), RemoteSumInput.create(10L, 20L), RemoteSumOutput.create(30L)).execute());
assertThat(e.getMessage(), equalTo("Can't find input RemoteSumInput{a=1, b=2} for remote task [remote_sum_task] across known " + "task inputs, use SdkTestingExecutor#withTaskOutput or SdkTestingExecutor#withTask"));
}
Aggregations