use of flyteidl.core.Condition in project flytekit-java by flyteorg.
the class ProtoUtilTest method shouldSerializeBranchNode.
@Test
void shouldSerializeBranchNode() {
ComparisonExpression comparison = ComparisonExpression.builder().operator(ComparisonExpression.Operator.EQ).leftValue(Operand.ofVar("a")).rightValue(Operand.ofVar("b")).build();
Condition.ComparisonExpression comparisonProto = Condition.ComparisonExpression.newBuilder().setOperator(Condition.ComparisonExpression.Operator.EQ).setLeftValue(Condition.Operand.newBuilder().setVar("a").build()).setRightValue(Condition.Operand.newBuilder().setVar("b").build()).build();
IfBlock ifBlock = IfBlock.builder().condition(BooleanExpression.ofComparison(comparison)).thenNode(Node.builder().id("node-1").upstreamNodeIds(ImmutableList.of()).inputs(ImmutableList.of()).build()).build();
Workflow.IfBlock ifBlockProto = Workflow.IfBlock.newBuilder().setThenNode(Workflow.Node.newBuilder().setId("node-1").build()).setCondition(Condition.BooleanExpression.newBuilder().setComparison(comparisonProto).build()).build();
IfElseBlock ifElse = IfElseBlock.builder().case_(ifBlock).other(ImmutableList.of(ifBlock)).elseNode(ifBlock.thenNode()).build();
Workflow.IfElseBlock ifElseProto = Workflow.IfElseBlock.newBuilder().setCase(ifBlockProto).addOther(ifBlockProto).setElseNode(ifBlockProto.getThenNode()).build();
BranchNode branchNode = BranchNode.builder().ifElse(ifElse).build();
Workflow.BranchNode branchNodeProto = Workflow.BranchNode.newBuilder().setIfElse(ifElseProto).build();
assertThat(ProtoUtil.serialize(branchNode), equalTo(branchNodeProto));
}
Aggregations