@Test void shouldSerializeTaskTemplate() { Container container = Container.builder() .command(ImmutableList.of("echo")) .args(ImmutableList.of("hello world")) .env(ImmutableList.of(KeyValuePair.of("key", "value"))) .image("alpine:3.7") .build(); Variable stringVar = ApiUtils.createVar(SimpleType.STRING); Variable integerVar = ApiUtils.createVar(SimpleType.INTEGER); TypedInterface interface_ = TypedInterface.builder() .inputs(ImmutableMap.of("x", stringVar)) .outputs(ImmutableMap.of("y", integerVar)) .build(); TaskTemplate template = TaskTemplate.builder().container(container).interface_(interface_).build(); Tasks.TaskTemplate serializedTemplate = ProtoUtil.serialize(template); assertThat( serializedTemplate, equalTo( Tasks.TaskTemplate.newBuilder() .setContainer( Tasks.Container.newBuilder() .setImage("alpine:3.7") .addCommand("echo") .addArgs("hello world") .addEnv( Literals.KeyValuePair.newBuilder() .setKey("key") .setValue("value") .build()) .build()) .setMetadata( Tasks.TaskMetadata.newBuilder() .setRuntime( Tasks.RuntimeMetadata.newBuilder() .setType(Tasks.RuntimeMetadata.RuntimeType.FLYTE_SDK) .setFlavor(ProtoUtil.RUNTIME_FLAVOR) .setVersion(ProtoUtil.RUNTIME_VERSION) .build()) .build()) .setInterface( Interface.TypedInterface.newBuilder() .setInputs( Interface.VariableMap.newBuilder() .putVariables( "x", Interface.Variable.newBuilder() .setType( Types.LiteralType.newBuilder() .setSimple(Types.SimpleType.STRING) .build()) .build()) .build()) .setOutputs( Interface.VariableMap.newBuilder() .putVariables( "y", Interface.Variable.newBuilder() .setType( Types.LiteralType.newBuilder() .setSimple(Types.SimpleType.INTEGER) .build()) .build()) .build()) .build()) .setType(ProtoUtil.TASK_TYPE) .build())); }
static IdentifierOuterClass.Identifier serialize(Identifier id) { IdentifierOuterClass.ResourceType type = getResourceType(id); return IdentifierOuterClass.Identifier.newBuilder() .setResourceType(type) .setDomain(id.domain()) .setProject(id.project()) .setName(id.name()) .setVersion(id.version()) .build(); }
ProtoUtil { static IdentifierOuterClass.Identifier serialize(Identifier id) { IdentifierOuterClass.ResourceType type = getResourceType(id); return IdentifierOuterClass.Identifier.newBuilder() .setResourceType(type) .setDomain(id.domain()) .setProject(id.project()) .setName(id.name()) .setVersion(id.version()) .build(); } }
ProtoUtil { static IdentifierOuterClass.Identifier serialize(Identifier id) { IdentifierOuterClass.ResourceType type = getResourceType(id); return IdentifierOuterClass.Identifier.newBuilder() .setResourceType(type) .setDomain(id.domain()) .setProject(id.project()) .setName(id.name()) .setVersion(id.version()) .build(); } private  ProtoUtil(); }
ProtoUtil { static IdentifierOuterClass.Identifier serialize(Identifier id) { IdentifierOuterClass.ResourceType type = getResourceType(id); return IdentifierOuterClass.Identifier.newBuilder() .setResourceType(type) .setDomain(id.domain()) .setProject(id.project()) .setName(id.name()) .setVersion(id.version()) .build(); } private  ProtoUtil(); static Workflow.WorkflowTemplate serialize(WorkflowTemplate template); }
ProtoUtil { static IdentifierOuterClass.Identifier serialize(Identifier id) { IdentifierOuterClass.ResourceType type = getResourceType(id); return IdentifierOuterClass.Identifier.newBuilder() .setResourceType(type) .setDomain(id.domain()) .setProject(id.project()) .setName(id.name()) .setVersion(id.version()) .build(); } private  ProtoUtil(); static Workflow.WorkflowTemplate serialize(WorkflowTemplate template);  }